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/news/index.vue                           |   10 ++
 .gitignore                                         |    1 
 src/components/Transform/list-quotation/index.vue  |    8 +-
 src/views/cryptos/index.vue                        |   34 +++++++---
 src/config/index.js                                |    7 +-
 src/components/Transform/contract-header/index.vue |   39 ++++++++++---
 src/views/cryptos/PerpetualContract/index.vue      |    4 
 src/views/cryptos/TrendDetails/index.vue           |    6 +-
 src/views/cryptos/Trade/index.vue                  |    2 
 src/components/Transform/trade-head/index.vue      |   33 +++++++++--
 10 files changed, 103 insertions(+), 41 deletions(-)

diff --git a/.gitignore b/.gitignore
index 06c32c9..220c816 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
 bower_components/
 .pnp/
 .pnp.js
+*.zip
 
 # 测试相关
 coverage/
diff --git a/src/components/Transform/contract-header/index.vue b/src/components/Transform/contract-header/index.vue
index f66a27f..28d2b42 100644
--- a/src/components/Transform/contract-header/index.vue
+++ b/src/components/Transform/contract-header/index.vue
@@ -60,7 +60,7 @@
           </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 class="mt-10 font-28" :class="item.change_ratio_str > 0 ? 'text-green' : 'text-red'">{{ item.change_ratio_str
             }}%</div>
           </div>
         </div>
@@ -75,7 +75,8 @@
 import { _getHomeList } from "@/service/home.api";
 import { useQuotesStore } from '@/store/quotes.store';
 import { THEME } from '@/config/theme'
-import { setStorage } from '@/utils/utis'
+import { setStorage, getStorage } from '@/utils/utis'
+import { _getCoinList } from '@/service/quotes.api'; 
 export default {
   name: "contractHeader",
   props: {
@@ -153,15 +154,35 @@
       }
       this.show = false
     },
-    onSidebar() { // 侧边栏打开
+    async onSidebar() { // 侧边栏打开
       // console.log('侧边栏打开: ', this.selectIndex)
-      if (this.selectIndex == 2) {
-        const quotesData = JSON.parse(localStorage.getItem('qoutes'));
-        this.coins = quotesData.coins || [];
-        this.coins = quotesData.coins.map(item => item.symbol)
+      // if (this.selectIndex == 2) {
+       // 优先用本地缓存的 coins
+       let arr = getStorage('qoutes')
+     let coninArr = ''
+     console.log('arr:', arr)
+
+      if (arr && arr.length) {
+        // 如果本地有 coins,优先用本地
+        arr.forEach(item => {
+          coninArr += item.symbol + ','
+        })
       } else {
-        this.coins = this.coinList.map(item => item.symbol);
+        // 如果本地没有 coins,拉取接口
+        const quotesData = await _getCoinList()
+        console.log('quotesData:', quotesData)
+          quotesData.forEach(item => {
+            coninArr += item.symbol + ','
+          })
+          setStorage('qoutes', { coins: quotesData }) // 存到本地
       }
+      this.coins = coninArr
+        // const quotesData = JSON.parse(localStorage.getItem('qoutes'));
+        // this.coins = quotesData.coins || [];
+        // this.coins = quotesData.coins.map(item => item.symbol)
+      // } else {
+      //   this.coins = this.coinList.map(item => item.symbol);
+      // }
 
       // quotesStore.coins
 
@@ -170,7 +191,7 @@
       this.fetchList()
     },
     fetchList() { // 获取行情
-      _getHomeList(this.coins.join(',')).then(list => {
+      _getHomeList(this.coins).then(list => {
         // console.log(list)
         this.list = list
         if (this.timeout) {
diff --git a/src/components/Transform/list-quotation/index.vue b/src/components/Transform/list-quotation/index.vue
index f42dd52..5b7ed98 100644
--- a/src/components/Transform/list-quotation/index.vue
+++ b/src/components/Transform/list-quotation/index.vue
@@ -57,9 +57,9 @@
               </li>
               <li class="flex flex-col items-end mid">
                 <p class="textColor font-32 font-600">{{ item.close || '--' }}</p>
-                <p class="font-24 text-grey">{{ currency.currency_symbol }}
+                <!-- <p class="font-24 text-grey">{{ currency.currency_symbol }}
                   {{ item.close && item.symbol_data.toUpperCase() == 'SHIB' ? (item.close * currency.rate).toFixed(8) : (item.close *
-                    currency.rate).toFixed(2) || '--' }}</p>
+                    currency.rate).toFixed(2) || '--' }}</p> -->
               </li>
               <li class="right flex items-center justify-end">
                 <p class="w-153 font-31 h-71 bg-green text-white border-0 text-center btn" v-if="item.change_ratio_str > 0">
@@ -91,8 +91,8 @@
               </li>
               <li class="flex flex-col items-end mid">
                 <p class="textColor font-32 font-600">{{ item.close }}</p>
-                <p class="font-24 text-grey">{{ currency.currency_symbol }} {{ item.close && item.symbol_data.toUpperCase() == 'SHIB' ? (item.close * currency.rate).toFixed(8) : (item.close *
-                    currency.rate).toFixed(2) || '--' }}</p>
+                <!-- <p class="font-24 text-grey">{{ currency.currency_symbol }} {{ item.close && item.symbol_data.toUpperCase() == 'SHIB' ? (item.close * currency.rate).toFixed(8) : (item.close *
+                    currency.rate).toFixed(2) || '--' }}</p> -->
               </li>
               <li class="right flex items-center justify-end text-right">
                 <div v-if="active == 3" class="textColor w-182 font-700 font-24">
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) {
diff --git a/src/config/index.js b/src/config/index.js
index 5c924a8..2dd6213 100644
--- a/src/config/index.js
+++ b/src/config/index.js
@@ -42,7 +42,7 @@
 // const ENV_PRO = 'qheufhj.site' //  app域名
 // const ENV_PRO = window.location.hostname // 接口域名跟随 H5zhapi.coinbtcs.com
 // const ENV_PRO = 'openapi.yanshiz.com' // 接口域名跟随 H5zhapi.coinbtcs.com
-const ENV_PRO = '192.168.10.18:8086' // 接口域名跟随 H5zhapi.coinbtcs.com
+const ENV_PRO = 'aa.yanshiz.com' // 接口域名跟随 H5zhapi.coinbtcs.com
 
 let base_url = ''
 let ws_url = ''
@@ -50,7 +50,7 @@
 if (import.meta.env.MODE === 'development') {
     host_url = 'https://' + ENV_DEV
     base_url = 'https://' + ENV_DEV
-    ws_url = 'ws://' + ENV_DEV + '/api/websocket'
+    ws_url = 'wss://' + ENV_DEV + '/api/websocket'
 } else {
     host_url = 'https://' + ENV_PRO
     base_url = 'https://' + ENV_PRO
@@ -59,7 +59,8 @@
 export const BASE_URL = base_url
 export const WS_URL = ws_url
 export const IMG_PATH = host_url
-export const HOST_URL = host_url
+// export const HOST_URL = host_url
+export const HOST_URL = 'https://forex.yanshiz.com'; // 静态资源地址
 
 export default {
     sliderOptions: {
diff --git a/src/views/cryptos/PerpetualContract/index.vue b/src/views/cryptos/PerpetualContract/index.vue
index 86f95b1..c8faae1 100644
--- a/src/views/cryptos/PerpetualContract/index.vue
+++ b/src/views/cryptos/PerpetualContract/index.vue
@@ -489,11 +489,11 @@
       })
     },
     handleQoutes(data) {
-      // console.log('handleQoutes: ', data);
+      console.log('handleQoutes: ', data);
       if (data && data.length) {
         const cur = data[0]
         this.price = cur.close
-        this.range = cur.changeRatioStr + ''
+        this.range = (cur.change_ratio_str || cur.changeRatioStr)
         this.quote = cur
         this.updateKey++
       }
diff --git a/src/views/cryptos/Trade/index.vue b/src/views/cryptos/Trade/index.vue
index 7754420..2a47c74 100644
--- a/src/views/cryptos/Trade/index.vue
+++ b/src/views/cryptos/Trade/index.vue
@@ -378,7 +378,7 @@
       if (data && data.length) {
         const cur = data[0]
         this.price = cur.close
-        this.range = cur.change_ratio + ''
+        this.range = cur.change_ratio_str || cur.changeRatioStr
         this.quote = cur
         this.updateKey++
       }
diff --git a/src/views/cryptos/TrendDetails/index.vue b/src/views/cryptos/TrendDetails/index.vue
index 25845ca..bf94aca 100644
--- a/src/views/cryptos/TrendDetails/index.vue
+++ b/src/views/cryptos/TrendDetails/index.vue
@@ -16,11 +16,11 @@
         <div class="data-index">
           <div class="flex flex-1 px-32 mt-40">
             <div class="flex flex-col font-22">
-              <p class="font-70 font-600" :class="quote.change_ratio > 0 ? 'text-green' : 'text-red'">
+              <p class="font-70 font-600" :class="quote.change_ratio_str > 0 ? 'text-green' : 'text-red'">
                 {{ quote.close || '--' }}</p>
               <p class="font-22 mt-10">≈ {{ currency.currency_symbol }}{{ quote.close ? (quote.close *
                 currency.rate).toFixed(2) : '--' }}
-                <span :class="quote.change_ratio > 0 ? 'text-green' : 'text-red'">{{ quote.change_ratio
+                <span :class="quote.change_ratio_str > 0 ? 'text-green' : 'text-red'">{{ quote.changeRatioStr
                   ||
                   '--' }}%</span>
               </p>
@@ -551,7 +551,7 @@
 }
 
 :deep(.van-tabs__nav) {
-  background-color: $night !important;
+  // background-color: $night !important;
 }
 
 @keyframes animate1 {
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
diff --git a/src/views/news/index.vue b/src/views/news/index.vue
index ba067ae..07bdf6c 100644
--- a/src/views/news/index.vue
+++ b/src/views/news/index.vue
@@ -45,7 +45,7 @@
             </div>
           </div>
           <div class="flex justify-between">
-            <div class="py-2 px-8 rounded-full text-13 font-medium bg-white">{{item.change_ratio}}</div>
+            <div class="py-2 px-8 rounded-full text-13 font-medium bg-white">{{item.change_ratio_str}}</div>
             <span class="text-18">→</span>
           </div>
         </div>
@@ -63,7 +63,7 @@
       </div>
       <div class="text-center">{{t('理財')}}</div>
     </div>
-    <div class="flex-1 flex flex-col items-center" @click="goToPage('/cryptos/trade/btcusdt')">
+    <div class="flex-1 flex flex-col items-center" @click="goToPage('/cryptos/trade/USDSGD')">
       <div class="w-40 h-40 rounded-full flex items-center justify-center">
         <img class="w-33 h-33" src="@/assets/c.jpg" draggable="false">
       </div>
@@ -127,6 +127,8 @@
 import { showToast } from 'vant'
 import { useI18n } from 'vue-i18n'
 import { useRouter } from 'vue-router'
+import { _getCoinList } from '@/service/quotes.api'
+import { setStorage } from '@/utils/index'
 const router = useRouter()
 
 const { t } = useI18n()
@@ -144,6 +146,10 @@
   console.log('user', user)
   username.value = user.userInfo?.username || ''
   usercode.value = user.userInfo?.usercode || ''
+
+  // 如果本地没有 coins,拉取接口
+  const quotesData = await _getCoinList()
+  setStorage('qoutes', { coins: quotesData }) // 存到本地
 })
 
 const goToExplanation = () => {

--
Gitblit v1.9.3