li.shaoyi před 1 rokem
rodič
revize
d2e021841b

+ 2 - 2
oem/ykhj/config/appconfig.json

@@ -1,8 +1,8 @@
 {
   "appId": "cn.muchinfo.ykhj",
   "appName": "永坤黄金",
-  "version": "1.0.5",
-  "versionCode": "100005",
+  "version": "1.0.6",
+  "versionCode": "100006",
   "apiUrl": "http://120.25.76.98:8280/cfg?key=ykhj_ddgl",
   "tradeChannel": "ws",
   "modules": [

+ 20 - 20
src/packages/sbyj/views/market/list/index.vue

@@ -61,7 +61,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, computed, onActivated, onDeactivated, ref, onMounted, onUnmounted } from 'vue'
+import { shallowRef, computed, onActivated, onDeactivated, ref } from 'vue'
 import moment, { Moment } from 'moment'
 import { getServerTime } from '@/services/api/common'
 import { handleNumberValue, formatDecimal } from '@/filters'
@@ -134,27 +134,23 @@ if (loginStore.token) {
                 futuresStore.updateQuotation(item ?? { goodscode })
             })
             subscribe.start(...subscribeData.value)
-
-            const [firstMarket] = touristTradeGoodsList.value
-            if (firstMarket) {
-                /// 获取市场运行情况
-                marketRun({
-                    marketID: firstMarket.marketid
-                })
-            }
         })
     })
 }
 
-const { data: market, run: marketRun } = useRequest(queryMarketRun, {
+const { dataList: marketList, run: marketRun } = useRequest(queryMarketRun, {
     manual: true,
-    onSuccess: (res) => {
-        market.value = res.data[0]
+    onSuccess: () => {
         // 每1分钟轮询刷新
         timerTask.setTimeout(() => marketRun(), 60 * 1000, 'getMarketRun')
     }
 })
 
+const market = computed(() => {
+    const [firstMarket] = touristTradeGoodsList.value
+    return marketList.value.find((e) => e.marketid === firstMarket?.marketid)
+})
+
 // 校验服务器时间
 const checkServerTime = () => {
     getServerTime().then((res) => {
@@ -166,21 +162,25 @@ const checkServerTime = () => {
     })
 }
 
-onMounted(() => {
+const clearTimer = () => {
+    timerTask.clearInterval('refreshTime')
+    timerTask.clearTimeout('getServerTime')
+    timerTask.clearTimeout('getMarketRun')
+}
+
+onActivated(() => {
+    subscribeData.value.length && subscribe.start(...subscribeData.value)
     serverTime.value = moment(new Date())
     timerTask.setInterval(() => {
         serverTime.value = moment(serverTime.value).add(1000, 'ms')
     }, 1000, 'refreshTime')
     checkServerTime()
+    marketRun()
 })
 
-onActivated(() => subscribeData.value.length && subscribe.start(...subscribeData.value))
-onDeactivated(() => subscribe.stop())
-
-onUnmounted(() => {
-    timerTask.clearInterval('refreshTime')
-    timerTask.clearTimeout('getServerTime')
-    timerTask.clearTimeout('getMarketRun')
+onDeactivated(() => {
+    subscribe.stop()
+    clearTimer()
 })
 </script>