Index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <app-view class="goods-detail g-form">
  3. <template #header>
  4. <app-navbar :title="quote ? quote.goodscode + '/' + quote.goodsname : '挂牌大厅'" />
  5. </template>
  6. <component :is="Price" v-bind="{ goodsCode }" />
  7. <component :is="Chart" v-bind="{ goodsCode }" />
  8. <component :is="Forex" v-bind="{ goodsCode }" :show-more="showMore" @more-click="onMoreClick" />
  9. <component :is="Tik" v-bind="{ goodsCode }" />
  10. <template #footer>
  11. <div class="g-form__footer">
  12. <Button block type="danger" square @click="onListing(BuyOrSell.Buy)">买入</Button>
  13. <Button block type="primary" square @click="onListing(BuyOrSell.Sell)">卖出</Button>
  14. </div>
  15. <component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ goodsCode, buyOrSell }"
  16. @closed="closeComponent" v-if="componentId" />
  17. </template>
  18. </app-view>
  19. </template>
  20. <script lang="ts" setup>
  21. import { shallowRef, defineAsyncComponent, computed } from 'vue'
  22. import { Button } from 'vant'
  23. import { useNavigation } from '@mobile/router/navigation'
  24. import { useComponent } from '@/hooks/component'
  25. import { BuyOrSell } from '@/constants/order'
  26. import { useFuturesStore } from '@/stores'
  27. defineProps({
  28. showMore: {
  29. type: Boolean,
  30. default: true
  31. }
  32. })
  33. const Price = defineAsyncComponent(() => import('@mobile/components/modules/quote/price/index.vue'))
  34. const Chart = defineAsyncComponent(() => import('@mobile/components/modules/quote/chart/index.vue'))
  35. const Forex = defineAsyncComponent(() => import('@mobile/components/modules/quote/forex/index.vue'))
  36. const Tik = defineAsyncComponent(() => import('@mobile/components/modules/quote/tik/index.vue'))
  37. const componentMap = new Map<string, unknown>([
  38. ['listing', defineAsyncComponent(() => import('./components/listing/Index.vue'))],
  39. ])
  40. const { router, getQueryStringToNumber } = useNavigation()
  41. const futuresStore = useFuturesStore()
  42. const goodsid = getQueryStringToNumber('goodsid')
  43. const quote = futuresStore.getGoodsQuote(goodsid)
  44. const buyOrSell = shallowRef<BuyOrSell>()
  45. const goodsCode = computed(() => quote.value?.goodscode ?? '')
  46. const { componentRef, componentId, openComponent, closeComponent } = useComponent()
  47. const onListing = (type: BuyOrSell) => {
  48. buyOrSell.value = type
  49. openComponent('listing')
  50. }
  51. const onMoreClick = (buyorsell: BuyOrSell) => {
  52. router.push({
  53. name: 'goods-trade',
  54. query: {
  55. goodsid,
  56. buyorsell,
  57. }
  58. })
  59. }
  60. </script>