channel.js
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import Vue from 'vue';
import * as Types from './types';
export default function() {
return {
namespaced: true,
state: {
// channelData: [],
channelList: {
list: [], // 资源列表
productlist: [], // 资源列表
page: 0, // 当前页
page_size: 20, // 每页数量
page_total: 0, // 总共多少页
total: 0, // 总共多少条
scrollnavList: [], // 导航菜单
// scrollnavidList: [], // 导航菜单
current: 0,
},
},
mutations: {
[Types.FETCH_CHANNEL](state, { list }) {
state.channelList.list = list;
state.channelList.list.map(res => {
if (res.template_name === 'hotSeries') {
for (let i = 0; i < res.data.length; i++) {
state.channelList.scrollnavList.push(res.data[i].series_name);
}
}
});
},
[Types.FETCH_PRODUCT](state, { productlist }) {
console.log(state.channelList.productlist);
Vue.set(state.channelList, 'productlist', state.channelList.productlist.concat(productlist.product_list));
Vue.set(state.channelList, 'page', productlist.page);
},
},
actions: {
async fetchProductList({ commit, state }, obj) {
let page = obj && obj.isReset ? state.channelList.page = 1 : state.channelList.page + 1;
let size = state.channelList.page_size;
const result = await this.$api.get('/api/ufo/list/productList', {
page,
pageSize: size,
...obj,
});
if (result.code === 200) {
commit(Types.FETCH_PRODUCT, {productlist: result.data});
}
},
async fetchChannelList({ commit }) {
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;
}
}
},
};
}