index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div id="index">
  3. <index-detail
  4. :info="info"
  5. :map="map"
  6. :zixunList="gndtList"
  7. :noticeList="tzggList"
  8. :lawList="zhzczdList"
  9. :xinpinList="xinpinList"
  10. :chuangxinList="chuangxinList"
  11. :linkList="linkList"
  12. ></index-detail>
  13. </div>
  14. </template>
  15. <script>
  16. import indexDetail from '@/components/index.vue';
  17. import { createNamespacedHelpers, mapGetters } from 'vuex';
  18. const { mapActions: mapSite } = createNamespacedHelpers('site');
  19. const { mapActions: mapLink } = createNamespacedHelpers('link');
  20. const { mapActions: mapAffairsColumn } = createNamespacedHelpers('affairsColumn');
  21. const { mapActions: mapAffairsNews } = createNamespacedHelpers('affairsNews');
  22. const { mapActions: mapPolicyColumn } = createNamespacedHelpers('policyColumn');
  23. const { mapActions: mapPolicyNews } = createNamespacedHelpers('policyNews');
  24. export default {
  25. name: 'index',
  26. props: {},
  27. components: {
  28. indexDetail,
  29. },
  30. data: () => ({
  31. info: {},
  32. map: require('@/assets/map.jpg'),
  33. gndtList: [],
  34. tzggList: [],
  35. zhzczdList: [
  36. {
  37. title: '尼日利亚传统领袖:尼应学习借鉴中国自贸区建设经验',
  38. date: '2019-12-25',
  39. },
  40. {
  41. title: '八条数据',
  42. date: '2019-12-25',
  43. },
  44. ],
  45. linkList: [],
  46. xinpinList: [
  47. {
  48. title: '科技超市(产品)',
  49. date: '2019-12-25',
  50. },
  51. {
  52. title: '六条数据',
  53. date: '2019-12-25',
  54. },
  55. ],
  56. chuangxinList: [
  57. {
  58. title: '科技超市(产品)',
  59. date: '2019-12-25',
  60. },
  61. {
  62. title: '六条数据',
  63. date: '2019-12-25',
  64. },
  65. ],
  66. }),
  67. created() {
  68. this.searchSite();
  69. this.searchLink();
  70. this.searchAffairs();
  71. this.searchPolicy();
  72. },
  73. computed: {},
  74. methods: {
  75. ...mapSite(['showInfo']),
  76. ...mapLink(['query']),
  77. ...mapAffairsColumn({ affairsColumnList: 'query', affairsColumnInfo: 'fetch' }),
  78. ...mapAffairsNews({ affairsNews: 'query' }),
  79. ...mapPolicyColumn({ policyColumnList: 'query', policyColumnInfo: 'fetch' }),
  80. ...mapPolicyNews({ policyNews: 'query' }),
  81. // 查询站点信息
  82. async searchSite() {
  83. let res = await this.showInfo();
  84. let object = JSON.parse(JSON.stringify(res.data));
  85. if (object) {
  86. this.$set(this, `info`, res.data);
  87. } else {
  88. this.$message.error(res.errmsg ? res.errmsg : 'error');
  89. }
  90. },
  91. // 查询友情链接
  92. async searchLink({ ...info } = {}) {
  93. const res = await this.query({ ...info });
  94. if (this.$checkRes(res)) {
  95. this.$set(this, `linkList`, res.data);
  96. }
  97. },
  98. // 最新資訊,通知公告(所属科技政务,国内动态,通知公告)
  99. async searchAffairs({ ...info } = {}) {
  100. const res = await this.affairsColumnList({ ...info });
  101. for (const val of res.data) {
  102. this.tpxwSearch({ column_id: val.id, site: val.site });
  103. }
  104. },
  105. async tpxwSearch({ skip = 0, limit = 8, column_id, site } = {}) {
  106. if (site === 'gndt') {
  107. const res = await this.affairsNews({ skip, limit, column_id: column_id });
  108. for (const val of res.data) {
  109. const result = await this.affairsColumnInfo(val.column_id);
  110. val.column_name = result.data.name;
  111. }
  112. this.$set(this, `${site}List`, res.data);
  113. } else if (site === 'tzgg') {
  114. const res = await this.affairsNews({ skip, limit, column_id: column_id });
  115. for (const val of res.data) {
  116. const result = await this.affairsColumnInfo(val.column_id);
  117. val.column_name = result.data.name;
  118. }
  119. this.$set(this, `${site}List`, res.data);
  120. }
  121. },
  122. // 政策法规(所属科技政策,综合政策指导)
  123. async searchPolicy({ ...info } = {}) {
  124. const res = await this.policyColumnList({ ...info });
  125. for (const val of res.data) {
  126. this.zhzcdPolicy({ column_id: val.id, site: val.site });
  127. }
  128. },
  129. async zhzcdPolicy({ skip = 0, limit = 8, column_id, site } = {}) {
  130. if (site === 'zhzczd') {
  131. const res = await this.policyNews({ skip, limit, column_id: column_id });
  132. for (const val of res.data) {
  133. const result = await this.policyColumnInfo(val.column_id);
  134. val.column_name = result.data.name;
  135. }
  136. this.$set(this, `${site}List`, res.data);
  137. }
  138. },
  139. },
  140. };
  141. </script>
  142. <style lang="scss" scoped></style>