|
|
@@ -1,148 +1,78 @@
|
|
|
<template>
|
|
|
- <app-view class="home-main">
|
|
|
- <Banner :data-list="topBanners" />
|
|
|
- <PullRefresh class="home-main__container" v-model="refreshing" @refresh="onRefresh">
|
|
|
- <app-block>
|
|
|
- <Cell :value="$t('common.more')" :to="{ name: 'notice-list' }" icon="volume" is-link>
|
|
|
- <template #title>
|
|
|
- <Badge :offset="[10, 8]" :dot="noticeStore.unreadCount > 0">{{ $t('routes.notice') }}</Badge>
|
|
|
- </template>
|
|
|
- </Cell>
|
|
|
- </app-block>
|
|
|
- <app-block class="home-main__news">
|
|
|
- <CellGroup class="article">
|
|
|
- <Cell class="home-main__titlebar" :title="$t('routes.news')" :value="$t('common.more')" icon="fire"
|
|
|
- :to="{ name: 'news-list' }" is-link />
|
|
|
- <template v-for="(item, index) in newsList" :key="index">
|
|
|
- <Cell class="article-item" :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
|
|
|
- :to="{ name: 'news-detail', query: { id: item.id } }" />
|
|
|
- </template>
|
|
|
- </CellGroup>
|
|
|
- </app-block>
|
|
|
- </PullRefresh>
|
|
|
- </app-view>
|
|
|
+ <div class="home-main">
|
|
|
+ <app-wallet-total v-if="loginStore.token" />
|
|
|
+ <app-grid :items="gridItems" />
|
|
|
+ <app-block class="home-main-hot">
|
|
|
+ <h4>热门货币</h4>
|
|
|
+ <section>
|
|
|
+ <template v-for="(item, index) in goodsList" :key="index">
|
|
|
+ <ul v-if="index < 3">
|
|
|
+ <li>
|
|
|
+ <Tag>{{ index + 1 }}</Tag>
|
|
|
+ <span>{{ item.goodsid }}/{{ item.goodsname }}</span>
|
|
|
+ </li>
|
|
|
+ <li :class="item.lastColor">{{ parsePercent(item.change) }}</li>
|
|
|
+ <li :class="item.lastColor">{{ item.last.toFixed(item.decimalplace) }}</li>
|
|
|
+ </ul>
|
|
|
+ </template>
|
|
|
+ </section>
|
|
|
+ </app-block>
|
|
|
+ <app-article title="新闻资讯" />
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, computed } from 'vue'
|
|
|
-import { Cell, CellGroup, PullRefresh, Badge } from 'vant'
|
|
|
-import { displayname, formatDate } from "@/filters"
|
|
|
-import { queryImageConfigs } from "@/services/api/common"
|
|
|
-import { queryNewTitles } from "@/services/api/news"
|
|
|
-import { useMarketSection } from '@/business/market'
|
|
|
-import { useNoticeStore, useGlobalStore } from '@/stores'
|
|
|
-import Banner from '@mobile/components/base/banner/index.vue'
|
|
|
+import { computed } from 'vue'
|
|
|
+import { Tag } from 'vant'
|
|
|
+import { parsePercent } from '@/filters'
|
|
|
+import { useRequest } from '@/hooks/request'
|
|
|
+import { getHotGoodses } from '@/services/api/goods'
|
|
|
+import { useLoginStore, useFuturesStore, i18n } from '@/stores'
|
|
|
+import { GridItem } from '@/packages/digital/components/grid/types'
|
|
|
+import quoteSocket from '@/services/websocket/quote'
|
|
|
+import AppArticle from '@mobile/components/modules/article/index.vue'
|
|
|
+import AppWalletTotal from '@/packages/digital/components/wallet-total/index.vue'
|
|
|
+import AppGrid from '@/packages/digital/components/grid/index.vue'
|
|
|
|
|
|
-// const globalStore = useGlobalStore()
|
|
|
-const noticeStore = useNoticeStore()
|
|
|
-const globalStore = useGlobalStore()
|
|
|
-const refreshing = shallowRef(false) // 是否处于加载中状态
|
|
|
-const topBanners = shallowRef<string[]>([]); // 轮播图列表
|
|
|
-const newsList = shallowRef<Model.NewTitlesRsp[]>([]) // 资讯列表
|
|
|
+const { t } = i18n.global
|
|
|
+const loginStore = useLoginStore()
|
|
|
+const futuresStore = useFuturesStore()
|
|
|
+const subscribe = quoteSocket.createSubscribe()
|
|
|
|
|
|
-// 跳转导航页面
|
|
|
-// const switchTab = (routeName: string) => {
|
|
|
-// if (loginStore.token) {
|
|
|
-// routerTo(routeName, true)
|
|
|
-// } else {
|
|
|
-// routerTo('user-login')
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// 获取市场板块
|
|
|
-const { allMarket } = useMarketSection()
|
|
|
-
|
|
|
-const iconbar = computed(() => allMarket.value.reduce<{
|
|
|
- name: string;
|
|
|
- label: string;
|
|
|
- icon: string;
|
|
|
- markets?: string;
|
|
|
-}[][]>((pre, cur, index) => {
|
|
|
- if (index > 2) {
|
|
|
- const item = {
|
|
|
- name: '',
|
|
|
- label: displayname(cur),
|
|
|
- icon: '',
|
|
|
- markets: cur.marketids
|
|
|
- }
|
|
|
- switch (cur.trademode) {
|
|
|
- case 10:
|
|
|
- item.name = 'pricing-list'
|
|
|
- item.icon = 'g-icon-pricing--line'
|
|
|
- break
|
|
|
- case 17:
|
|
|
- item.name = 'spot-list'
|
|
|
- item.icon = 'g-icon-spot--line'
|
|
|
- break
|
|
|
- case 46:
|
|
|
- item.name = 'swap-list'
|
|
|
- item.icon = 'g-icon-swap--line'
|
|
|
- break
|
|
|
- case 48:
|
|
|
- item.name = 'presale-list'
|
|
|
- item.icon = 'g-icon-auction--line'
|
|
|
- break
|
|
|
- case 49:
|
|
|
- item.name = 'transfer-list'
|
|
|
- item.icon = 'g-icon-transfer--line'
|
|
|
- break
|
|
|
- case 16:
|
|
|
- case 50:
|
|
|
- item.name = 'goods-list'
|
|
|
- item.icon = 'g-icon-listing--line'
|
|
|
- break
|
|
|
- case 51:
|
|
|
- item.name = 'ballot-list'
|
|
|
- item.icon = 'g-icon-presale--line'
|
|
|
- break
|
|
|
- case 53:
|
|
|
- item.name = 'mall-list'
|
|
|
- item.icon = 'g-icon-quote--line'
|
|
|
- break
|
|
|
- case 54:
|
|
|
- item.name = 'score-list'
|
|
|
- item.icon = 'g-icon-quote--line'
|
|
|
- break
|
|
|
- case 99:
|
|
|
- item.name = 'market-list'
|
|
|
- item.icon = 'g-icon-quote--line'
|
|
|
- break
|
|
|
- }
|
|
|
- const i = pre.length - 1
|
|
|
- if (i < 0 || pre[i].length > 3) {
|
|
|
- pre.push([item])
|
|
|
- } else {
|
|
|
- pre[i].push(item)
|
|
|
- }
|
|
|
+const gridItems = computed<GridItem[]>(() => ([
|
|
|
+ {
|
|
|
+ text: t('digital.wallet-deposit'),
|
|
|
+ icon: './img/icons/deposit.svg',
|
|
|
+ to: { name: 'wallet-deposit-currency' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: t('digital.wallet-withdraw'),
|
|
|
+ icon: './img/icons/withdraw.svg',
|
|
|
+ to: { name: 'wallet-withdraw-currency' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: t('digital.wallet-transfer'),
|
|
|
+ icon: './img/icons/transfer.svg',
|
|
|
+ to: { name: 'wallet-transfer' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: t('digital.setting'),
|
|
|
+ icon: './img/icons/setting.svg',
|
|
|
+ to: { name: 'setting' }
|
|
|
}
|
|
|
- return pre
|
|
|
-}, []))
|
|
|
+]))
|
|
|
|
|
|
-// 下拉刷新
|
|
|
-const onRefresh = () => {
|
|
|
- if (!topBanners.value.length) {
|
|
|
- queryImageConfigs({
|
|
|
- data: {
|
|
|
- imageType: 1,
|
|
|
- }
|
|
|
- }).then((res) => {
|
|
|
- topBanners.value = res.data.map((e) => e.imagepath)
|
|
|
- })
|
|
|
- }
|
|
|
- // 市场资讯
|
|
|
- queryNewTitles({
|
|
|
- data: {
|
|
|
- page: 1,
|
|
|
- pagesize: 10,
|
|
|
+const { dataList } = useRequest(getHotGoodses, {
|
|
|
+ onSuccess: (res) => {
|
|
|
+ if (!loginStore.token) {
|
|
|
+ futuresStore.goodsList = res.data
|
|
|
+ futuresStore.getQuoteDay()
|
|
|
}
|
|
|
- }).then((res) => {
|
|
|
- newsList.value = res.data
|
|
|
- }).finally(() => {
|
|
|
- refreshing.value = false
|
|
|
- })
|
|
|
-}
|
|
|
+ subscribe.start(...res.data.map((e) => e.goodscode))
|
|
|
+ }
|
|
|
+})
|
|
|
|
|
|
-onRefresh()
|
|
|
+const goodsList = computed(() => futuresStore.quotationList.filter((q) => dataList.value.some((e) => e.goodsid === q.goodsid)))
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|