|
|
import { get } from 'lodash';
|
|
|
import { getImgUrl } from '../../common/utils';
|
|
|
import {get} from 'lodash';
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
export default function() {
|
|
|
return {
|
|
|
namespaced: true,
|
|
|
state: {
|
|
|
productList: {
|
|
|
showErrorPage: false,
|
|
|
isFetching: false,
|
|
|
error: null,
|
|
|
page: 0, // 当前页
|
|
|
page_size: 10, // 每页数量
|
|
|
page_total: 0, // 总共多少页
|
|
|
total: 0, // 总共多少条
|
|
|
endReached: false, // 到达底部
|
|
|
list: [], // 商品列表
|
|
|
isEmpty: false,
|
|
|
},
|
|
|
searchParams: {
|
|
|
type: 0, // type:0,推荐;1,热销;2,即将发售; 3,品类; 4,品牌;5,系列;6,搜索 7, 收藏
|
|
|
order: null, // 指定排序
|
|
|
productPool: null, // 商品池id
|
|
|
sort: null, // 品类id
|
|
|
brand: null, // 品牌id
|
|
|
series: null, // 系列id
|
|
|
gender: null, // 性别
|
|
|
size: null, // 尺码id
|
|
|
isSoonSale: null, // 是否是即将售卖
|
|
|
query: null, // 搜索词
|
|
|
limit: null, // 每页记录数
|
|
|
page: null, // 当前页号
|
|
|
coupon_token: null, // 优惠券token
|
|
|
},
|
|
|
filterParams: {
|
|
|
sort: [], // 品类id
|
|
|
brand: [], // 品牌id
|
|
|
gender: [], // 性别
|
|
|
size: [], // 尺码id
|
|
|
},
|
|
|
filterData: [],
|
|
|
filterVisible: false,
|
|
|
},
|
|
|
mutations: {
|
|
|
addProductList(state, {data}) {
|
|
|
Vue.set(state.productList, 'list', state.productList.list.concat(data.product_list));
|
|
|
Vue.set(state.productList, 'page', data.page);
|
|
|
},
|
|
|
},
|
|
|
actions: {
|
|
|
async fetchProductList({commit, state}) {
|
|
|
let page = state.productList.page;
|
|
|
let size = state.productList.page_size;
|
|
|
const result = await this.$api.get('/api/ufo/list/productList', {
|
|
|
page: page + 1,
|
|
|
size: size
|
|
|
});
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
commit('addProductList', {data: result.data});
|
|
|
}
|
|
|
|
|
|
return result.data ? result.data.length : 0;
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
} |
...
|
...
|
|