Index.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <app-view class="home-main">
  3. <template #header>
  4. <app-navbar :title="globalStore.getSystemInfo('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__news">
  12. <CellGroup class="article">
  13. <Cell class="home-main__titlebar" title="市场资讯" value="更多" icon="fire" :to="{ name: 'news-list' }" is-link />
  14. <template v-for="(item, index) in newsList" :key="index">
  15. <Cell class="article-item" :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
  16. :to="{ name: 'news-detail', query: { id: item.id } }" />
  17. </template>
  18. </CellGroup>
  19. </app-block>
  20. </PullRefresh>
  21. </app-view>
  22. </template>
  23. <script lang="ts" setup>
  24. import { shallowRef } from "vue";
  25. import { Cell, CellGroup, PullRefresh } from "vant";
  26. import { formatDate } from "@/filters";
  27. import { queryImageConfigs } from "@/services/api/common";
  28. import { queryNewTitles } from "@/services/api/news";
  29. import { useGlobalStore } from '@/stores'
  30. import Banner from '@mobile/components/base/banner/index.vue'
  31. const globalStore = useGlobalStore()
  32. const refreshing = shallowRef(false); // 是否处于加载中状态
  33. const topBanners = shallowRef<string[]>([]); // 轮播图列表
  34. const newsList = shallowRef<Model.NewTitlesRsp[]>([]); // 资讯列表
  35. // 下拉刷新
  36. const onRefresh = () => {
  37. if (!topBanners.value.length) {
  38. queryImageConfigs({
  39. data: {
  40. imageType: 1,
  41. }
  42. }).then((res) => {
  43. topBanners.value = res.data.map((e) => e.imagepath)
  44. })
  45. }
  46. // 市场资讯
  47. queryNewTitles({
  48. data: {
  49. page: 1,
  50. pagesize: 10,
  51. }
  52. }).then((res) => {
  53. newsList.value = res.data
  54. }).finally(() => {
  55. refreshing.value = false
  56. })
  57. }
  58. onRefresh()
  59. </script>
  60. <style lang="less">
  61. @import "./index.less";
  62. </style>