index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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="page-nav-container wow fadeInLeft" data-wow-duration="2s" data-wow-delay="0s" data-wow-offset="0">
  10. <div class="nav-txt">
  11. <n-breadcrumb separator=">">
  12. <n-breadcrumb-item>
  13. <n-icon :component="MdHome" /><router-link to="/home">{{
  14. t("common.navigate.home")
  15. }}</router-link>
  16. </n-breadcrumb-item>
  17. <n-breadcrumb-item>
  18. <n-icon :component="IosFiling" />{{ t("common.navigate.news") }}
  19. </n-breadcrumb-item>
  20. </n-breadcrumb>
  21. </div>
  22. </div>
  23. <div class="news-content">
  24. <div class="container content">
  25. <div class="search wow fadeInUp" data-wow-duration="2s" data-wow-delay="0s" data-wow-offset="0">
  26. <div class="search-keyword">
  27. <n-input type="text" size="large" round :placeholder="t('report.content.keyword')" clearable v-model:value="params.keyword">
  28. <template #suffix>
  29. <a class="search-btn" @click="handleSearch"><n-icon :component="MdSearch" size="30" color="#0e7a0d" /></a>
  30. </template>
  31. </n-input>
  32. </div>
  33. <div class="search-type">
  34. <a :class="
  35. !params?.marketType && !params.marketCategory ? 'selected' : ''
  36. " @click="handleAll()">{{ t("news.category.title") }}</a>
  37. <!--资讯分类-->
  38. <template v-for="item in newsCategory" :key="item">
  39. <a :class="item.dictValue === params?.marketType ? 'selected' : ''" @click="handleType(item.dictValue)">{{ item.dictLabel }}</a>
  40. </template>
  41. <!--报告分类-->
  42. <template v-for="item in reportTypes" :key="item">
  43. <a :class="
  44. item.dictValue === params?.marketCategory ? 'selected' : ''
  45. " @click="handleCategroy(item.dictValue)">{{ item.dictLabel }}</a>
  46. </template>
  47. </div>
  48. </div>
  49. <div class="content-list">
  50. <template v-for="item in pageList?.list" :key="item">
  51. <n-list :show-divider="false">
  52. <n-list-item class="content-list-item wow fadeInRight" data-wow-duration="2s" data-wow-delay="0s" data-wow-offset="0">
  53. <template #prefix>
  54. <div class="img">
  55. <a :href="
  56. (lang === 'zh-CN' ? '' : '/en') +
  57. '/news/' +
  58. item.webTitle +
  59. '-' +
  60. item.id
  61. ">
  62. <img :src="
  63. BaseUrl +
  64. '/fileupload/' +
  65. item.filePath +
  66. item.fileName
  67. " />
  68. </a>
  69. </div>
  70. </template>
  71. <!-- <a class="list-title" @click="viewDetail(item)">{{ item.title }}</a> -->
  72. <a class="list-title" :href="
  73. (lang === 'zh-CN' ? '' : '/en') +
  74. '/news/' +
  75. item.webTitle +
  76. '-' +
  77. item.id
  78. ">{{ item.title }}</a>
  79. <div v-if="pcShow" class="list-pc">
  80. <p class="list-content">{{ item.outline }}</p>
  81. <span class="list-date">{{ item.publishDate }}</span>
  82. </div>
  83. </n-list-item>
  84. <template #footer>
  85. <div v-if="!pcShow" class="list-mobile">
  86. <p class="list-content">{{ item.outline }}</p>
  87. <span class="list-date">{{ item.publishDate }}</span>
  88. </div>
  89. </template>
  90. </n-list>
  91. </template>
  92. <div class="pagination">
  93. <n-pagination :page="pageList?.pageNo" :page-count="pageList?.count" :page-size="pageList?.pageSize" size="large" :on-update-page="changePage" :page-slot="7" />
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="load">
  99. <n-spin size="large">
  100. <template #description>{{ t("report.content.loading") }}</template>
  101. </n-spin>
  102. </div>
  103. </div>
  104. </template>
  105. <script lang="ts" setup>
  106. import { IosFiling, MdHome, MdSearch } from "@vicons/ionicons4";
  107. import {
  108. NIcon,
  109. NBreadcrumb,
  110. NBreadcrumbItem,
  111. NInput,
  112. NList,
  113. NListItem,
  114. NThing,
  115. NPagination,
  116. NSpin,
  117. } from "naive-ui";
  118. import { useRouter, useRoute } from "vue-router";
  119. import { onMounted, onServerPrefetch, ref, watch } from "vue";
  120. import { useI18n } from "#imports";
  121. import { useUserStore } from "@/store/user";
  122. const config = useRuntimeConfig();
  123. const BaseUrl = ref(config.public.baseUrl);
  124. const pageSize = 10;
  125. const router = useRouter();
  126. const route = useRoute(); // 接收参数
  127. const reportTypes = ref([]); // 报告分类
  128. const newsCategory = ref([]); //资讯分类
  129. const params = ref({ pageSize: pageSize, pageNo: 1, keyword: "" }) as any; // 参数
  130. const pageList = ref([]); //data
  131. const spinShow = ref("none"); // loading
  132. const { t } = useI18n();
  133. const pcShow = ref<boolean>(true);
  134. const userStore = useUserStore();
  135. const lang = userStore.getLang;
  136. function viewDetail(item: MarketInfo) {
  137. const language = lang === "zh-CN" ? "" : "en";
  138. router.push({
  139. name: "newsDetail",
  140. params: { webTitle: item.webTitle + "-" + item.id, lang: language },
  141. });
  142. }
  143. // onMounted(async () => {
  144. // pcShow.value = !isMobile();
  145. // const keyword = route.params.keyword;
  146. // if (keyword) {
  147. // params.value.keyword = keyword;
  148. // }
  149. // const dicts = await getLocalSessionReport();
  150. // reportTypes.value = dicts;
  151. // const dicts02 = await getLocalSessionNews();
  152. // newsCategory.value = dicts02;
  153. // if (containsMarketType(dicts, route.params.marketType)) {
  154. // params.value.marketCategory = route.params.marketType;
  155. // } else {
  156. // params.value.marketType = route.params.marketType;
  157. // }
  158. // await getData();
  159. // });
  160. watch(
  161. () => [
  162. route.params.marketType,
  163. route.params.marketCategory,
  164. route.params.keyword,
  165. ],
  166. (newValue, oldValue) => {
  167. params.value.marketType = newValue[0];
  168. params.value.marketCategory = newValue[1];
  169. params.value.keyword = newValue[2];
  170. getData();
  171. }
  172. );
  173. async function getData() {
  174. spinShow.value = "block";
  175. params.value.lang = lang;
  176. const ret = await marketInfoPageList(params.value);
  177. setTimeout(() => {
  178. pageList.value = ret.data;
  179. spinShow.value = "none";
  180. }, 500);
  181. }
  182. //报告分类
  183. function handleCategroy(type: string | undefined) {
  184. params.value.marketType = "";
  185. params.value.marketCategory = type;
  186. const language = lang === "zh-CN" ? "" : "en";
  187. router.push({
  188. name: "newsCategories",
  189. params: { marketCategory: type, lang: language },
  190. });
  191. }
  192. //资讯分类
  193. function handleType(type: string | undefined) {
  194. params.value.marketCategory = "";
  195. params.value.marketType = type;
  196. const language = lang === "zh-CN" ? "" : "en";
  197. router.push({
  198. name: "newsCategories",
  199. params: { marketType: type, lang: language },
  200. });
  201. }
  202. // 全部
  203. function handleAll() {
  204. params.value.marketCategory = "";
  205. params.value.marketType = "";
  206. const language = lang === "zh-CN" ? "" : "en";
  207. router.push({ name: "newsCategories", params: { lang: language } });
  208. }
  209. // 改变页数
  210. async function changePage(page: number) {
  211. document.documentElement.scrollTop = 0;
  212. params.value.pageNo = page;
  213. await getData();
  214. }
  215. // 关键字查询
  216. async function handleSearch() {
  217. await getData();
  218. }
  219. try {
  220. const keyword = route.params.keyword;
  221. if (keyword) {
  222. params.value.keyword = keyword;
  223. }
  224. const dicts = await getLocalSessionReport();
  225. reportTypes.value = dicts;
  226. const dicts02 = await getLocalSessionNews();
  227. newsCategory.value = dicts02;
  228. if (containsMarketType(dicts, route.params.marketType)) {
  229. params.value.marketCategory = route.params.marketType;
  230. } else {
  231. params.value.marketType = route.params.marketType;
  232. }
  233. params.value.lang = lang;
  234. const ret = await marketInfoPageList(params.value);
  235. pageList.value = ret;
  236. } catch (error) {
  237. console.log(error);
  238. }
  239. useHead({
  240. title: t("common.navigate.news") + "-" + t("defaultSettings.title"),
  241. viewport: "width=device-width,initial-scale=1,maximum-scale=1 ",
  242. charset: "utf-8",
  243. meta: [
  244. {
  245. hid: "keywords",
  246. name: "keywords",
  247. content: t("defaultSettings.keyword"),
  248. },
  249. {
  250. hid: "description",
  251. name: "description",
  252. content: t("defaultSettings.desc"),
  253. },
  254. ],
  255. });
  256. </script>
  257. <style scoped lang="scss">
  258. .news-content {
  259. padding-bottom: 30px;
  260. margin-top: 10px;
  261. .content {
  262. background-color: #fff;
  263. padding: 3em 4em;
  264. .search {
  265. .search-keyword {
  266. width: 70%;
  267. .n-icon {
  268. vertical-align: middle;
  269. }
  270. }
  271. .search-type {
  272. display: flex;
  273. margin-top: 20px;
  274. flex-wrap: wrap;
  275. > a {
  276. display: block;
  277. padding: 8px 15px;
  278. background-color: #eaedf4;
  279. border-radius: 30px;
  280. font-size: 14px;
  281. margin: 0 1rem 1rem 0;
  282. }
  283. a.selected {
  284. background-color: #18a058;
  285. color: #fff;
  286. }
  287. }
  288. }
  289. .img {
  290. height: 160px;
  291. width: 200px;
  292. overflow: hidden;
  293. img {
  294. width: 100%;
  295. transition: all 0.4s ease;
  296. height: 100%;
  297. object-fit: cover;
  298. &:hover {
  299. transform: scale(1.1);
  300. }
  301. }
  302. }
  303. }
  304. }
  305. .list-title {
  306. display: block;
  307. font-size: 19px;
  308. color: #333333;
  309. font-weight: bold;
  310. transition: all 0.4s ease;
  311. padding: 10px 0;
  312. }
  313. .list-content {
  314. font-size: 14px;
  315. color: #999999;
  316. line-height: 26px;
  317. text-overflow: ellipsis;
  318. -webkit-line-clamp: 2;
  319. overflow: hidden;
  320. word-wrap: break-word;
  321. display: -webkit-box;
  322. -webkit-box-orient: vertical;
  323. height: 70px;
  324. margin: 0;
  325. }
  326. .list-date {
  327. display: block;
  328. font-size: 14px;
  329. color: #999999;
  330. line-height: 26px;
  331. }
  332. .pagination {
  333. width: 100%;
  334. display: flex;
  335. justify-content: center;
  336. padding-top: 40px;
  337. border-top: 1px solid rgb(239 239 245);
  338. }
  339. .content-list-item {
  340. padding: 40px 20px;
  341. }
  342. .load {
  343. display: v-bind("spinShow");
  344. }
  345. </style>