news.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('News.NewsInformation')" />
  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: 3,
  22. endDate: "",
  23. startDate: "",
  24. id: null
  25. })
  26. const activeTab = ref(1)
  27. const tabsConfig = computed(() => [
  28. { text: t('News.ExpertAnalysis'), value: 1, type: 5 },
  29. { text: t('News.Ebook'), value: 2, type: 10 },
  30. ])
  31. onReachBottom(() => {
  32. newsList.value?.loadMore()
  33. })
  34. const type = ref(0)
  35. watch(activeTab, (val) => {
  36. if (val == 1) {
  37. fetchNewsList.value = newsApi.newsInformationNewsletterList
  38. queryParams.value = {
  39. tag: 3,
  40. endDate: '',
  41. startDate: '',
  42. id: null, pageSize: 9
  43. }
  44. } else {
  45. fetchNewsList.value = newsApi.newsEbookList
  46. queryParams.value = {
  47. tag: null,
  48. endDate: '',
  49. startDate: '',
  50. id: null, pageSize: 12
  51. }
  52. }
  53. type.value = tabsConfig.value.find(item => item.value == val).type
  54. nextTick(() => {
  55. newsList.value.load()
  56. })
  57. }, { immediate: true })
  58. </script>
  59. <style lang="scss" scoped>
  60. @import "@/uni.scss";
  61. </style>