detail.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="page" id="page">
  3. <div class="top-title wow fadeInUp" data-wow-duration="2s" data-wow-delay="0s" data-wow-offset="0">
  4. <div class="top-container">
  5. <n-icon :component="IosFiling" size="40" style="vertical-align: middle" />
  6. <span>{{ t('common.navigate.news') }}</span>
  7. </div>
  8. </div>
  9. <div class="newsdt-page">
  10. <div class="container newsdt-container wow fadeInRight" data-wow-duration="2s" data-wow-delay="0s" data-wow-offset="0">
  11. <h1 class="newsdt-title">
  12. {{ vo?.title }}
  13. </h1>
  14. <p class="newsdt-time">
  15. <n-icon :component="MdTime" color="#0e7a0d" size="20" />
  16. <span>{{ vo?.publishDate }}</span>
  17. </p>
  18. <div class="newsdt-text">
  19. <div v-html="vo?.context"></div>
  20. </div>
  21. <div class="newsdt-other wow fadeInDown" data-wow-duration="2s" data-wow-delay="0s" data-wow-offset="0">
  22. <a v-if="last" class="newsdt-other-prev" @click="handleSwt(last)">{{ t('news.detail.last') + ':' + last?.title }}</a>
  23. <a v-if="next" class="newsdt-other-next" @click="handleSwt(next)">{{ t('news.detail.next') + ':' + next?.title }}</a>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="load">
  28. <n-spin size="large">
  29. <template #description>{{ t('report.content.loading') }}</template>
  30. </n-spin>
  31. </div>
  32. </div>
  33. </template>
  34. <script lang="ts" setup>
  35. import { IosFiling, MdTime } from "@vicons/ionicons4";
  36. import { NIcon, NSpin } from "naive-ui";
  37. import { ref, watch, onMounted, onServerPrefetch } from "vue";
  38. import { useRoute, useRouter } from "vue-router";
  39. import { useI18n } from "#imports";
  40. import { useUserStore } from "@/store/user";
  41. const userStore = useUserStore();
  42. const lang = userStore.getLang;
  43. const route = useRoute();
  44. const router = useRouter();
  45. const vo = ref<MarketInfo>(),
  46. last = ref<MarketInfo>(),
  47. next = ref<MarketInfo>();
  48. //const id = ref();
  49. const spinShow = ref("none");
  50. const { t } = useI18n();
  51. // watch(() => route.params.webTitle, (newValue, oldValue) => {
  52. // const wts = newValue.split('-');
  53. // getDetail(wts[wts.length - 1]);
  54. // });
  55. // onMounted(() => {
  56. // const webTitle = route.params.webTitle;
  57. // const wts = webTitle.split("-");
  58. // getDetail(wts[wts.length - 1]);
  59. // });
  60. async function getDetail(id: any) {
  61. spinShow.value = "block";
  62. const ret = await marketInfoDetailList({ id: id, lang: lang });
  63. if (Object.keys(ret).length != 0) {
  64. setTimeout(() => {
  65. vo.value = ret.vo;
  66. last.value = ret.last;
  67. next.value = ret.next;
  68. spinShow.value = "none";
  69. }, 200);
  70. } else {
  71. spinShow.value = "none";
  72. //router.push({name: 'news'});
  73. }
  74. }
  75. // 上下页切换
  76. function handleSwt(item: MarketInfo) {
  77. router.push({
  78. name: "newsDetail",
  79. params: { webTitle: item.webTitle + "-" + item.id },
  80. });
  81. }
  82. // onServerPrefetch(async () => {
  83. try {
  84. const webTitle = route.params.webTitle;
  85. const wts = webTitle.split("-");
  86. const ret = await marketInfoDetailList({
  87. id: wts[wts.length - 1],
  88. lang: lang,
  89. });
  90. if (Object.keys(ret).length != 0) {
  91. vo.value = ret.vo;
  92. last.value = ret.last;
  93. next.value = ret.next;
  94. }
  95. } catch (error) {
  96. console.log(error);
  97. }
  98. useHead({
  99. title: t("defaultSettings.title"),
  100. viewport: "width=device-width,initial-scale=1,maximum-scale=1 ",
  101. charset: "utf-8",
  102. meta: [
  103. {
  104. hid: "keywords",
  105. name: "keywords",
  106. content: t("defaultSettings.keyword"),
  107. },
  108. {
  109. hid: "description",
  110. name: "description",
  111. content: t("defaultSettings.desc"),
  112. },
  113. ],
  114. });
  115. // });
  116. </script>
  117. <style lang="scss" scoped>
  118. .newsdt-page {
  119. padding: 50px 0;
  120. .newsdt-container {
  121. background-color: #fff;
  122. padding: 40px;
  123. .newsdt-title {
  124. font-size: 24px;
  125. font-weight: 700;
  126. color: #214385;
  127. }
  128. .newsdt-time {
  129. margin: 15px 0;
  130. .n-icon {
  131. vertical-align: sub;
  132. }
  133. > span {
  134. font-size: 18px;
  135. margin-left: 3px;
  136. font-weight: bold;
  137. }
  138. }
  139. .newsdt-text {
  140. padding: 40px 0;
  141. border-top: 1px solid #dedede;
  142. border-bottom: 1px solid #dedede;
  143. }
  144. .newsdt-other {
  145. display: flex;
  146. width: 100%;
  147. justify-content: space-between;
  148. margin-top: 30px;
  149. > a {
  150. display: block;
  151. width: 45%;
  152. height: 40px;
  153. line-height: 40px;
  154. overflow: hidden;
  155. text-overflow: ellipsis;
  156. white-space: nowrap;
  157. font-size: 16px;
  158. }
  159. }
  160. }
  161. }
  162. .load {
  163. display: v-bind("spinShow");
  164. }
  165. </style>
  166. <style lang="scss">
  167. .newsdt-text {
  168. ul,
  169. li {
  170. list-style: disc;
  171. }
  172. }
  173. </style>