analystViews.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('News.Announcement')" />
  4. <cwg-asset-tabs v-model="activeTab" :tabs="tabsConfig" />
  5. <view class="account-section">
  6. <List ref="newsList" :fetchData="fetchNewsList" :queryParams="queryParams" :type="type" />
  7. </view>
  8. </cwg-page-wrapper>
  9. </template>
  10. <script setup lang="ts">
  11. import { ref, reactive, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
  12. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  13. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  14. import { newsApi } from '@/service/news'
  15. import List from './components/List.vue'
  16. const { t, locale } = useI18n()
  17. const isZh = computed(() => ['cn', 'zhHant'].includes(locale.value))
  18. const newsList = ref(null)
  19. const fetchNewsList = ref(null)
  20. const queryParams = ref({
  21. tag: 4,
  22. endDate: "",
  23. startDate: "",
  24. id: null
  25. })
  26. const activeTab = ref(1)
  27. const tabsConfig = computed(() => [
  28. { text: t('News.Announcement1'), value: 1, type: 3 },
  29. { text: t('News.CompanyNews'), value: 2, type: 5 },
  30. ])
  31. onReachBottom(() => {
  32. newsList.value?.loadMore()
  33. })
  34. // const lang = computed(() => uni.getLocale())
  35. const type = ref(0)
  36. // watch(lang, (val) => {
  37. // if (activeTab.value == 1) {
  38. // const langMap = {
  39. // 'zh-Hans': 'cn',
  40. // 'zh-Hant': 'zhHant',
  41. // 'vn': 'vi'
  42. // }
  43. // queryParams.value = {
  44. // tag: null,
  45. // endDate: '',
  46. // startDate: '',
  47. // id: null,
  48. // pageSize: 18,
  49. // lang: langMap[val] || val
  50. // }
  51. // }
  52. // })
  53. watch(activeTab, (val) => {
  54. if (val == 1) {
  55. fetchNewsList.value = newsApi.newsInformationList
  56. queryParams.value = {
  57. tag: null,
  58. endDate: '',
  59. startDate: '',
  60. id: null,
  61. pageSize: 18
  62. }
  63. } else {
  64. fetchNewsList.value = newsApi.newsInformationNewsletterList
  65. queryParams.value = {
  66. tag: 4,
  67. endDate: '',
  68. startDate: '',
  69. id: null,
  70. pageSize: 9
  71. }
  72. }
  73. type.value = tabsConfig.value.find(item => item.value == val).type
  74. nextTick(() => {
  75. newsList.value.load()
  76. })
  77. }, { immediate: true })
  78. </script>
  79. <style lang="scss" scoped>
  80. @import "@/uni.scss";
  81. </style>