From b37eef5a0807a8f5688e2112591cb80a3ba333e4 Mon Sep 17 00:00:00 2001
From: lxf <1371462558@qq.com>
Date: Tue, 08 Jul 2025 22:31:48 +0800
Subject: [PATCH] style
---
src/views/cryptos/index.vue | 34 +++++++++++++++++++++++-----------
1 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/src/views/cryptos/index.vue b/src/views/cryptos/index.vue
index e76dcf5..19acbaf 100644
--- a/src/views/cryptos/index.vue
+++ b/src/views/cryptos/index.vue
@@ -73,6 +73,7 @@
import { _getUnreadMsg } from '@/service/im.api'
import { _getNewsList1, _getPopupNews } from '@/service/user.api'
import { BASE_URL } from "@/config";
+import { _getCoinList } from '@/service/quotes.api';
const THEME = 'dark'
export default {
name: "HomePage",
@@ -135,22 +136,33 @@
},
async fetchQList(v) { // 获取行情
let coninArr = ''
- if (v) { this.getVal = v }
- // if(this.getVal == 2) {
- let arr = getStorage('qoutes').coins
- arr.map((item) => {
+ // if (v) { this.getVal = v }
+ let arr = getStorage('qoutes')
+
+ // 优先用本地缓存的 coins
+ let coins = (arr && arr.coins && arr.coins.length) ? arr.coins : arr
+
+ if (coins && coins.length) {
+ // 如果本地有 coins,优先用本地
+ coins.forEach(item => {
coninArr += item.symbol + ','
})
- // }else{
- // coninArr = this.coinArr.join(',')
- // }
+ } else {
+ // 如果本地没有 coins,拉取接口
+ const quotesData = await _getCoinList()
+ if (quotesData && quotesData.coins && quotesData.coins.length) {
+ quotesData.coins.forEach(item => {
+ coninArr += item.symbol + ','
+ })
+ }
+ }
console.log('fetchQList', v, coninArr)
// if()
const list = await _getHomeList(coninArr).catch(() => {
- //TODO: 轮询
- // this.timeout = setTimeout(() => {
- // this.fetchQList()
- // }, 1000)
+ //请求失败时,1秒后重试
+ this.timeout = setTimeout(() => {
+ this.fetchQList()
+ }, 1000)
})
if (!(list instanceof Array)) {
return
--
Gitblit v1.9.3