news.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <view class="container">
  4. <view
  5. class="app-page-head card-header d-flex gap-3 flex-wrap align-items-center justify-content-between border-0">
  6. <view class="app-page-head mb-0">
  7. <h1 class="app-page-title" v-t="'News.NewsInformation'"></h1>
  8. </view>
  9. </view>
  10. <view class="col-row">
  11. <view class="card">
  12. <view class="card-header">
  13. <view class="nav nav-underline card-header-tabs" id="myTab" role="tablist">
  14. <view class="nav-item" v-for="item in tabsConfig" :key="item">
  15. <view class="nav-link cursor-pointer" @click="activeTab = item.value"
  16. :class="{ 'active': item.value == activeTab }">{{
  17. item.text }}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="card-body">
  22. <List ref="newsList" :fetchData="fetchNewsList" :queryParams="queryParams" :type="type" />
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </cwg-page-wrapper>
  28. </template>
  29. <script setup lang="ts">
  30. import { ref, reactive, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
  31. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  32. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  33. import { newsApi } from '@/service/news'
  34. import List from './components/List.vue'
  35. const { t, locale } = useI18n()
  36. const isZh = computed(() => ['cn', 'zhHant'].includes(locale.value))
  37. const newsList = ref(null)
  38. const fetchNewsList = ref(null)
  39. const queryParams = ref({
  40. tag: 3,
  41. endDate: "",
  42. startDate: "",
  43. id: null
  44. })
  45. const activeTab = ref(1)
  46. const tabsConfig = computed(() => [
  47. { text: t('News.ExpertAnalysis'), value: 1, type: 5 },
  48. { text: t('News.Ebook'), value: 2, type: 10 },
  49. ])
  50. onReachBottom(() => {
  51. newsList.value?.loadMore()
  52. })
  53. const type = ref(0)
  54. watch(activeTab, (val) => {
  55. if (val == 1) {
  56. fetchNewsList.value = newsApi.newsInformationNewsletterList
  57. queryParams.value = {
  58. tag: 3,
  59. endDate: '',
  60. startDate: '',
  61. id: null, pageSize: 100
  62. }
  63. } else {
  64. fetchNewsList.value = newsApi.newsEbookList
  65. queryParams.value = {
  66. tag: null,
  67. endDate: '',
  68. startDate: '',
  69. id: null, pageSize: 100
  70. }
  71. }
  72. type.value = tabsConfig.value.find(item => item.value == val).type
  73. nextTick(() => {
  74. newsList.value.load()
  75. })
  76. }, { immediate: true })
  77. </script>
  78. <style lang="scss" scoped>
  79. @import "@/uni.scss";
  80. </style>