123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <template>
- <div id="index">
- <el-row>
- <el-col :span="24" class="style">
- <el-col :span="24" class="top">
- <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
- </el-col>
- <el-col :span="24" class="down">
- <el-col :span="24" class="search">
- <el-col :span="6" class="type">
- <el-select v-model="type" placeholder="请选择" clearable @change="typeChange">
- <el-option v-for="(item, index) in column" :key="index" :label="item.title" :value="item.id"> </el-option>
- </el-select>
- </el-col>
- <el-col :span="18" class="input">
- <van-search v-model="name" @search="onSearch" placeholder="请输入信息标题" />
- </el-col>
- </el-col>
- <el-col :span="24" class="data">
- <van-tabs v-model="active">
- <van-tab title="科技资讯">
- <kjzxList :list="kjzxLists" @detailBtn="detailBtn"></kjzxList>
- </van-tab>
- <van-tab title="工作动态">
- <kjzxList :list="gzdtLists" @detailBtn="detailBtn"></kjzxList>
- </van-tab>
- <van-tab title="通知通告">
- <kjzxList :list="tztgLists" @detailBtn="detailBtn"></kjzxList>
- </van-tab>
- <van-tab title="技术前沿">
- <kjzxList :list="jsqyLists" @detailBtn="detailBtn"></kjzxList>
- </van-tab>
- </van-tabs>
- </el-col>
- </el-col>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import { mapState, createNamespacedHelpers } from 'vuex';
- const { mapActions: journcolumn } = createNamespacedHelpers('journcolumn');
- const { mapActions: journnews } = createNamespacedHelpers('journnews');
- import NavBar from '@/layout/common/topInfo.vue';
- import footInfo from '@/layout/common/footInfo.vue';
- import kjzxList from './parts/kjzxList.vue';
- export default {
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- name: 'index',
- props: {},
- components: {
- NavBar,
- // footInfo,
- kjzxList,
- },
- data: function() {
- return {
- // 头部标题
- title: '',
- // meta为true
- isleftarrow: '',
- // 返回
- navShow: true,
- //菜单显示
- active: 0,
- //科技资讯
- kjzxLists: [],
- //科技动态
- gzdtLists: [],
- //通知通告
- tztgLists: [],
- //技术前沿
- jsqyLists: [],
- //栏目
- column: [],
- // 类型
- name: '',
- type: '',
- };
- },
- async created() {
- await this.searchColumn();
- await this.searchList();
- },
- methods: {
- ...journcolumn({ columnquery: 'query' }),
- ...journnews({ newsquery: 'query' }),
- async searchColumn() {
- const res = await this.columnquery();
- if (this.$checkRes(res)) {
- console.log(_.orderBy(res.data, ['meta.createdAt'], ['asc']));
- this.$set(this, `column`, _.orderBy(res.data, ['meta.createdAt'], ['asc']));
- }
- },
- async searchList() {
- let col = this.column.find(i => i.site == 'kjzx');
- if (col) {
- const res = await this.newsquery({ column_id: col.id });
- if (this.$checkRes(res)) {
- this.$set(this, `kjzxLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- }
- }
- let col2 = this.column.find(i => i.site == 'gzdt');
- if (col2) {
- const res = await this.newsquery({ column_id: col2.id });
- if (this.$checkRes(res)) {
- this.$set(this, `gzdtLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- }
- }
- let col3 = this.column.find(i => i.site == 'tztg');
- if (col3) {
- const res = await this.newsquery({ column_id: col3.id });
- if (this.$checkRes(res)) {
- this.$set(this, `tztgLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- }
- }
- let col4 = this.column.find(i => i.site == 'jsqy');
- if (col4) {
- const res = await this.newsquery({ column_id: col4.id });
- if (this.$checkRes(res)) {
- this.$set(this, `jsqyLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- }
- }
- },
- async search({ ...info } = {}) {
- info.column_id = this.type;
- if (this.name) {
- info.title = this.name;
- const res = await this.newsquery({ ...info });
- if (this.$checkRes(res)) {
- let col = this.column.find(i => i.id == this.type);
- if (col.site == 'kjzx') this.$set(this, `kjzxLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- else if (col.site == 'gzdt') this.$set(this, `gzdtLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- else if (col.site == 'tztg') this.$set(this, `tztgLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- else if (col.site == 'jsqy') this.$set(this, `jsqyLists`, _.orderBy(res.data, ['publish_time'], ['desc']));
- }
- } else {
- this.searchList();
- }
- },
- // 选择类型
- typeChange(value) {
- if (value) {
- this.active = '';
- this.$set(this, `type`, value);
- let index = this.column.findIndex(i => i.id == value);
- if (index) {
- this.$set(this, `active`, index);
- }
- }
- },
- // 输入框查询
- onSearch(data) {
- this.$set(this, `name`, data);
- if (this.type) {
- this.search();
- } else {
- this.$notify({
- message: '请选择信息类型',
- type: 'danger',
- });
- }
- },
- detailBtn(data) {
- this.$router.push({ path: '/journ/detail', query: { id: data.id } });
- },
- },
- computed: {
- ...mapState(['user']),
- },
- mounted() {
- this.title = this.$route.meta.title;
- this.isleftarrow = this.$route.meta.isleftarrow;
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- };
- </script>
- <style lang="less" scoped>
- .style {
- width: 100%;
- height: 100%;
- position: relative;
- background-color: #f9fafc;
- .down {
- position: relative;
- .search {
- position: fixed;
- width: 100%;
- z-index: 999;
- border-bottom: 1px solid #ccc;
- background-color: #fff;
- .type {
- /deep/.el-input__inner {
- border: none;
- padding: 0;
- height: 30px;
- line-height: 30px;
- }
- .el-select {
- padding: 10px 0px 0px 5px;
- }
- /deep/.el-input__icon {
- line-height: 30px;
- }
- }
- .input {
- .van-search {
- padding: 10px 12px 10px 0;
- }
- }
- }
- .data {
- position: absolute;
- width: 100%;
- top: 54px;
- background: #f9fafc;
- }
- }
- }
- .top {
- height: 46px;
- overflow: hidden;
- }
- .foot {
- position: absolute;
- bottom: 0;
- }
- /deep/.van-tabs__line {
- width: 60px;
- }
- </style>
|