|
|
@@ -3,7 +3,7 @@
|
|
|
<template #default="{ item }">
|
|
|
<div class="goods" @click="rowClick(item)">
|
|
|
<div class="goods-image">
|
|
|
- <img :src="getFileUrl(item.thumurls)" v-if="item.thumurls" />
|
|
|
+ <img :src="getFirstImage(item.thumurls)" v-if="item.thumurls" />
|
|
|
<Image width="100%" height="160px" v-else />
|
|
|
</div>
|
|
|
<div class="goods-info">
|
|
|
@@ -18,13 +18,15 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { PropType } from 'vue'
|
|
|
+import { PropType, ref, onActivated } from 'vue'
|
|
|
import { Image } from 'vant'
|
|
|
import { getFileUrl, handleNumberValue, formatDecimal } from '@/filters'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
import { BuyOrSell, BuildType, getGoodsCurrencyName } from '@/constants/order'
|
|
|
+import { queryTouristGoods, queryTouristQuoteDay } from '@/services/api/goods'
|
|
|
+import { useLoginStore, useFuturesStore } from '@/stores'
|
|
|
import Waterfall from '@mobile/components/base/waterfall/index.vue'
|
|
|
-import { useFuturesStore } from '@/stores'
|
|
|
+import _ from 'lodash'
|
|
|
|
|
|
defineProps({
|
|
|
dataList: {
|
|
|
@@ -34,17 +36,25 @@ defineProps({
|
|
|
})
|
|
|
|
|
|
const { router } = useNavigation()
|
|
|
-const futureStore = useFuturesStore()
|
|
|
+const loginStore = useLoginStore()
|
|
|
+const futuresStore = useFuturesStore()
|
|
|
+const quotationList = ref<Model.GoodsQuote[]>([])
|
|
|
+
|
|
|
+// 获取商品首图
|
|
|
+const getFirstImage = (thumurls?: string) => {
|
|
|
+ const firstImage = thumurls ? thumurls.split(',')[0] : ''
|
|
|
+ return getFileUrl(firstImage)
|
|
|
+}
|
|
|
|
|
|
// 获取商品价格
|
|
|
const getPrice = (item: Model.TCEGoodsCollectionRsp) => {
|
|
|
- const { ask = 0, currencyid = 0, decimalplace } = futureStore.getGoodsQuote(item.defaultgoodsid).value ?? {}
|
|
|
+ const { ask = 0, currencyid = 0, decimalplace } = quotationList.value.find((e) => e.goodsid === item.defaultgoodsid) ?? {}
|
|
|
return ask ? getGoodsCurrencyName(currencyid) + formatDecimal(ask, decimalplace) : handleNumberValue()
|
|
|
}
|
|
|
|
|
|
// 获取价格颜色
|
|
|
const getColor = (item: Model.TCEGoodsCollectionRsp) => {
|
|
|
- const { askColor = '' } = futureStore.getGoodsQuote(item.defaultgoodsid).value ?? {}
|
|
|
+ const { askColor = '' } = quotationList.value.find((e) => e.goodsid === item.defaultgoodsid) ?? {}
|
|
|
return askColor
|
|
|
}
|
|
|
|
|
|
@@ -58,4 +68,38 @@ const rowClick = (row: Model.TCEGoodsCollectionRsp) => {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+onActivated(() => {
|
|
|
+ if (loginStore.token) {
|
|
|
+ futuresStore.onDataCompleted(() => {
|
|
|
+ quotationList.value = _.cloneDeep(futuresStore.quotationList)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 获取游客商品列表
|
|
|
+ queryTouristGoods({
|
|
|
+ data: {
|
|
|
+ trademodes: '10,53'
|
|
|
+ }
|
|
|
+ }).then((res) => {
|
|
|
+ if (res.data.length) {
|
|
|
+ futuresStore.goodsList = res.data
|
|
|
+ const goodsCodes = res.data.map((e) => e.goodscode)
|
|
|
+
|
|
|
+ // 获取游客商品盘面
|
|
|
+ queryTouristQuoteDay({
|
|
|
+ data: {
|
|
|
+ goodsCodes: goodsCodes.join(',')
|
|
|
+ }
|
|
|
+ }).then((res) => {
|
|
|
+ goodsCodes.forEach((goodscode) => {
|
|
|
+ const item = res.data.find((e) => e.goodscode === goodscode)
|
|
|
+ futuresStore.updateQuotation(item ?? { goodscode })
|
|
|
+ })
|
|
|
+
|
|
|
+ quotationList.value = _.cloneDeep(futuresStore.quotationList)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|