analystViews.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.Announcement'"></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: 4,
  41. endDate: "",
  42. startDate: "",
  43. id: null
  44. })
  45. const activeTab = ref(1)
  46. const tabsConfig = computed(() => [
  47. { text: t('News.Announcement1'), value: 1, type: 3 },
  48. { text: t('News.CompanyNews'), value: 2, type: 5 },
  49. ])
  50. onReachBottom(() => {
  51. newsList.value?.loadMore()
  52. })
  53. // const lang = computed(() => uni.getLocale())
  54. const type = ref(0)
  55. // watch(lang, (val) => {
  56. // if (activeTab.value == 1) {
  57. // const langMap = {
  58. // 'zh-Hans': 'cn',
  59. // 'zh-Hant': 'zhHant',
  60. // 'vn': 'vi'
  61. // }
  62. // queryParams.value = {
  63. // tag: null,
  64. // endDate: '',
  65. // startDate: '',
  66. // id: null,
  67. // pageSize: 18,
  68. // lang: langMap[val] || val
  69. // }
  70. // }
  71. // })
  72. watch(activeTab, (val) => {
  73. if (val == 1) {
  74. fetchNewsList.value = newsApi.newsInformationList
  75. queryParams.value = {
  76. tag: null,
  77. endDate: '',
  78. startDate: '',
  79. id: null,
  80. pageSize: 18
  81. }
  82. } else {
  83. fetchNewsList.value = newsApi.newsInformationNewsletterList
  84. queryParams.value = {
  85. tag: 4,
  86. endDate: '',
  87. startDate: '',
  88. id: null,
  89. pageSize: 9
  90. }
  91. }
  92. type.value = tabsConfig.value.find(item => item.value == val).type
  93. nextTick(() => {
  94. newsList.value.load()
  95. })
  96. }, { immediate: true })
  97. </script>
  98. <style lang="scss" scoped>
  99. @import "@/uni.scss";
  100. </style>