Authored by Tao

modify news

... ... @@ -29,7 +29,6 @@ export default {
console.log(item);
let { type, description } = item;
this.$router.push({name:'newsDetail',query: {type,description}})
this.$emit('clearStore',1);
}
}
};
... ...
... ... @@ -8,8 +8,7 @@
:data="newsList.list">
<div class="news-content">
<Tab
v-if="newsList.tabList.length > 0" :list="newsList.tabList"
@clearStore="clearStoreData"></Tab>
v-if="newsList.tabList.length > 0" :list="newsList.tabList"></Tab>
<List v-if="newsList.list.length > 0" :list="newsList && newsList.list || []"></List>
<UfoNoItem v-else :tip="`暂无数据`" style="margin-6op: 50px"></UfoNoItem>
</div>
... ... @@ -65,13 +64,6 @@ export default {
await this.fetchNewsList(params);
this.$refs.scroll.forceUpdate();
},
clearStoreData(index) {
console.log(index);
}
},
watch:{
// '$route':["fetchNewsList","fetchNewsTabList"]
},
components: {
Style,
... ...
... ... @@ -38,7 +38,6 @@ export default {
...mapState(['newsList','newsDeatilList']),
},
activated() {
console.log('111');
let params = {
type: this.type,
isPage: true
... ...
... ... @@ -53,8 +53,11 @@ export default function() {
const result = await this.$api.get('/api/ufo/channel/channelList', {
content_code: 'f788335b57b67c1711f255648c744dab',
});
console.log(result);
console.log("resultresultresult");
if (result.code === 200) {
commit(Types.FETCH_CHANNEL, { list: result.data });
return result.data;
}
}
... ...
... ... @@ -31,25 +31,35 @@ export default function() {
},
[Types.FETCH_NEWSDETAIL_LIST](state, { list }) {
console.log(list.page);
console.log("list.page");
state.newsDeatilList.list = list.page > 1 ? state.newsDeatilList.list.concat(list.list) : list.list;
state.newsDeatilList.page = list.page;
state.newsDeatilList.totalPage = list.totalPage;
list.page < list.totalPage ? state.newsDeatilList.isMoreData = true : state.newsDeatilList.isMoreData = false;
},
resPages(state, {page, isMoreData}) {
state.newsDeatilList.page = page;
state.newsDeatilList.isMoreData = isMoreData;
},
[Types.FETCH_NEWS_TAB_LIST](state, { list }) {
state.newsList.tabList = list;
},
},
actions: {
async fetchNewsList({ commit, state }, obj) {
let page = state.newsList.page + 1;
let limit = state.newsList.limit;
console.log(obj)
console.log("objobj")
let type = obj && obj.type;
let page = type ? state.newsDeatilList.page + 1 : state.newsList.page + 1;
let limit = state.newsList.limit;
let isPage = obj && obj.isPage;
// 页面跳转重置page页码
isPage ? page = 1 : state.newsList.page + 1;
if (isPage) {
page = 1;
}
const result = await this.$api.post('/api/ufo/home/newsList', {
page, type: type || '', limit
});
... ... @@ -59,8 +69,10 @@ export default function() {
res.createTime = moment(new Date(res.createTime * 1000)).format('YYYY.MM.DD HH:mm');
});
if (type) {
console.log('1');
commit(Types.FETCH_NEWSDETAIL_LIST, {list: result.data});
} else {
console.log('2');
commit(Types.FETCH_NEWS_LIST, {list: result.data});
}
}
... ...