|
|
import { get, set } from 'lodash';
|
|
|
import { getImgUrl } from '../../common/utils';
|
|
|
import Vue from 'vue';
|
|
|
// const uid = '500031170';
|
|
|
|
|
|
export default function() {
|
|
|
return {
|
...
|
...
|
@@ -10,43 +11,54 @@ export default function() { |
|
|
pageTotal: 0,
|
|
|
recId: '',
|
|
|
favoriteProductList: {
|
|
|
list: []
|
|
|
list:[]
|
|
|
},
|
|
|
isShowEmpty: false,
|
|
|
isMore: true,
|
|
|
},
|
|
|
mutations: {
|
|
|
addList(state, { data }) {
|
|
|
console.log(data);
|
|
|
if (data && data.product_list) {
|
|
|
console.log(data)
|
|
|
if(data && data.product_list){
|
|
|
// data.product_list.
|
|
|
let { page, product_list = [] } = data;
|
|
|
let isShowEmpty = page === 1 && product_list === 0;
|
|
|
// console.log("isShowEmpty:"+isShowEmpty)
|
|
|
// state.isShowEmpty = isShowEmpty
|
|
|
let list = state.favoriteProductList.list.concat(product_list);
|
|
|
Vue.set(state.favoriteProductList, 'list', list);
|
|
|
} else {
|
|
|
let { page, product_list = [], pageTotal } = data;
|
|
|
let isShowEmpty = page === 1 && product_list === 0;
|
|
|
// console.log("isShowEmpty:"+isShowEmpty)
|
|
|
// state.isShowEmpty = isShowEmpty
|
|
|
if(pageTotal > page){
|
|
|
state.isMore = true;
|
|
|
}
|
|
|
state.pageTotal = pageTotal;
|
|
|
state.page = page + 1;
|
|
|
|
|
|
let list = state.favoriteProductList.list.concat(product_list);
|
|
|
Vue.set(state.favoriteProductList, "list", list);
|
|
|
}else {
|
|
|
// state.isShowEmpty = true;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
errorData(state) {
|
|
|
errorData(state){
|
|
|
// console.log("error==isShowEmpty:")
|
|
|
state.isShowEmpty = true;
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
actions: {
|
|
|
async fetchFavoriteList({ commit }) {
|
|
|
const result = await this.$api.get('/api/ufo/home/favoriteProduct', {});
|
|
|
if (result.code === 200) {
|
|
|
let data = result.data;
|
|
|
commit('addList', { data: data });
|
|
|
} else {
|
|
|
// console.log("error=//=isShowEmpty:")
|
|
|
commit('errorData');
|
|
|
}
|
|
|
return result.data || [];
|
|
|
async fetchFavoriteList({ commit, state }) {
|
|
|
let page = state.page;
|
|
|
let limit = 20;
|
|
|
const result = await this.$api.get('/api/ufo/home/favoriteProduct', {page, limit});
|
|
|
if (result.code === 200) {
|
|
|
let data =result.data;
|
|
|
commit('addList', { data:data });
|
|
|
}else {
|
|
|
// console.log("error=//=isShowEmpty:")
|
|
|
commit('errorData');
|
|
|
}
|
|
|
return result.data || [];
|
|
|
// }else {
|
|
|
// return [];
|
|
|
// }
|
|
|
},
|
|
|
},
|
|
|
};
|
...
|
...
|
|