li.shaoyi 2 years ago
parent
commit
b1a45cd4c7

+ 2 - 2
src/packages/mobile/views/market/list/Index.vue

@@ -41,7 +41,7 @@
 </template>
 
 <script lang="ts" setup>
-import { onMounted, onUnmounted, computed } from 'vue'
+import { onActivated, onUnmounted, computed } from 'vue'
 import { parsePercent, handleNumberValue, formatDecimal } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
 import { useFuturesStore } from '@/stores'
@@ -107,6 +107,6 @@ const rowClick = (row: Model.GoodsQuote) => {
     })
 }
 
-onMounted(() => subscribe.start(...goodsCodes))
+onActivated(() => subscribe.start(...goodsCodes))
 onUnmounted(() => subscribe.stop())
 </script>

+ 6 - 1
src/packages/mobile/views/spot/add/components/sell/index.vue

@@ -85,7 +85,12 @@ const goodsList = shallowRef<Model.FtDeliveryGoodsRsp['wdlst']>([]) // 商品列
 
 // 仓库列表
 const warehouseList = computed(() => {
-    return wrStandardFactoryItems.value.reduce((res, item) => [...res, ...item.itemlst], [] as Model.WrStandardFactoryItemRsp['itemlst'])
+    return wrStandardFactoryItems.value.reduce<Model.WrStandardFactoryItemRsp['itemlst']>((res, item) => {
+        if (item.dgfactoryitemtypeid === 1) {
+            res.push(...item.itemlst)
+        }
+        return res
+    }, [])
 })
 
 // 表单验证规则

+ 15 - 8
src/packages/mobile/views/swap/list/Index.vue

@@ -38,7 +38,7 @@
 </template>
 
 <script lang="ts" setup>
-import { computed, onUnmounted } from 'vue'
+import { computed, onUnmounted, onActivated } from 'vue'
 import { parsePercent, handleNumberValue, formatDecimal } from '@/filters'
 import { useRequest } from '@/hooks/request'
 import { useNavigation } from '@mobile/router/navigation'
@@ -73,11 +73,12 @@ const { dataList, run } = useRequest(queryQuoteGoodsList, {
 })
 
 const tableList = computed(() => {
-    return dataList.value.map(({ refgoodsid, goodscode, goodsname }) => {
+    return dataList.value.map(({ refgoodsid,refgoodscode, goodscode, goodsname }) => {
         const quote = futuresStore.getGoodsQuote(refgoodsid)
         const { lastColor, openedColor, lowestColor, highestColor, last = 0, presettle = 0, rise = 0, change, amplitude, highest = 0, lowest = 0, opened = 0, decimalplace } = quote.value ?? {}
         return {
             refgoodsid,
+            refgoodscode,
             goodscode,
             goodsname,
             lastColor,
@@ -97,7 +98,8 @@ const tableList = computed(() => {
 })
 
 const columns: Model.TableColumn[] = [
-    { prop: 'goodsname', label: '商品/标的' },
+    { prop: 'goodsname', label: '商品/合约' },
+    { prop: 'refgoodscode', label: '标的' },
     { prop: 'last', label: '当前价' },
     { prop: 'rise', label: '涨跌' },
     { prop: 'change', label: '幅度' },
@@ -109,18 +111,23 @@ const columns: Model.TableColumn[] = [
 ]
 
 const rowClick = (row: Model.QuoteGoodsListRsp) => {
-
-    const { hasauth } = userStore.userAccount
     /// 这里要去判断是否已经实名认证
-    if (hasauth === 1) {
+    if (userStore.hasAuth) {
         setGlobalUrlParams(row)
         router.push({ name: 'swap-detail' })
     } else {
         showToast('未实名认证,请先去实名认证,如果已提交实名认证,请耐心等待审核通过!')
-    }    
+    }
 }
 
-futuresStore.onResponse(() => run())
+onActivated(() => {
+    const goodsCodes = dataList.value.map((e) => e.refgoodscode)
+    if (goodsCodes.length) {
+        subscribe.start(...goodsCodes)
+    } else {
+        run()
+    }
+})
 
 onUnmounted(() => subscribe.stop())
 </script>

+ 21 - 18
src/packages/tjmd/views/home/main/Index.vue

@@ -45,8 +45,8 @@
 </template>
 
 <script lang="ts" setup>
-import { onUnmounted, shallowRef, onActivated, defineAsyncComponent, computed, nextTick } from 'vue'
-import { Cell, CellGroup, PullRefresh, Swipe, SwipeItem, Grid, GridItem } from 'vant'
+import { shallowRef,  defineAsyncComponent, computed, nextTick, watch, watchEffect } from 'vue'
+import { Cell, CellGroup, PullRefresh, Swipe, SwipeItem } from 'vant'
 import { formatDate, parsePercent, handleNumberValue, formatDecimal } from '@/filters'
 import { queryQuoteGoodsList } from '@/services/api/swap'
 import { queryImageConfigs } from '@/services/api/common'
@@ -127,25 +127,28 @@ const onRefresh = () => {
 
 onRefresh()
 
-onActivated(() => {
-  if (!goodsList.value.length && loginStore.token) {
-    // 掉期商品
-    queryQuoteGoodsList({
-      data: {
-        usertype: userStore.userType ?? 0,
-        marketids: userStore.getMarketId('TRADEMODE_TJMD').toString()
-      }
-    }).then((res) => {
-      const goodsCodes = res.data.map((e) => e.refgoodscode)
-      goodsList.value = res.data
-      goodsCode.value = goodsCodes[0]
-      showChart.value = true
+watchEffect(() => {
+  if (loginStore.token) {
+    if (goodsList.value.length) {
+      const goodsCodes = goodsList.value.map((e) => e.refgoodscode)
       subscribe.start(...goodsCodes)
-    })
+    } else {
+      // 掉期商品
+      queryQuoteGoodsList({
+        data: {
+          usertype: userStore.userType ?? 0,
+          marketids: userStore.getMarketId('TRADEMODE_TJMD').toString()
+        }
+      }).then((res) => {
+        const goodsCodes = res.data.map((e) => e.refgoodscode)
+        goodsList.value = res.data
+        goodsCode.value = goodsCodes[0]
+        showChart.value = true
+        subscribe.start(...goodsCodes)
+      })
+    }
   }
 })
-
-onUnmounted(() => subscribe.stop())
 </script>
 
 <style lang="less">

+ 1 - 0
src/services/websocket/quote.ts

@@ -143,6 +143,7 @@ export default new (class {
      * 关闭行情链路
      */
     close() {
+        this.subscribeMap.clear()
         this.socket?.close()
     }
 })