|
|
import Vue from 'vue';
|
|
|
import * as Types from './types';
|
|
|
import { get, set } from 'lodash';
|
|
|
import { getImgUrl } from '../../common/utils';
|
|
|
|
|
|
export default function() {
|
|
|
return {
|
|
|
namespaced: true,
|
|
|
state: {
|
|
|
channelData: [],
|
|
|
// channelData: [],
|
|
|
channelList: {
|
|
|
list: [], // 资源列表
|
|
|
productlist: [], // 资源列表
|
|
|
page: 0, // 当前页
|
|
|
page_size: 10, // 每页数量
|
|
|
page_total: 0, // 总共多少页
|
|
|
total: 0, // 总共多少条
|
|
|
scrollnavList: [], // 导航菜单
|
|
|
// scrollnavidList: [], // 导航菜单id
|
|
|
},
|
|
|
},
|
|
|
mutations: {
|
|
|
[Types.FETCH_CHANNEL](state, { list }) {
|
|
|
state.channelData = 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);
|
|
|
// state.channelList.scrollnavidList.push(res.data[i].series_id);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
[Types.FETCH_PRODUCT](state, { productlist }) {
|
|
|
// state.channelList.productlist = 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 }) {
|
|
|
let page = state.channelList.page;
|
|
|
let size = state.channelList.page_size;
|
|
|
const result = await this.$api.get('/api/ufo/list/productList', {
|
|
|
page: page + 1,
|
|
|
size,
|
|
|
});
|
|
|
|
|
|
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: '9cb6138be8e60c96f48107da481816c3',
|
|
|
uid: '64668089',
|
|
|
});
|
|
|
if (result.code === 200) {
|
|
|
result.data.map(res => {
|
|
|
// 焦点图
|
|
|
if(res.template_name === 'focus') {
|
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
|
let url = "https:" + getImgUrl(get(res.data[i], "src") || '', 750, 200);
|
|
|
set(res.data[i], "src", url);
|
|
|
}
|
|
|
}
|
|
|
// 热门系列
|
|
|
if(res.template_name === 'hotSeries') {
|
|
|
for (let i = 0; i < res.data.length; i++) {
|
|
|
let url = "https:" + getImgUrl(get(res.data[i], "image_url") || '', 100, 80);
|
|
|
set(res.data[i], "image_url", url);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
console.log(result.data);
|
|
|
commit(Types.FETCH_CHANNEL, { list: result.data });
|
|
|
}
|
|
|
}
|
...
|
...
|
|