|
@@ -1,16 +1,28 @@
|
|
|
<template>
|
|
<template>
|
|
|
<app-view class="goods-detail g-form">
|
|
<app-view class="goods-detail g-form">
|
|
|
<template #header>
|
|
<template #header>
|
|
|
- <app-navbar :title="quote ? quote.goodscode + '/' + quote.goodsname : '挂牌大厅'" :show-back-button="false" />
|
|
|
|
|
|
|
+ <app-navbar :show-back-button="showBackButton">
|
|
|
|
|
+ <div class="goods-detail__titlebar">
|
|
|
|
|
+ <Icon class="prev" name="play" :disabled="selectedIndex <= 0" @click="onPrev" />
|
|
|
|
|
+ <span class="text">
|
|
|
|
|
+ {{ selectedItem ? selectedItem.goodscode + '/' + selectedItem.goodsname : '交易' }}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ <Icon class="next" name="play" :disabled="selectedIndex >= (goodsList.length - 1)" @click="onNext" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </app-navbar>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-if="!loading">
|
|
|
|
|
+ <component :is="Price" v-bind="{ goodsCode }" />
|
|
|
|
|
+ <component :is="Chart" v-bind="{ goodsCode }" @ready="loading = true" />
|
|
|
|
|
+ <component :is="Forex" v-bind="{ goodsCode }" @more-click="onMoreClick" />
|
|
|
|
|
+ <component :is="Tik" v-bind="{ goodsCode }" />
|
|
|
</template>
|
|
</template>
|
|
|
- <component :is="Price" v-bind="{ goodsCode }" />
|
|
|
|
|
- <component :is="Chart" v-bind="{ goodsCode }" />
|
|
|
|
|
- <component :is="Forex" v-bind="{ goodsCode }" @more-click="onMoreClick" />
|
|
|
|
|
- <component :is="Tik" v-bind="{ goodsCode }" />
|
|
|
|
|
<template #footer>
|
|
<template #footer>
|
|
|
<div class="g-form__footer">
|
|
<div class="g-form__footer">
|
|
|
- <Button block type="danger" square @click="onListing(BuyOrSell.Buy)">买入</Button>
|
|
|
|
|
- <Button block type="primary" square @click="onListing(BuyOrSell.Sell)">卖出</Button>
|
|
|
|
|
|
|
+ <Button type="danger" :disabled="selectedIndex < 0" @click="onListing(BuyOrSell.Buy)" square
|
|
|
|
|
+ block>买入</Button>
|
|
|
|
|
+ <Button type="primary" :disabled="selectedIndex < 0" @click="onListing(BuyOrSell.Sell)" square
|
|
|
|
|
+ block>卖出</Button>
|
|
|
</div>
|
|
</div>
|
|
|
<component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ goodsCode, buyOrSell }"
|
|
<component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ goodsCode, buyOrSell }"
|
|
|
@closed="closeComponent" v-if="componentId" />
|
|
@closed="closeComponent" v-if="componentId" />
|
|
@@ -19,8 +31,8 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, defineAsyncComponent, computed } from 'vue'
|
|
|
|
|
-import { Button } from 'vant'
|
|
|
|
|
|
|
+import { shallowRef, defineAsyncComponent, computed, onMounted } from 'vue'
|
|
|
|
|
+import { Button, Icon } from 'vant'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
import { useComponent } from '@/hooks/component'
|
|
import { useComponent } from '@/hooks/component'
|
|
|
import { BuyOrSell } from '@/constants/order'
|
|
import { BuyOrSell } from '@/constants/order'
|
|
@@ -35,13 +47,22 @@ const componentMap = new Map<string, unknown>([
|
|
|
['listing', defineAsyncComponent(() => import('@mobile/views/goods/detail/components/listing/Index.vue'))],
|
|
['listing', defineAsyncComponent(() => import('@mobile/views/goods/detail/components/listing/Index.vue'))],
|
|
|
])
|
|
])
|
|
|
|
|
|
|
|
|
|
+defineProps({
|
|
|
|
|
+ showBackButton: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: true
|
|
|
|
|
+ },
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
const { router, getQueryStringToNumber } = useNavigation()
|
|
const { router, getQueryStringToNumber } = useNavigation()
|
|
|
const futuresStore = useFuturesStore()
|
|
const futuresStore = useFuturesStore()
|
|
|
-const goodsid = getQueryStringToNumber('goodsid')
|
|
|
|
|
-const quote = futuresStore.getGoodsQuote(goodsid)
|
|
|
|
|
|
|
+const selectedIndex = shallowRef(-1)
|
|
|
const buyOrSell = shallowRef<BuyOrSell>()
|
|
const buyOrSell = shallowRef<BuyOrSell>()
|
|
|
|
|
+const loading = shallowRef(false)
|
|
|
|
|
|
|
|
-const goodsCode = computed(() => quote.value?.goodscode ?? '')
|
|
|
|
|
|
|
+const goodsList = computed(() => futuresStore.getGoodsListByTradeMode(50))
|
|
|
|
|
+const selectedItem = computed(() => goodsList.value[selectedIndex.value])
|
|
|
|
|
+const goodsCode = computed(() => selectedItem.value?.goodscode ?? '')
|
|
|
|
|
|
|
|
const { componentRef, componentId, openComponent, closeComponent } = useComponent()
|
|
const { componentRef, componentId, openComponent, closeComponent } = useComponent()
|
|
|
|
|
|
|
@@ -50,13 +71,48 @@ const onListing = (type: BuyOrSell) => {
|
|
|
openComponent('listing')
|
|
openComponent('listing')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 上一个
|
|
|
|
|
+const onPrev = () => {
|
|
|
|
|
+ if (!loading.value && selectedIndex.value) {
|
|
|
|
|
+ loading.value = true
|
|
|
|
|
+ selectedIndex.value -= 1
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ }, 0)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 下一个
|
|
|
|
|
+const onNext = () => {
|
|
|
|
|
+ if (!loading.value && selectedIndex.value < (goodsList.value.length - 1)) {
|
|
|
|
|
+ loading.value = true
|
|
|
|
|
+ selectedIndex.value += 1
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ }, 0)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const onMoreClick = (buyorsell: BuyOrSell) => {
|
|
const onMoreClick = (buyorsell: BuyOrSell) => {
|
|
|
router.push({
|
|
router.push({
|
|
|
name: 'goods-trade',
|
|
name: 'goods-trade',
|
|
|
query: {
|
|
query: {
|
|
|
- goodsid,
|
|
|
|
|
|
|
+ goodsid: selectedItem.value?.goodsid,
|
|
|
buyorsell,
|
|
buyorsell,
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
-</script>
|
|
|
|
|
|
|
+
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ const goodsid = getQueryStringToNumber('goodsid')
|
|
|
|
|
+ if (goodsid) {
|
|
|
|
|
+ selectedIndex.value = goodsList.value.findIndex((e) => e.goodsid === goodsid)
|
|
|
|
|
+ } else if (goodsList.value.length) {
|
|
|
|
|
+ selectedIndex.value = 0
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="less">
|
|
|
|
|
+@import './index.less';
|
|
|
|
|
+</style>
|