Index.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <app-view class="goods-detail g-form">
  3. <template #header>
  4. <app-navbar :title="quote ? quote.goodscode + '/' + quote.goodsname : $t('quote.listinghall')" />
  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)">{{ $t('quote.buy') }}</Button>
  13. <Button block color="#199e00" square @click="onListing(BuyOrSell.Sell)">{{ $t('quote.selll') }}</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 { useFuturesStore } from '@/stores'
  22. import { useNavigation } from '@mobile/router/navigation'
  23. import { shallowRef, defineAsyncComponent } from 'vue'
  24. import { Button } from 'vant'
  25. import { BuyOrSell } from '@/constants/order'
  26. import { useComponent } from '@/hooks/component'
  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/hqchart/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. ['trade', defineAsyncComponent(() => import('./components/trade/Index.vue'))],
  39. ])
  40. const futuresStore = useFuturesStore()
  41. const { router, getQueryString, getQueryStringToNumber } = useNavigation()
  42. const goodsCode = getQueryString('goodscode') ?? ''
  43. const goodsid = getQueryStringToNumber('goodsid')
  44. const quote = futuresStore.getGoodsQuote(goodsCode)
  45. const buyOrSell = shallowRef<BuyOrSell>()
  46. const { componentRef, componentId, openComponent, closeComponent } = useComponent()
  47. const onListing = (type: BuyOrSell) => {
  48. buyOrSell.value = type
  49. openComponent('trade')
  50. }
  51. const onMoreClick = (buyorsell: BuyOrSell) => {
  52. router.push({
  53. name: 'goods-trade',
  54. query: {
  55. goodsid,
  56. buyorsell,
  57. }
  58. })
  59. }
  60. </script>
  61. <style lang="less">
  62. @import './index.less';
  63. </style>