123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <div id="question">
- <el-row>
- <el-col :span="24" class="question">
- <el-col :span="24" class="search">
- <van-search v-model="value" placeholder="请输入信息标题" @search="onSearch" />
- </el-col>
- <el-col :span="24" class="mess">
- <el-col :span="24" v-for="(item, index) in list" :key="index" class="list">
- <p class="title textOver">{{ item.title }}</p>
- <p>
- <span class="textOver">发布时间:{{ item.publish_time }}</span>
- <span class="textOver">来源:{{ item.orgin || '暂无' }}</span>
- </p>
- </el-col>
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- const { mapActions: column } = createNamespacedHelpers('column');
- const { mapActions: news } = createNamespacedHelpers('news');
- import { mapState, createNamespacedHelpers } from 'vuex';
- export default {
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- name: 'question',
- props: {},
- components: {},
- data: function() {
- return {
- //栏目列表
- columnList: [],
- colId: '',
- list: [],
- value: '',
- };
- },
- async created() {
- await this.search();
- await this.searchList();
- },
- methods: {
- ...column(['query', 'delete', 'update', 'create']),
- ...news({ newQuery: 'query' }),
- //查栏目
- async search() {
- const res = await this.query();
- if (this.$checkRes(res)) {
- this.$set(this, `columnList`, res.data);
- const colData = this.columnList.find(i => i.site == 'dcwj');
- this.colId = colData.id;
- }
- },
- //查列表
- async searchList() {
- const res = await this.newQuery({ column_id: this.colId });
- if (this.$checkRes(res)) {
- this.$set(this, `list`, res.data);
- // console.log(this.list);
- }
- },
- //搜索
- async onSearch({ ...info } = {}) {
- if (this.value) {
- info.title = this.value;
- info.column_id = this.colId;
- const res = await this.newQuery({ ...info });
- console.log(res.data);
- if (this.$checkRes(res)) {
- this.$set(this, `list`, res.data);
- }
- } else {
- this.searchList();
- }
- },
- },
- computed: {
- ...mapState(['user']),
- },
- watch: {},
- };
- </script>
- <style lang="less" scoped>
- .question {
- position: relative;
- .search {
- position: fixed;
- width: 100%;
- z-index: 999;
- border-bottom: 1px solid #ccc;
- background-color: #fff;
- .van-search {
- padding: 10px 12px 10px 12px;
- }
- }
- .mess {
- padding: 0px 10px;
- margin-top: 55px;
- .list {
- padding: 10px 0px;
- border-bottom: 1px dashed #ccc;
- .title {
- font-size: 18px;
- font-weight: bold;
- }
- p:nth-child(2) {
- margin-top: 5px;
- span {
- display: inline-block;
- width: 50%;
- height: 42px;
- line-height: 42px;
- color: #666;
- }
- }
- }
- }
- }
- </style>
|