Index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <app-view class="home-main">
  3. <template #header>
  4. <app-navbar title="多元世纪" :show-back-button="false" />
  5. </template>
  6. <div class="home-main__banner">
  7. <Swipe :autoplay="5000" indicator-color="white" lazy-render>
  8. <SwipeItem v-for="(item, index) in topBanners" :key="index">
  9. <img :src="getFileUrl(item.imagepath)" />
  10. </SwipeItem>
  11. </Swipe>
  12. </div>
  13. <PullRefresh class="home-main__container" v-model="refreshing" @refresh="onRefresh">
  14. <app-block>
  15. <Cell title="通知公告" value="更多" :to="{ name: 'notice-list' }" icon="volume" is-link />
  16. </app-block>
  17. <app-block class="home-main__iconbar bg">
  18. <ul>
  19. <li @click="switchTab(1)">
  20. <img src="@mobile/assets/icons/cpjs.svg" />
  21. <span>预售竞拍</span>
  22. </li>
  23. <li @click="routerTo('ballot-list')">
  24. <img src="@mobile/assets/icons/cpjs.svg" />
  25. <span>预售中签</span>
  26. </li>
  27. <li @click="switchTab(2)">
  28. <img src="@mobile/assets/icons/cpjg.svg" />
  29. <span>定金转让</span>
  30. </li>
  31. <li @click="routerTo('swap-list')">
  32. <img src="@mobile/assets/icons/ptgz.svg" />
  33. <span>掉期贸易</span>
  34. </li>
  35. </ul>
  36. <ul>
  37. <li @click="switchTab(3)">
  38. <img src="@mobile/assets/icons/wdrw.svg" />
  39. <span>订单挂牌</span>
  40. </li>
  41. <li @click="routerTo('pricing-list')">
  42. <img src="@mobile/assets/icons/ccwl.svg" />
  43. <span>挂牌点价</span>
  44. </li>
  45. <li @click="routerTo('spot-list')">
  46. <img src="@mobile/assets/icons/htzr.svg" />
  47. <span>现货贸易</span>
  48. </li>
  49. <li @click="routerTo('market-list')">
  50. <img src="@mobile/assets/icons/ccwl.svg" />
  51. <span>参考行情</span>
  52. </li>
  53. </ul>
  54. </app-block>
  55. <app-block class="home-main__market" v-if="spotQuoteList.length">
  56. <Cell class="home-main__titlebar" value="更多" :to="{ name: 'MarketSpot' }" is-link>
  57. <template #title>
  58. <img src="@mobile/assets/icons/spot.png" />
  59. <span>现货行情</span>
  60. <span>({{ currentSpotQuote.spotmonth }})</span>
  61. </template>
  62. </Cell>
  63. <section class="scrollbar">
  64. <Swipe :autoplay="8000" :show-indicators="false" :touchable="false" vertical @change="onSpotChange">
  65. <SwipeItem v-for="(item, i) in spotQuoteList" :key="i">
  66. <ul @click="openNewsDetails(item.relatedid)">
  67. <li>
  68. <span>{{ item.spotsrc }}</span>
  69. </li>
  70. <li>
  71. <span>{{ item.spotname }}招标价 </span>
  72. <span class="g-color--up">{{ item.spotprice }} 元/吨</span>
  73. </li>
  74. <li>
  75. <span>采购量 </span>
  76. <span class="g-color--up">{{ item.spotqty }} 吨</span>
  77. </li>
  78. </ul>
  79. </SwipeItem>
  80. </Swipe>
  81. </section>
  82. </app-block>
  83. <app-block v-if="false">
  84. <section class="scrollbar">
  85. <h4 class="scrollbar-title">
  86. <img src="@mobile/assets/icons/futures.png" />
  87. <span>期货行情</span>
  88. </h4>
  89. <Swipe :autoplay="8000" :show-indicators="false" :touchable="false" vertical>
  90. <SwipeItem
  91. v-for="({ goodsname, last, lasttime, presettle, change, amplitude, holdvolume, lastvolume, decimalplace }, i) in dataList"
  92. :key="i">
  93. <ul>
  94. <li>{{ goodsname }}</li>
  95. <li style="color:#999">{{ formatDate(lasttime, 'HH:mm') }}</li>
  96. <li :class="handlePriceColor(last, presettle)">{{ handleNumberValue(formatDecimal(last, decimalplace))
  97. }}
  98. </li>
  99. <li :class="handlePriceColor(last, presettle)">{{ handleNumberValue(formatDecimal(change, decimalplace))
  100. }}</li>
  101. <li :class="handlePriceColor(last, presettle)">{{ parsePercent(amplitude) }}</li>
  102. <li :class="handlePriceColor(last, presettle)">{{ changeUnit(lastvolume) }}</li>
  103. <li :class="handlePriceColor(last, presettle)">{{ changeUnit(holdvolume) }}</li>
  104. </ul>
  105. </SwipeItem>
  106. </Swipe>
  107. </section>
  108. </app-block>
  109. <app-block class="home-main__banner home-main__banner--body" v-if="false">
  110. <Swipe :autoplay="5000" indicator-color="white" lazy-render>
  111. <SwipeItem v-for="(item, index) in bodyBanners" :key="index">
  112. <img :src="getFileUrl(item.imagepath)" />
  113. </SwipeItem>
  114. </Swipe>
  115. </app-block>
  116. <app-block class="home-main__news">
  117. <CellGroup class="article">
  118. <Cell class="home-main__titlebar" value="更多" :to="{ name: 'news-list' }" is-link>
  119. <template #title>
  120. <img src="@mobile/assets/icons/fire.png" />
  121. <span>市场资讯</span>
  122. </template>
  123. </Cell>
  124. <template v-for="(item, index) in newsList" :key="index">
  125. <Cell class="article-item" :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
  126. :to="{ name: 'news-detail', query: { id: item.id } }" />
  127. </template>
  128. </CellGroup>
  129. </app-block>
  130. </PullRefresh>
  131. </app-view>
  132. </template>
  133. <script lang="ts" setup>
  134. import { shallowRef, computed } from "vue";
  135. import { Cell, CellGroup, Swipe, SwipeItem, PullRefresh } from "vant";
  136. import { formatDecimal, getFileUrl, formatDate, handlePriceColor, parsePercent, handleNumberValue, changeUnit } from "@/filters";
  137. import { useNavigation } from "@/hooks/navigation";
  138. import { queryImageConfigs } from "@/services/api/common";
  139. import { queryNewTitles } from "@/services/api/news";
  140. import { useFuturesList } from "@/business/market";
  141. import { queryMarketRun } from "@/services/api/goods";
  142. import { queryThjSpotQuoteConfig } from "@/services/api/market";
  143. import { useLoginStore } from '@/stores'
  144. const loginStore = useLoginStore();
  145. const { router, routerTo, setGlobalUrlParams } = useNavigation();
  146. const { dataList } = useFuturesList();
  147. const refreshing = shallowRef(false); // 是否处于加载中状态
  148. const topBanners = shallowRef<Model.ImageConfigsRsp[]>([]); // 轮播图列表
  149. const bodyBanners = shallowRef<Model.ImageConfigsRsp[]>([]); // 轮播图列表
  150. const newsList = shallowRef<Model.NewTitlesRsp[]>([]); // 资讯列表
  151. const spotQuoteList = shallowRef<Model.ThjSpotQuoteConfigRsp[]>([]); // 现货行情
  152. const spotQuoteIndex = shallowRef(0) // 当前现货行情索引
  153. const marketRun = shallowRef<Partial<Model.MarketRunRsp>>({}); // 市场
  154. // 当前现货行情
  155. const currentSpotQuote = computed(() => spotQuoteList.value[spotQuoteIndex.value])
  156. // 跳转导航页面
  157. const switchTab = (tabIndex: number) => {
  158. if (loginStore.token) {
  159. setGlobalUrlParams({ tabIndex })
  160. switch (tabIndex) {
  161. case 1:
  162. routerTo('home-presale', true)
  163. break
  164. case 2:
  165. routerTo('home-transfer', true)
  166. break
  167. case 3:
  168. routerTo('home-goods', true)
  169. break
  170. }
  171. } else {
  172. routerTo('user-login')
  173. }
  174. }
  175. // 打开新闻详情
  176. const openNewsDetails = (id: number) => {
  177. if (id) {
  178. router.push({ name: 'news-detail', query: { id } })
  179. }
  180. }
  181. // 现货行情轮播变化
  182. const onSpotChange = (index: number) => {
  183. spotQuoteIndex.value = index
  184. }
  185. // 下拉刷新
  186. const onRefresh = () => {
  187. if (!topBanners.value.length) {
  188. queryImageConfigs({
  189. data: {
  190. imageType: 1,
  191. }
  192. }).then((res) => {
  193. topBanners.value = res.data
  194. })
  195. }
  196. // if (!bodyBanners.value.length) {
  197. // queryImageConfigs({
  198. // imageType: 10,
  199. // }).then((res) => {
  200. // bodyBanners.value = res.data
  201. // })
  202. // }
  203. // 现货行情
  204. queryThjSpotQuoteConfig().then((res) => {
  205. spotQuoteList.value = res.data
  206. })
  207. // 市场资讯
  208. queryNewTitles({
  209. data: {
  210. page: 1,
  211. pagesize: 10,
  212. }
  213. }).then((res) => {
  214. newsList.value = res.data
  215. }).finally(() => {
  216. refreshing.value = false
  217. })
  218. }
  219. // 市场信息
  220. queryMarketRun().then((res) => {
  221. marketRun.value = res.data[0]
  222. })
  223. onRefresh()
  224. </script>
  225. <style lang="less">
  226. @import "./index.less";
  227. </style>