index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-col :span="24" class="top">
  6. <top topType="1" @search="search"></top>
  7. </el-col>
  8. <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
  9. <list :list="communityList" @detailBtn="detailBtn"></list>
  10. </el-col>
  11. <el-col :span="24" class="foot">
  12. <page limit="5" :total="total" @search="search"></page>
  13. </el-col>
  14. </el-col>
  15. </el-row>
  16. </div>
  17. </template>
  18. <script>
  19. import list from './parts/list.vue';
  20. import top from '@/layout/common/top.vue';
  21. import page from '@/layout/common/page.vue';
  22. import { mapState, createNamespacedHelpers } from 'vuex';
  23. const { mapActions: mapTopic } = createNamespacedHelpers('topic');
  24. export default {
  25. name: 'index',
  26. props: {},
  27. components: {
  28. list,
  29. top,
  30. page,
  31. },
  32. data: function() {
  33. return {
  34. clientHeight: '',
  35. communityList: [
  36. {
  37. content:
  38. '文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容',
  39. origin: '文章来源',
  40. renew_time: '2021-02-01 10:00:00',
  41. type: '0',
  42. imgUrl: [
  43. { name: '图片名称', url: require('@a/news1.jpg') },
  44. { name: '图片名称1', url: require('@a/news1.jpg') },
  45. ],
  46. fileUrl: require('@a/video1.mp4'),
  47. website: 'http://broadcast.waityou24.cn/platlive/home.html',
  48. read: 10,
  49. },
  50. ],
  51. total: 0,
  52. };
  53. },
  54. async created() {
  55. await this.search();
  56. },
  57. mounted() {
  58. let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 80;
  59. this.$set(this, `clientHeight`, clientHeight);
  60. },
  61. methods: {
  62. ...mapTopic(['query']),
  63. async search({ skip = 0, limit = 5, searchName, ...info } = {}) {
  64. if (searchName) info.content = searchName;
  65. let res = await this.query({ skip, limit, ...info });
  66. if (this.$checkRes(res)) {
  67. this.$set(this, `communityList`, res.data);
  68. this.$set(this, `total`, res.total);
  69. }
  70. },
  71. // 话题正文
  72. detailBtn(data) {
  73. this.$router.push({ path: '/community/detail', query: { id: data.id } });
  74. },
  75. },
  76. computed: {
  77. ...mapState(['user']),
  78. },
  79. metaInfo() {
  80. return { title: this.$route.meta.title };
  81. },
  82. watch: {
  83. test: {
  84. deep: true,
  85. immediate: true,
  86. handler(val) {},
  87. },
  88. },
  89. };
  90. </script>
  91. <style lang="less" scoped>
  92. .main {
  93. .top {
  94. height: 40px;
  95. overflow: hidden;
  96. border-bottom: 1px solid #f1f1f1;
  97. }
  98. .info {
  99. overflow-x: hidden;
  100. overflow-y: auto;
  101. background-color: #f1f1f1;
  102. }
  103. .foot {
  104. height: 40px;
  105. overflow: hidden;
  106. border-top: 1px solid #f1f1f1;
  107. }
  108. }
  109. </style>