news.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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="col-xl-12">
  12. <view class="card">
  13. <view class="card-body">
  14. <h6 class="card-title mb-3">Popular Tags </h6>
  15. <view class="d-flex flex-wrap gap-2">
  16. <a href="javascript:void(0);"
  17. class="badge bg-secondary-subtle text-secondary">#NZD/USD</a>
  18. <a href="javascript:void(0);"
  19. class="badge bg-secondary-subtle text-secondary">#EUR/USD</a>
  20. <a href="javascript:void(0);"
  21. class="badge bg-secondary-subtle text-secondary">#XAU/USD</a>
  22. <a href="javascript:void(0);"
  23. class="badge bg-secondary-subtle text-secondary">#USOIL</a>
  24. <a href="javascript:void(0);" class="badge bg-secondary-subtle text-secondary">#US30</a>
  25. <a href="javascript:void(0);"
  26. class="badge bg-secondary-subtle text-secondary">#UK100</a>
  27. <a href="javascript:void(0);"
  28. class="badge bg-secondary-subtle text-secondary">#ADA/USD</a>
  29. <a href="javascript:void(0);"
  30. class="badge bg-secondary-subtle text-secondary">#ZEC/USD</a>
  31. </view>
  32. </view>
  33. </view>
  34. </view> -->
  35. <view class="card">
  36. <view class="card-header">
  37. <view class="nav nav-underline card-header-tabs" id="myTab" role="tablist">
  38. <view class="nav-item" v-for="item in tabsConfig" :key="item">
  39. <view class="nav-link cursor-pointer" @click="activeTab = item.value"
  40. :class="{ 'active': item.value == activeTab }">{{
  41. item.text }}</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="card-body">
  46. <List ref="newsList" :fetchData="fetchNewsList" :queryParams="queryParams" :type="type" />
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </cwg-page-wrapper>
  52. </template>
  53. <script setup lang="ts">
  54. import { ref, reactive, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
  55. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  56. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  57. import { newsApi } from '@/service/news'
  58. import List from './components/List.vue'
  59. const { t, locale } = useI18n()
  60. const isZh = computed(() => ['cn', 'zhHant'].includes(locale.value))
  61. const newsList = ref(null)
  62. const fetchNewsList = ref(null)
  63. const queryParams = ref({
  64. tag: 3,
  65. endDate: "",
  66. startDate: "",
  67. id: null
  68. })
  69. const activeTab = ref(1)
  70. const tabsConfig = computed(() => [
  71. { text: t('News.ExpertAnalysis'), value: 1, type: 5 },
  72. { text: t('News.Ebook'), value: 2, type: 10 },
  73. ])
  74. onReachBottom(() => {
  75. newsList.value?.loadMore()
  76. })
  77. const type = ref(0)
  78. watch(activeTab, (val) => {
  79. if (val == 1) {
  80. fetchNewsList.value = newsApi.newsInformationNewsletterList
  81. queryParams.value = {
  82. tag: 3,
  83. endDate: '',
  84. startDate: '',
  85. id: null, pageSize: 9
  86. }
  87. } else {
  88. fetchNewsList.value = newsApi.newsEbookList
  89. queryParams.value = {
  90. tag: null,
  91. endDate: '',
  92. startDate: '',
  93. id: null, pageSize: 12
  94. }
  95. }
  96. type.value = tabsConfig.value.find(item => item.value == val).type
  97. nextTick(() => {
  98. newsList.value.load()
  99. })
  100. }, { immediate: true })
  101. </script>
  102. <style lang="scss" scoped>
  103. @import "@/uni.scss";
  104. </style>