index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <app-scroll-view class="home-main">
  3. <template #afterHeader>
  4. <app-navbar title="铁合金掌上行" :show-back-button="false" />
  5. </template>
  6. <app-statusbar class="home-main__header">
  7. <div class="home-main__banner home-main__banner--header">
  8. <Swipe :autoplay="5000" indicator-color="white" lazy-render>
  9. <SwipeItem v-for="(item, index) in topBanners" :key="index">
  10. <img :src="getFileUrl(item.imagepath)" />
  11. </SwipeItem>
  12. </Swipe>
  13. </div>
  14. </app-statusbar>
  15. <PullRefresh class="home-main__container" v-model="refreshing" @refresh="onRefresh">
  16. <app-block class="home-main__iconbar bg">
  17. <ul>
  18. <li @click="routerTo('product')">
  19. <img src="@mobile/assets/icons/cpjs.svg" />
  20. <span>产品介绍</span>
  21. </li>
  22. <li @click="routerTo('Market')">
  23. <img src="@mobile/assets/icons/cpjg.svg" />
  24. <span>产品价格</span>
  25. </li>
  26. <li @click="routerTo('NavigationPTGZ')">
  27. <img src="@mobile/assets/icons/ptgz.svg" />
  28. <span>平台规则</span>
  29. </li>
  30. </ul>
  31. <ul>
  32. <li @click="routerTo('credit-signin')">
  33. <img src="@mobile/assets/icons/wdrw.svg" />
  34. <span>我的任务</span>
  35. </li>
  36. <li @click="routerTo('contract')">
  37. <img src="@mobile/assets/icons/htzr.svg" />
  38. <span>合同转让</span>
  39. </li>
  40. <li @click="routerTo('rules-ccwl')">
  41. <img src="@mobile/assets/icons/ccwl.svg" />
  42. <span>仓储物流</span>
  43. </li>
  44. </ul>
  45. </app-block>
  46. <app-block class="home-main__market" v-if="spotQuoteList.length">
  47. <Cell class="home-main__titlebar" value="更多" :to="{ name: 'MarketSpot' }" is-link>
  48. <template #title>
  49. <img src="@mobile/assets/icons/spot.png" />
  50. <span>现货行情</span>
  51. <span>({{ currentSpotQuote.spotmonth }})</span>
  52. </template>
  53. </Cell>
  54. <section class="scrollbar">
  55. <Swipe :autoplay="8000" :show-indicators="false" :touchable="false" vertical @change="onSpotChange">
  56. <SwipeItem v-for="(item, i) in spotQuoteList" :key="i">
  57. <ul @click="openNewsDetails(item.relatedid)">
  58. <li>
  59. <span>{{ item.spotsrc }}</span>
  60. </li>
  61. <li>
  62. <span>{{ item.spotname }}招标价 </span>
  63. <span class="g-color--up">{{ item.spotprice }}元/吨</span>
  64. </li>
  65. <li>
  66. <span>采购量 </span>
  67. <span class="g-color--up">{{ item.spotqty }}吨</span>
  68. </li>
  69. </ul>
  70. </SwipeItem>
  71. </Swipe>
  72. </section>
  73. </app-block>
  74. <app-block v-if="false">
  75. <section class="scrollbar">
  76. <h4 class="scrollbar-title">
  77. <img src="@mobile/assets/icons/futures.png" />
  78. <span>期货行情</span>
  79. </h4>
  80. <Swipe :autoplay="8000" :show-indicators="false" :touchable="false" vertical>
  81. <SwipeItem
  82. v-for="({ goodsname, last, lasttime, presettle, change, amplitude, holdvolume, lastvolume, decimalplace }, i) in dataList"
  83. :key="i">
  84. <ul>
  85. <li>{{ goodsname }}</li>
  86. <li style="color:#999">{{ formatDate(lasttime, 'HH:mm') }}</li>
  87. <li :class="handlePriceColor(last, presettle)">{{ handleNumberValue(formatDecimal(last, decimalplace))
  88. }}
  89. </li>
  90. <li :class="handlePriceColor(last, presettle)">{{ handleNumberValue(formatDecimal(change, decimalplace))
  91. }}</li>
  92. <li :class="handlePriceColor(last, presettle)">{{ parsePercent(amplitude) }}</li>
  93. <li :class="handlePriceColor(last, presettle)">{{ changeUnit(lastvolume) }}</li>
  94. <li :class="handlePriceColor(last, presettle)">{{ changeUnit(holdvolume) }}</li>
  95. </ul>
  96. </SwipeItem>
  97. </Swipe>
  98. </section>
  99. </app-block>
  100. <app-block class="home-main__banner home-main__banner--body" v-if="false">
  101. <Swipe :autoplay="5000" indicator-color="white" lazy-render>
  102. <SwipeItem v-for="(item, index) in bodyBanners" :key="index">
  103. <img :src="getFileUrl(item.imagepath)" />
  104. </SwipeItem>
  105. </Swipe>
  106. </app-block>
  107. <app-block class="home-main__news">
  108. <CellGroup class="article">
  109. <Cell class="home-main__titlebar" value="更多" :to="{ name: 'news-list' }" is-link>
  110. <template #title>
  111. <img src="@mobile/assets/icons/fire.png" />
  112. <span>市场资讯</span>
  113. </template>
  114. </Cell>
  115. <template v-for="(item, index) in newsList" :key="index">
  116. <Cell class="article-item" :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
  117. :to="{ name: 'news-details', query: { id: item.id } }" />
  118. </template>
  119. </CellGroup>
  120. </app-block>
  121. </PullRefresh>
  122. </app-scroll-view>
  123. </template>
  124. <script lang="ts" setup>
  125. import { shallowRef, computed } from "vue";
  126. import { Cell, CellGroup, Swipe, SwipeItem, PullRefresh } from "vant";
  127. import { formatDecimal, getFileUrl, formatDate, handlePriceColor, parsePercent, handleNumberValue, changeUnit } from "@/filters";
  128. import { useNavigation } from "@/hooks/navigation";
  129. import { queryImageConfigs } from "@/services/api/common";
  130. import { queryNewTitles } from "@/services/api/news";
  131. import { useFuturesList } from "@/business/market";
  132. import { queryMarketRun } from "@/services/api/goods";
  133. import { queryThjSpotQuoteConfig } from "@/services/api/market";
  134. const { router, routerTo } = useNavigation();
  135. const { dataList } = useFuturesList();
  136. const refreshing = shallowRef(false); // 是否处于加载中状态
  137. const topBanners = shallowRef<Model.ImageConfigsRsp[]>([]); // 轮播图列表
  138. const bodyBanners = shallowRef<Model.ImageConfigsRsp[]>([]); // 轮播图列表
  139. const newsList = shallowRef<Model.NewTitlesRsp[]>([]); // 资讯列表
  140. const spotQuoteList = shallowRef<Model.ThjSpotQuoteConfigRsp[]>([]); // 现货行情
  141. const spotQuoteIndex = shallowRef(0) // 当前现货行情索引
  142. const marketRun = shallowRef<Partial<Model.MarketRunRsp>>({}); // 市场
  143. // 当前现货行情
  144. const currentSpotQuote = computed(() => spotQuoteList.value[spotQuoteIndex.value])
  145. // 打开新闻详情
  146. const openNewsDetails = (id: number) => {
  147. if (id) {
  148. router.push({ name: 'news-details', query: { id } })
  149. }
  150. }
  151. // 现货行情轮播变化
  152. const onSpotChange = (index: number) => {
  153. spotQuoteIndex.value = index
  154. }
  155. // 下拉刷新
  156. const onRefresh = () => {
  157. if (!topBanners.value.length) {
  158. queryImageConfigs({
  159. imageType: 1,
  160. }).then((res) => {
  161. topBanners.value = res.data
  162. })
  163. }
  164. // if (!bodyBanners.value.length) {
  165. // queryImageConfigs({
  166. // imageType: 10,
  167. // }).then((res) => {
  168. // bodyBanners.value = res.data
  169. // })
  170. // }
  171. // 现货行情
  172. queryThjSpotQuoteConfig().then((res) => {
  173. spotQuoteList.value = res.data
  174. })
  175. // 市场资讯
  176. queryNewTitles({
  177. page: 1,
  178. pagesize: 10,
  179. }).then((res) => {
  180. newsList.value = res.data
  181. }).finally(() => {
  182. refreshing.value = false
  183. })
  184. }
  185. // 市场信息
  186. queryMarketRun().then((res) => {
  187. marketRun.value = res.data[0]
  188. })
  189. onRefresh()
  190. </script>
  191. <style lang="less">
  192. @import "./index.less";
  193. </style>