123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="main">
- <el-col :span="24" class="top">
- <top topType="1" @search="search"></top>
- </el-col>
- <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
- <list :list="communityList" @detailBtn="detailBtn"></list>
- </el-col>
- <el-col :span="24" class="foot">
- <page limit="5" :total="total" @search="search"></page>
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import list from './parts/list.vue';
- import top from '@/layout/common/top.vue';
- import page from '@/layout/common/page.vue';
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: mapTopic } = createNamespacedHelpers('topic');
- export default {
- name: 'index',
- props: {},
- components: {
- list,
- top,
- page,
- },
- data: function() {
- return {
- clientHeight: '',
- communityList: [
- {
- content:
- '文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容文章内容',
- origin: '文章来源',
- renew_time: '2021-02-01 10:00:00',
- type: '0',
- imgUrl: [
- { name: '图片名称', url: require('@a/news1.jpg') },
- { name: '图片名称1', url: require('@a/news1.jpg') },
- ],
- fileUrl: require('@a/video1.mp4'),
- website: 'http://broadcast.waityou24.cn/platlive/home.html',
- read: 10,
- },
- ],
- total: 0,
- };
- },
- async created() {
- await this.search();
- },
- mounted() {
- let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 80;
- this.$set(this, `clientHeight`, clientHeight);
- },
- methods: {
- ...mapTopic(['query']),
- async search({ skip = 0, limit = 5, searchName, ...info } = {}) {
- if (searchName) info.content = searchName;
- let res = await this.query({ skip, limit, ...info });
- if (this.$checkRes(res)) {
- this.$set(this, `communityList`, res.data);
- this.$set(this, `total`, res.total);
- }
- },
- // 话题正文
- detailBtn(data) {
- this.$router.push({ path: '/community/detail', query: { id: data.id } });
- },
- },
- computed: {
- ...mapState(['user']),
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- watch: {
- test: {
- deep: true,
- immediate: true,
- handler(val) {},
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .main {
- .top {
- height: 40px;
- overflow: hidden;
- border-bottom: 1px solid #f1f1f1;
- }
- .info {
- overflow-x: hidden;
- overflow-y: auto;
- background-color: #f1f1f1;
- }
- .foot {
- height: 40px;
- overflow: hidden;
- border-top: 1px solid #f1f1f1;
- }
- }
- </style>
|