li.shaoyi 9 kuukautta sitten
vanhempi
commit
44ccde7eb6

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

@@ -1,8 +1,8 @@
 {
   "appId": "com.muchinfo.tss",
   "appName": "TCE",
-  "version": "1.0.42",
-  "versionCode": "100042",
+  "version": "1.0.43",
+  "versionCode": "100043",
   "apiUrl": "http://192.168.31.210:8080/cfg?key=test_210",
   "tradeChannel": "ws",
   "showLoginAlert": true,

+ 178 - 0
src/packages/sbyj/views/market/list/composables.ts

@@ -0,0 +1,178 @@
+import { shallowRef, computed, onActivated, onDeactivated, ref } from 'vue'
+import moment, { Moment } from 'moment'
+import { getServerTime } from '@/services/api/common'
+import { useNavigation } from '@mobile/router/navigation'
+import { queryTouristGoods, queryTouristQuoteDay } from '@/services/api/goods'
+import { useFuturesStore, useLoginStore, useUserStore } from '@/stores'
+import { timerTask } from '@/utils/timer'
+import { useRequest } from '@/hooks/request'
+import { queryImageConfigs } from "@/services/api/common"
+import { queryMarketRun } from '@/services/api/market'
+import quoteSocket from '@/services/websocket/quote'
+
+export function useSetup() {
+    const { router } = useNavigation()
+    const futuresStore = useFuturesStore()
+    const loginStore = useLoginStore()
+    const subscribe = quoteSocket.createSubscribe()
+    // 订阅的商品代码
+    const subscribeData = shallowRef<string[]>([])
+    // 系统时间
+    const serverTime = ref<Moment>()
+
+    const { getSystemParamValue } = useUserStore()
+    const system_1012 = getSystemParamValue('1012') ?? '1'
+
+    // 请求背景图
+    const { dataList: banners } = useRequest(queryImageConfigs, {
+        params: {
+            imageType: 2
+        }
+    })
+
+    // 构建游客交易商品 任务 #6614
+    const touristTradeGoodsList = computed(() => {
+        const list = futuresStore.getGoodsListByTradeMode(52)
+        const result = list.sort((a, b) => a.goodsorder.localeCompare(b.goodsorder))
+
+        // 分组
+        return result.reduce<{
+            groupId: number;
+            groupName: string;
+            marketId: number;
+            goodsList: Model.GoodsQuote[];
+        }[]>((pre, cur) => {
+            const existingGroup = pre.find((e) => e.groupId === cur.goodsgroupid)
+
+            if (existingGroup) {
+                existingGroup.goodsList.push(cur)
+            } else {
+                pre.push({
+                    groupId: cur.goodsgroupid,
+                    groupName: cur.goodsgroupname,
+                    marketId: cur.marketid,
+                    goodsList: [cur]
+                })
+            }
+
+            return pre
+        }, [])
+    })
+
+    // 构建游客参考行情商品
+    const touristRefGoodsList = computed(() => {
+        const list = futuresStore.getGoodsListByTradeMode(99, 97)
+        return list.sort((a, b) => a.goodsorder.localeCompare(b.goodsorder))
+    })
+
+    const rowClick = (row: Model.GoodsQuote) => {
+        router.push({
+            name: 'market-detail',
+            query: {
+                goodscode: row.goodscode
+            }
+        })
+    }
+
+    // 游客商品点击
+    const touristRowClick = (row: Model.GoodsQuote) => {
+        /// 不显示图标
+        if (system_1012 != '1') {
+            return
+        }
+        router.push({
+            name: 'market-chart',
+            query: {
+                goodscode: row.goodscode
+            }
+        })
+    }
+
+    if (loginStore.token) {
+        futuresStore.onDataCompleted(() => {
+            subscribeData.value = futuresStore.goodsList.map((e) => e.goodscode)
+            subscribe.start(...subscribeData.value)
+        })
+    } else {
+        // 获取游客商品列表
+        queryTouristGoods({
+            data: {
+                trademodes: '52,99,97'
+            }
+        }).then((res) => {
+            if (res.data.length) {
+                futuresStore.goodsList = res.data
+                subscribeData.value = res.data.map((e) => e.goodscode)
+
+                // 获取游客商品盘面
+                queryTouristQuoteDay({
+                    data: {
+                        goodsCodes: subscribeData.value.join(',')
+                    }
+                }).then((res) => {
+                    subscribeData.value.forEach((goodscode) => {
+                        const item = res.data.find((e) => e.goodscode === goodscode)
+                        futuresStore.updateQuotation(item ?? { goodscode })
+                    })
+                    subscribe.start(...subscribeData.value)
+                })
+            }
+        })
+    }
+
+    const { dataList: marketList, run: marketRun } = useRequest(queryMarketRun, {
+        manual: true,
+        onSuccess: () => {
+            // 每1分钟轮询刷新
+            timerTask.setTimeout(() => marketRun(), 60 * 1000, 'getMarketRun')
+        }
+    })
+
+    // 获取市场状态
+    const getMarketStatus = (marketId: number) => {
+        const marketInfo = marketList.value.find((e) => e.marketid === marketId)
+        return marketInfo && [2, 6].includes(marketInfo.runstatus) ? '开盘' : '停盘'
+    }
+
+    // 校验服务器时间
+    const checkServerTime = () => {
+        getServerTime().then((res) => {
+            serverTime.value = moment(res.data)
+            // 每1分钟同步一次服务器时间
+            timerTask.setTimeout(() => {
+                checkServerTime()
+            }, 60 * 1000, 'getServerTime')
+        })
+    }
+
+    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()
+    })
+
+    onDeactivated(() => {
+        subscribe.stop()
+        clearTimer()
+    })
+
+    return {
+        banners,
+        serverTime,
+        touristTradeGoodsList,
+        touristRefGoodsList,
+        getMarketStatus,
+        rowClick,
+        touristRowClick
+    }
+}

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

@@ -1,7 +1,7 @@
 <template>
     <app-view class="market">
         <template #header>
-            <app-navbar class="market-header" :show-back-button="false" :style="topBG" />
+            <app-navbar class="market-header" :show-back-button="false" :style="firstBanner" />
             <div style="padding: 12px;font-size: 14px;display: flex;justify-content: space-between;">
                 <span>
                     {{ serverTime?.format('YYYY/MM/DD HH:mm:ss') }}
@@ -73,180 +73,23 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, computed, onActivated, onDeactivated, ref } from 'vue'
-import moment, { Moment } from 'moment'
-import { getServerTime } from '@/services/api/common'
+import { computed } from 'vue'
 import { handleNumberValue, formatDecimal, getFileUrl } from '@/filters'
-import { useNavigation } from '@mobile/router/navigation'
-import { queryTouristGoods, queryTouristQuoteDay } from '@/services/api/goods'
-import { useFuturesStore, useLoginStore, useUserStore } from '@/stores'
-import { timerTask } from '@/utils/timer'
-import { useRequest } from '@/hooks/request'
-import { queryImageConfigs } from "@/services/api/common"
-import { getRunStatusName } from '@/constants/market'
-import { queryMarketRun } from '@/services/api/market'
-import quoteSocket from '@/services/websocket/quote'
-
-const { router } = useNavigation()
-const futuresStore = useFuturesStore()
-const loginStore = useLoginStore()
-const subscribe = quoteSocket.createSubscribe()
-// 订阅的商品代码
-const subscribeData = shallowRef<string[]>([])
-// 系统时间
-const serverTime = ref<Moment>()
-const topBG = ref('')
-
-const { getSystemParamValue } = useUserStore()
-const system_1012 = getSystemParamValue('1012') ?? '1'
-
-// 请求背景图
-useRequest(queryImageConfigs, {
-    params: {
-        imageType: 2
-    },
-    onSuccess: (res) => {
-        const [firstItem] = res.data
-        if (firstItem) {
-            topBG.value = `--header-bg:url(${getFileUrl(firstItem.imagepath)})`
-        }
-    }
-})
-
-// 构建游客交易商品 任务 #6614
-const touristTradeGoodsList = computed(() => {
-    const list = futuresStore.getGoodsListByTradeMode(52)
-    const result = list.sort((a, b) => a.goodsorder.localeCompare(b.goodsorder))
-
-    // 分组
-    return result.reduce<{
-        groupId: number;
-        groupName: string;
-        marketId: number;
-        goodsList: Model.GoodsQuote[];
-    }[]>((pre, cur) => {
-        const existingGroup = pre.find((e) => e.groupId === cur.goodsgroupid)
-
-        if (existingGroup) {
-            existingGroup.goodsList.push(cur)
-        } else {
-            pre.push({
-                groupId: cur.goodsgroupid,
-                groupName: cur.goodsgroupname,
-                marketId: cur.marketid,
-                goodsList: [cur]
-            })
-        }
-
-        return pre
-    }, [])
-})
-
-// 构建游客参考行情商品
-const touristRefGoodsList = computed(() => {
-    const list = futuresStore.getGoodsListByTradeMode(99, 97)
-    return list.sort((a, b) => a.goodsorder.localeCompare(b.goodsorder))
-})
-
-const rowClick = (row: Model.GoodsQuote) => {
-    router.push({
-        name: 'market-detail',
-        query: {
-            goodscode: row.goodscode
-        }
-    })
-}
-
-// 游客商品点击
-const touristRowClick = (row: Model.GoodsQuote) => {
-    /// 不显示图标
-    if (system_1012 != '1') {
-        return
-    }
-    router.push({
-        name: 'market-chart',
-        query: {
-            goodscode: row.goodscode
-        }
-    })
-}
-
-if (loginStore.token) {
-    futuresStore.onDataCompleted(() => {
-        subscribeData.value = futuresStore.goodsList.map((e) => e.goodscode)
-        subscribe.start(...subscribeData.value)
-    })
-} else {
-    // 获取游客商品列表
-    queryTouristGoods({
-        data: {
-            trademodes: '52,99,97'
-        }
-    }).then((res) => {
-        if (res.data.length) {
-            futuresStore.goodsList = res.data
-            subscribeData.value = res.data.map((e) => e.goodscode)
-
-            // 获取游客商品盘面
-            queryTouristQuoteDay({
-                data: {
-                    goodsCodes: subscribeData.value.join(',')
-                }
-            }).then((res) => {
-                subscribeData.value.forEach((goodscode) => {
-                    const item = res.data.find((e) => e.goodscode === goodscode)
-                    futuresStore.updateQuotation(item ?? { goodscode })
-                })
-                subscribe.start(...subscribeData.value)
-            })
-        }
-    })
-}
-
-const { dataList: marketList, run: marketRun } = useRequest(queryMarketRun, {
-    manual: true,
-    onSuccess: () => {
-        // 每1分钟轮询刷新
-        timerTask.setTimeout(() => marketRun(), 60 * 1000, 'getMarketRun')
-    }
-})
-
-// 获取市场状态
-const getMarketStatus = (marketId: number) => {
-    const marketInfo = marketList.value.find((e) => e.marketid === marketId)
-    return marketInfo && [2, 6].includes(marketInfo.runstatus) ? getRunStatusName(marketInfo.runstatus) : '未开盘'
-}
-
-// 校验服务器时间
-const checkServerTime = () => {
-    getServerTime().then((res) => {
-        serverTime.value = moment(res.data)
-        // 每1分钟同步一次服务器时间
-        timerTask.setTimeout(() => {
-            checkServerTime()
-        }, 60 * 1000, 'getServerTime')
-    })
-}
-
-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()
-})
-
-onDeactivated(() => {
-    subscribe.stop()
-    clearTimer()
+import { useSetup } from './composables'
+
+const {
+    banners,
+    serverTime,
+    touristTradeGoodsList,
+    touristRefGoodsList,
+    getMarketStatus,
+    rowClick,
+    touristRowClick
+} = useSetup()
+
+const firstBanner = computed(() => {
+    const [firstItem] = banners.value
+    return firstItem ? `--header-bg:url(${getFileUrl(firstItem.imagepath)})` : ''
 })
 </script>
 

+ 1 - 1
src/packages/sjgj/router/index.ts

@@ -44,7 +44,7 @@ const routes: Array<RouteRecordRaw> = [
           {
             path: 'market',
             name: 'home-market',
-            component: () => import('../../sbyj/views/market/list/index.vue'),
+            component: () => import('../views/market/list/index.vue'),
             meta: {
               ignoreAuth: true,
             },

+ 61 - 0
src/packages/sjgj/views/market/list/index.less

@@ -0,0 +1,61 @@
+.market {
+    &-header {
+        .app-statusbar {
+            height: 147px;
+            background-image: var(--header-bg);
+            background-repeat: no-repeat;
+            background-position: center top;
+            background-size: 100% auto;
+        }
+    }
+
+    &-title {
+        color: #999;
+        padding: 12px;
+    }
+
+    &-table {
+        width: 100%;
+        text-align: center;
+        background-color: #fff;
+
+        th {
+            color: #999;
+            font-weight: normal;
+            padding: 8px 5px;
+
+            &.title {
+                color: #999;
+                background-color: #f6f6f6;
+                padding: 12px;
+
+                div {
+                    display: flex;
+                    justify-content: space-between;
+                }
+            }
+        }
+
+        tr {
+            &:last-child {
+                td {
+                    border-bottom: 1px solid #eee;
+                }
+            }
+
+            td {
+                border-top: 1px solid #eee;
+                border-right: 1px solid #eee;
+                padding: 6px;
+
+                &:last-child {
+                    border-right: 0;
+                }
+
+                span {
+                    display: block;
+                }
+            }
+        }
+    }
+}

+ 98 - 0
src/packages/sjgj/views/market/list/index.vue

@@ -0,0 +1,98 @@
+<template>
+    <app-view class="market">
+        <template #header>
+            <Banner :data-list="topBanners" />
+            <div class="market-title">
+                <span>
+                    {{ serverTime?.format('YYYY/MM/DD HH:mm:ss') }}
+                </span>
+            </div>
+        </template>
+        <table class="market-table" cellspacing="0" cellpadding="0">
+            <thead>
+                <tr>
+                    <th>商品</th>
+                    <th>回购</th>
+                    <th>销售</th>
+                    <th>高/低</th>
+                </tr>
+            </thead>
+            <template v-for="group in touristTradeGoodsList" :key="group.groupId">
+                <thead>
+                    <tr>
+                        <th class="title" colspan="4">
+                            <div>
+                                <span>{{ group.groupName }}</span>
+                                <span>{{ getMarketStatus(group.marketId) }}</span>
+                            </div>
+                        </th>
+                    </tr>
+                </thead>
+                <tbody>
+                    <tr v-for="(item, index) in group.goodsList" :key="index" @click="rowClick(item)">
+                        <td>{{ item.goodsname }}</td>
+                        <td :class="item.bidColor">
+                            {{ handleNumberValue(formatDecimal(item.bid, item.decimalplace)) }}
+                        </td>
+                        <td :class="item.askColor">
+                            {{ handleNumberValue(formatDecimal(item.ask, item.decimalplace)) }}
+                        </td>
+                        <td>
+                            <span :class="item.highestColor">
+                                {{ handleNumberValue(formatDecimal(item.highest, item.decimalplace)) }}
+                            </span>
+                            <span :class="item.lowestColor">
+                                {{ handleNumberValue(formatDecimal(item.lowest, item.decimalplace)) }}
+                            </span>
+                        </td>
+                    </tr>
+                </tbody>
+            </template>
+            <thead>
+                <tr>
+                    <th class="title" colspan="4">
+                        <div>参考商品</div>
+                    </th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr v-for="(item, index) in touristRefGoodsList" :key="index" @click="touristRowClick(item)">
+                    <td>{{ item.goodsname }}</td>
+                    <td :class="item.bidColor">{{ handleNumberValue(formatDecimal(item.bid, item.decimalplace)) }}</td>
+                    <td :class="item.askColor">{{ handleNumberValue(formatDecimal(item.ask, item.decimalplace)) }}</td>
+                    <td>
+                        <span :class="item.highestColor">
+                            {{ handleNumberValue(formatDecimal(item.highest, item.decimalplace)) }}
+                        </span>
+                        <span :class="item.lowestColor">
+                            {{ handleNumberValue(formatDecimal(item.lowest, item.decimalplace)) }}
+                        </span>
+                    </td>
+                </tr>
+            </tbody>
+        </table>
+    </app-view>
+</template>
+
+<script lang="ts" setup>
+import { computed } from 'vue'
+import { handleNumberValue, formatDecimal } from '@/filters'
+import { useSetup } from '../../../../sbyj/views/market/list/composables'
+import Banner from '@mobile/components/base/banner/index.vue'
+
+const {
+    banners,
+    serverTime,
+    touristTradeGoodsList,
+    touristRefGoodsList,
+    getMarketStatus,
+    rowClick,
+    touristRowClick
+} = useSetup()
+
+const topBanners = computed(() => banners.value.map((e) => e.imagepath))
+</script>
+
+<style lang="less">
+@import './index.less';
+</style>

+ 1 - 0
src/services/index.ts

@@ -110,6 +110,7 @@ export default new (class {
                     resolve(result)
                 })
             }).catch(() => {
+                this.isPending = false
                 reject('配置文件加载失败,请稍后再试')
             })
         })