Index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <app-view class="home-main">
  3. <template #header>
  4. <app-navbar :title="globalStore.appName" :show-back-button="false" />
  5. </template>
  6. <Banner :data-list="topBanners" />
  7. <PullRefresh class="home-main__container" v-model="refreshing" @refresh="onRefresh">
  8. <app-block>
  9. <Cell title="通知公告" value="更多" :to="{ name: 'notice-list' }" icon="volume" is-link />
  10. </app-block>
  11. <app-block class="home-main__iconbar bg">
  12. <ul>
  13. <li @click="routerTo('presale-list')">
  14. <Iconfont label-direction="bottom" icon="icon-yushoujingpai">预售竞拍</Iconfont>
  15. </li>
  16. <li @click="routerTo('forward-list')">
  17. <Iconfont label-direction="bottom" icon="icon-dingjinzhuanrang">中远期挂牌</Iconfont>
  18. </li>
  19. <li @click="routerTo('fullpayment-list')">
  20. <Iconfont label-direction="bottom" icon="icon-a-zu771">全款挂牌</Iconfont>
  21. </li>
  22. <!-- <li @click="switchTab(1)">
  23. <Iconfont label-direction="bottom" icon="icon-zhongqian">预售中签</Iconfont>
  24. </li> -->
  25. <!-- <li @click="switchTab(2)">
  26. <Iconfont label-direction="bottom" icon="icon-dingjinzhuanrang">定金转让</Iconfont>
  27. </li> -->
  28. <li @click="routerTo('swap-list')">
  29. <Iconfont label-direction="bottom" icon="icon-diaoqimaoyi">掉期贸易</Iconfont>
  30. </li>
  31. </ul>
  32. <ul>
  33. <!-- <li @click="switchTab(3)">
  34. <Iconfont label-direction="bottom" icon="icon-a-zu771">订单挂牌</Iconfont>
  35. </li> -->
  36. <li @click="routerTo('pricing-list')">
  37. <Iconfont label-direction="bottom" icon="icon-guapaidianjia">挂牌点价</Iconfont>
  38. </li>
  39. <li @click="routerTo('spot-list')">
  40. <Iconfont label-direction="bottom" icon="icon-xianhuomaoyi">现货贸易</Iconfont>
  41. </li>
  42. <li @click="routerTo('market-list')">
  43. <Iconfont label-direction="bottom" icon="icon-cankaohangqing">参考行情</Iconfont>
  44. </li>
  45. </ul>
  46. </app-block>
  47. <app-block class="home-main__news">
  48. <CellGroup class="article">
  49. <Cell class="home-main__titlebar" value="更多" :to="{ name: 'news-list' }" is-link>
  50. <template #title>
  51. <img src="../../../assets/icons/fire.png" />
  52. <span>市场资讯</span>
  53. </template>
  54. </Cell>
  55. <template v-for="(item, index) in newsList" :key="index">
  56. <Cell class="article-item" :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
  57. :to="{ name: 'news-detail', query: { id: item.id } }" />
  58. </template>
  59. </CellGroup>
  60. </app-block>
  61. </PullRefresh>
  62. </app-view>
  63. </template>
  64. <script lang="ts" setup>
  65. import { shallowRef } from "vue";
  66. import { Cell, CellGroup, PullRefresh } from "vant";
  67. import { formatDate } from "@/filters";
  68. import { useNavigation } from '@mobile/router/navigation';
  69. import { queryImageConfigs } from "@/services/api/common";
  70. import { queryNewTitles } from "@/services/api/news";
  71. import { useLoginStore, useGlobalStore } from '@/stores'
  72. import Banner from '@mobile/components/base/banner/index.vue'
  73. import Iconfont from '@mobile/components/base/iconfont/index.vue'
  74. const globalStore = useGlobalStore()
  75. const loginStore = useLoginStore();
  76. const { routerTo, setGlobalUrlParams } = useNavigation();
  77. const refreshing = shallowRef(false); // 是否处于加载中状态
  78. const topBanners = shallowRef<string[]>([]); // 轮播图列表
  79. const newsList = shallowRef<Model.NewTitlesRsp[]>([]); // 资讯列表
  80. // 跳转导航页面
  81. const switchTab = (tabIndex: number) => {
  82. if (loginStore.token) {
  83. setGlobalUrlParams({ tabIndex })
  84. switch (tabIndex) {
  85. case 1:
  86. routerTo('home-ballot', true)
  87. break
  88. case 2:
  89. routerTo('home-transfer', true)
  90. break
  91. case 3:
  92. routerTo('home-goods', true)
  93. break
  94. }
  95. } else {
  96. routerTo('user-login')
  97. }
  98. }
  99. // 下拉刷新
  100. const onRefresh = () => {
  101. if (!topBanners.value.length) {
  102. queryImageConfigs({
  103. data: {
  104. imageType: 1,
  105. }
  106. }).then((res) => {
  107. topBanners.value = res.data.map((e) => e.imagepath)
  108. })
  109. }
  110. // 市场资讯
  111. queryNewTitles({
  112. data: {
  113. page: 1,
  114. pagesize: 10,
  115. }
  116. }).then((res) => {
  117. newsList.value = res.data
  118. }).finally(() => {
  119. refreshing.value = false
  120. })
  121. }
  122. onRefresh()
  123. </script>
  124. <style lang="less">
  125. @import "./index.less";
  126. </style>