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/components/Transform/trade-head/index.vue |   33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/src/components/Transform/trade-head/index.vue b/src/components/Transform/trade-head/index.vue
index 993e374..3c42e03 100644
--- a/src/components/Transform/trade-head/index.vue
+++ b/src/components/Transform/trade-head/index.vue
@@ -69,8 +69,8 @@
             </div>
             <div class="text-right">
               <div class="textColor font-28">{{ item.close || '--' }}</div>
-              <div class="mt-10 font-28" :class="item.change_ratio > 0 ? 'text-green' : 'text-red'">
-                {{ item.change_ratio }}%</div>
+              <div class="mt-10 font-28" :class="item.change_ratio_str > 0 ? 'text-green' : 'text-red'">
+                {{ item.change_ratio_str }}%</div>
             </div>
           </div>
         </div>
@@ -82,7 +82,7 @@
 </template>
     
 <script>
-import { setStorage, handleImage } from '@/utils/utis.js'
+import { getStorage, setStorage, handleImage } from '@/utils/utis.js'
 import { Popup, showSuccessToast } from "vant";
 import { mapGetters } from "vuex";
 import { _getHomeList, _collect, _deleteCollect, _checkIsInCollect } from "@/service/home.api";
@@ -90,6 +90,7 @@
 import { useRouter } from "vue-router";
 import addCurrency from '@/components/add-currency/index.vue'
 import { _isItemHasAdd, _isItemHasAddGlobal } from '@/service/quotes.api'
+import {_getCoinList} from '@/service/quotes.api'
 const router = useRouter()
 export default {
   name: "contractHeader",
@@ -222,14 +223,34 @@
       }
       this.show = false
     },
-    onSidebar() { // 侧边栏打开
+    async onSidebar() { // 侧边栏打开
       // console.log(this.userInfo)
-      this.coins = this.coinList.map(item => item.symbol)
+     // 优先用本地缓存的 coins
+     let arr = getStorage('qoutes')
+     let coninArr = ''
+     console.log('arr:', arr)
+
+      if (arr && arr.length) {
+        // 如果本地有 coins,优先用本地
+        arr.forEach(item => {
+          coninArr += item.symbol + ','
+        })
+      } else {
+        // 如果本地没有 coins,拉取接口
+        const quotesData = await _getCoinList()
+        console.log('quotesData:', quotesData)
+          quotesData.forEach(item => {
+            coninArr += item.symbol + ','
+          })
+          setStorage('qoutes', { coins: quotesData }) // 存到本地
+      }
+      this.coins = coninArr
+      // this.coins = this.coinList.map(item => item.symbol)
       this.show = true
       this.fetchList()
     },
     fetchList() { // 获取行情
-      _getHomeList(this.coins.join(',')).then(list => {
+      _getHomeList(this.coins).then(list => {
         // console.log(list)
         this.list = list
         if (this.timeout) {

--
Gitblit v1.9.3