1
李凌
2025-12-16 1201f7a4a72288816033dab8ab5058daf9425590
src/views/homePage/index.vue
@@ -1,7 +1,7 @@
<template>
    <div class="home_page">
        <Head></Head>
        <Head @search="onSearch"></Head>
        <!-- <div class="home_logo flex justify-center"><img src="@/assets/imgs/home/home_logo.png" alt=""></div> -->
        <!-- <van-swipe class="home_logo" :autoplay="3000" indicator-color="white">
            <van-swipe-item><img src="@/assets/imgs/home/Slider-1.jpg" alt=""></van-swipe-item>
@@ -125,6 +125,7 @@
    // { key: 12, name: "C2C", icon: new URL('@/assets/imgs/home/home_1.png', import.meta.url), path: '/wantBuy' },
    // { key: 13, name: t('质押'), icon: new URL('@/assets/imgs/home/home_1.png', import.meta.url), path: '' },
    { key: 14, name: t('onLineService'), icon: new URL('@/assets/imgs/home/home_10.png', import.meta.url), path: '/customerService' },
    { key: 15, name: t('MCB白皮书'), icon: new URL('@/assets/imgs/home/home_1.png', import.meta.url), path: '/aboutUs?serviceTerm=28' },
]
// 获取公告数据
@@ -171,6 +172,8 @@
//#region 行情数据----------------------------------------
let qList = ref([])
let qListCope = ref([]) // 备份数据
let key = ref('') // 搜索关键词
let timeout = ref(null)
const coinArr = computed(() => store.getters['home/coinArr']);
@@ -181,7 +184,16 @@
    if (!(list instanceof Array)) {
        return
    }
    qList.value = list;
    // 通过关键字进行筛选
    if (key.value) {
        qList.value = list.filter(item => {
            return item.symbol_data.toLowerCase().includes(key.value.toLowerCase()) || item.name.toLowerCase().includes(key.value.toLowerCase())
        })
    } else {
        qList.value = list
    }
    qListCope.value = list; // 备份数据
    if (timeout.value) {
        clearTimeout(timeout.value)
@@ -192,6 +204,20 @@
}
fetchQList()
// 搜索
const onSearch = (val) => {
    key.value = val
    if (!val) {
        qList.value = qListCope.value
        return
    }
    let newList = qListCope.value.filter(item => {
        return item.symbol_data.toLowerCase().includes(val.toLowerCase()) || item.name.toLowerCase().includes(val.toLowerCase())
    })
    qList.value = newList
}
onBeforeUnmount(() => {
    if (timeout.value) {
        clearTimeout(timeout.value)