index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <div class="w_1200">
  6. <el-col :span="24" class="common one">
  7. <el-col :span="12" class="left">
  8. <top topText="通知通告" @more="more('0')"></top>
  9. <list type="1" :list="oneList" @detail="detail"></list>
  10. </el-col>
  11. <el-col :span="12" class="left">
  12. <top topText="政务动态" @more="more('1')"></top>
  13. <list type="2" :list="twoList" @detail="detail"></list>
  14. </el-col>
  15. </el-col>
  16. <el-col :span="24" class="common two">
  17. <el-col :span="12" class="left">
  18. <top topText="科技新闻" @more="more('2')"></top>
  19. <list type="3" :list="thrList" @detail="detail"></list>
  20. </el-col>
  21. <el-col :span="12" class="left">
  22. <top topText="媒体聚焦" @more="more('3')"></top>
  23. <list type="4" :list="fourList" @detail="detail"></list>
  24. </el-col>
  25. </el-col>
  26. <!-- <el-col :span="24" class="common thr">
  27. <el-col :span="24" class="left">
  28. <top topText="信息公开" @more="more('4')"></top>
  29. <list type="5" :list="fiveList" @detail="detail"></list>
  30. </el-col>
  31. </el-col> -->
  32. </div>
  33. </el-col>
  34. </el-row>
  35. </div>
  36. </template>
  37. <script>
  38. import top from './parts/top.vue';
  39. import list from './parts/list.vue';
  40. const { newsColumn } = require('@common/dict/index');
  41. import { mapState, createNamespacedHelpers } from 'vuex';
  42. const { mapActions: news } = createNamespacedHelpers('news');
  43. export default {
  44. name: 'index',
  45. props: {},
  46. components: { top, list },
  47. data: function () {
  48. return {
  49. // 通知通告
  50. oneList: [],
  51. // 政务动态
  52. twoList: [],
  53. // 科技新闻
  54. thrList: [],
  55. // 媒体聚焦
  56. fourList: [],
  57. // 信息公开
  58. fiveList: [],
  59. column: newsColumn,
  60. };
  61. },
  62. async created() {
  63. await this.search();
  64. },
  65. methods: {
  66. ...news(['query']),
  67. async search({ skip = 0, limit = 10, ...info } = {}) {
  68. for (const val of this.column) {
  69. if (val == '通知通告') {
  70. let res = await this.query({ skip, limit: 11, column_name: val, ...info });
  71. if (this.$checkRes(res)) this.$set(this, `oneList`, res.data);
  72. } else if (val == '政务动态') {
  73. let res = await this.query({ skip, limit: 11, column_name: val, ...info });
  74. if (this.$checkRes(res)) this.$set(this, `twoList`, res.data);
  75. } else if (val == '科技新闻') {
  76. let res = await this.query({ skip, limit: 4, column_name: val, ...info });
  77. if (this.$checkRes(res)) this.$set(this, `thrList`, res.data);
  78. } else if (val == '媒体聚焦') {
  79. let res = await this.query({ skip, limit: 11, column_name: val, ...info });
  80. if (this.$checkRes(res)) this.$set(this, `fourList`, res.data);
  81. } else if (val == '信息公开') {
  82. let res = await this.query({ skip, limit: 12, column_name: val, ...info });
  83. if (this.$checkRes(res)) this.$set(this, `fiveList`, res.data);
  84. }
  85. }
  86. },
  87. // 更多
  88. more(index) {
  89. this.$router.push({ path: '/news/list', query: { index: index } });
  90. },
  91. // 详情
  92. detail({ id, index }) {
  93. this.$router.push({ path: '/news/list', query: { id: id, index: index } });
  94. },
  95. },
  96. computed: {
  97. ...mapState(['user']),
  98. },
  99. metaInfo() {
  100. return { title: this.$route.meta.title };
  101. },
  102. watch: {
  103. test: {
  104. deep: true,
  105. immediate: true,
  106. handler(val) {},
  107. },
  108. },
  109. };
  110. </script>
  111. <style lang="less" scoped>
  112. .main {
  113. min-height: 500px;
  114. margin: 10px 0 0 0;
  115. .common {
  116. margin: 0 0 10px 0;
  117. .left {
  118. width: 49.5%;
  119. height: 500px;
  120. overflow: hidden;
  121. box-shadow: 0 0 4px #409eff;
  122. border-radius: 10px;
  123. margin: 0 10px 10px 0;
  124. padding: 10px;
  125. }
  126. .left:nth-child(2n) {
  127. margin: 0 0 10px 0;
  128. }
  129. }
  130. .thr {
  131. .left {
  132. width: 100%;
  133. margin: 0;
  134. height: 300px;
  135. }
  136. }
  137. }
  138. </style>