index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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"></list>
  10. </el-col>
  11. <el-col :span="12" class="left">
  12. <top topText="通知通告" @more="more('1')"></top>
  13. <list type="2" :list="twoList"></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"></list>
  20. </el-col>
  21. <el-col :span="12" class="left">
  22. <top topText="媒体聚焦" @more="more('3')"></top>
  23. <list type="4" :list="fourList"></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"></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. console.log(index);
  90. },
  91. },
  92. computed: {
  93. ...mapState(['user']),
  94. },
  95. metaInfo() {
  96. return { title: this.$route.meta.title };
  97. },
  98. watch: {
  99. test: {
  100. deep: true,
  101. immediate: true,
  102. handler(val) {},
  103. },
  104. },
  105. };
  106. </script>
  107. <style lang="less" scoped>
  108. .main {
  109. min-height: 500px;
  110. margin: 10px 0 0 0;
  111. .common {
  112. margin: 0 0 10px 0;
  113. .left {
  114. width: 49.5%;
  115. height: 500px;
  116. overflow: hidden;
  117. box-shadow: 0 0 4px #409eff;
  118. border-radius: 10px;
  119. margin: 0 10px 10px 0;
  120. padding: 10px;
  121. }
  122. .left:nth-child(2n) {
  123. margin: 0 0 10px 0;
  124. }
  125. }
  126. .thr {
  127. .left {
  128. width: 100%;
  129. margin: 0;
  130. height: 300px;
  131. }
  132. }
  133. }
  134. </style>