PolicyAdviceIndex.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <!--
  2. * @Description: 政策资讯
  3. * @Author: 空白格
  4. * @Date: 2022-08-11 09:15:53
  5. * @LastEditors: 空白格
  6. * @LastEditTime: 2022-08-30 14:33:08
  7. * @FilePath: \veterans_client_web\src\views\PolicyAdvice\PolicyAdviceIndex.vue
  8. * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
  9. -->
  10. <template>
  11. <div class="app-main policy-advice">
  12. <BannerBreadcrumb title="政策资讯" />
  13. <!-- 内容 -->
  14. <div class="app-main-box policy-advice-box">
  15. <div class="policy-advice-box-logo">
  16. <el-carousel :interval="5000" arrow="never" height="140px">
  17. <el-carousel-item v-for="(item, index) in bannerList" :key="index">
  18. <el-image
  19. class="image"
  20. :src="
  21. item.bannerUrl || require('@/assets/images/policy-advice-logo.png')
  22. "
  23. fit="cover"
  24. @click="
  25. item.id &&
  26. jumpPage('/bannerdetails', {
  27. id: item.id,
  28. type: 5,
  29. })
  30. "
  31. >
  32. <div slot="placeholder" class="image-slot">
  33. 加载图片中<span class="dot">...</span>
  34. </div>
  35. <div slot="error" class="image-slot">
  36. <el-image
  37. class="image"
  38. :src="require('@/assets/images/policy-advice-logo.png')"
  39. fit="cover"
  40. ></el-image>
  41. </div>
  42. </el-image>
  43. <div class="title">
  44. {{ item.artTitle || "" }}
  45. </div>
  46. </el-carousel-item>
  47. </el-carousel>
  48. </div>
  49. <div class="app-main-box-content policy-advice-box-policy">
  50. <el-tabs v-model="queryParams.artCategoryId" @tab-click="handleClick">
  51. <el-tab-pane
  52. v-for="(item, index) in policyTypeList"
  53. :key="index"
  54. :label="item.label"
  55. :name="item.text"
  56. >
  57. <ul
  58. class="policy-list"
  59. v-loading="loading"
  60. v-if="policyList.length"
  61. >
  62. <li
  63. class="policy-list-item"
  64. @click="
  65. jumpPage('newsdetails', { id: item.artId, type: 'policy' })
  66. "
  67. v-for="(item, index) in policyList"
  68. :key="index"
  69. >
  70. <div class="policy-list-title">{{ item.artTitle }}</div>
  71. <div class="policy-list-icon">
  72. <i class="el-icon-arrow-right"></i>
  73. </div>
  74. </li>
  75. </ul>
  76. <div class="pagination" v-if="total">
  77. <el-pagination
  78. background
  79. layout="prev, pager, next"
  80. :page-size="queryParams.pageSize"
  81. :total="total"
  82. @current-change="currentChange"
  83. >
  84. </el-pagination>
  85. </div>
  86. <el-empty v-else description="暂无数据"></el-empty>
  87. </el-tab-pane>
  88. </el-tabs>
  89. </div>
  90. </div>
  91. </div>
  92. </template>
  93. <script>
  94. import BannerBreadcrumb from "@/components/BannerBreadcrumb";
  95. import { getDictData } from "@/api/Dict";
  96. import { getPolicyData } from "@/api/PolicyAdvice";
  97. import { getBannerList } from "@/api/Home";
  98. export default {
  99. name: "PolicyAdviceIndex",
  100. components: {
  101. BannerBreadcrumb,
  102. },
  103. data() {
  104. return {
  105. queryParams: {
  106. pageNum: 1,
  107. pageSize: 10,
  108. artCategoryId: "",
  109. },
  110. total: 0,
  111. policyTypeList: [],
  112. policyList: [],
  113. bannerList: [
  114. { bannerUrl: require("@/assets/images/policy-advice-logo.png") },
  115. ],
  116. loading: false,
  117. };
  118. },
  119. created() {
  120. this.getDictList();
  121. },
  122. methods: {
  123. /**
  124. * 获取字典数据
  125. * @date 2022-08-11
  126. * @returns {any}
  127. */
  128. getDictList() {
  129. getDictData({ key: "policy_type" }).then((res) => {
  130. this.policyTypeList = res.data;
  131. if (this.policyTypeList.length) {
  132. this.queryParams.artCategoryId = this.policyTypeList[0].text;
  133. this.getPolicyList();
  134. }
  135. });
  136. },
  137. /**
  138. * 获取政策资讯轮播
  139. * @date 2022-08-17
  140. * @returns {any}
  141. */
  142. getPolicyBannerList() {
  143. getBannerList({ type: 5 }).then((res) => {
  144. res.data.length ? (this.bannerList = res.data) : "";
  145. });
  146. },
  147. /**
  148. * 获取政策资讯列表数据
  149. */
  150. getPolicyList() {
  151. this.loading = true;
  152. getPolicyData(this.queryParams).then((res) => {
  153. this.policyList = res?.rows;
  154. this.total = Number(res?.total);
  155. this.loading = false;
  156. });
  157. },
  158. /**
  159. * tab点击
  160. * @date 2022-08-11
  161. * @param {any} tab
  162. * @returns {any}
  163. */
  164. handleClick(tab) {
  165. this.queryParams.pageNum = 1;
  166. this.queryParams.artCategoryId = tab.name;
  167. this.getPolicyList();
  168. },
  169. /**
  170. * 分页触发
  171. * @date 2022-08-30
  172. * @param {any} page
  173. * @returns {any}
  174. */
  175. currentChange(page) {
  176. this.queryParams.pageNum = page;
  177. this.getPolicyList();
  178. },
  179. /**
  180. * 跳转到指定页面
  181. * @date 2022-08-11
  182. * @param {any} path
  183. * @returns {any}
  184. */
  185. jumpPage(path, param) {
  186. if (path) {
  187. this.$router.push({ path: path, query: param });
  188. }
  189. },
  190. },
  191. };
  192. </script>
  193. <style lang="scss" scoped>
  194. .policy-advice {
  195. &-box {
  196. &-logo {
  197. width: 100%;
  198. height: 157px;
  199. .image {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. &-policy {
  205. min-height: 400px;
  206. :deep(.el-tabs__item) {
  207. font-size: 20px;
  208. font-weight: 500;
  209. color: #000000;
  210. }
  211. :deep(.el-tabs__item:hover) {
  212. color: #163da5;
  213. }
  214. :deep(.el-tabs__item.is-active) {
  215. color: #163da5;
  216. }
  217. :deep(.el-tabs__active-bar) {
  218. background-color: #163da5;
  219. }
  220. .policy-list {
  221. &-item {
  222. display: flex;
  223. justify-content: space-between;
  224. border-bottom: dashed 1px #d7d7d7;
  225. color: #2b2b2b;
  226. font-size: 16px;
  227. height: 50px;
  228. line-height: 50px;
  229. margin-bottom: 10px;
  230. cursor: pointer;
  231. }
  232. }
  233. }
  234. }
  235. .pagination {
  236. text-align: center;
  237. margin-top: 20px;
  238. :deep(.el-pager .active) {
  239. background-color: #ff3939;
  240. }
  241. :deep(.el-pagination.is-background .el-pager li:not(.disabled).active) {
  242. background-color: #ff3939;
  243. }
  244. }
  245. }
  246. </style>