favorite.js
966 Bytes
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
import { get, set } from 'lodash';
import { getImgUrl } from '../../common/utils';
import Vue from 'vue';
const uid = '500031170';
export default function() {
return {
namespaced: true,
state: {
page: 1,
pageTotal: 0,
recId: '',
favoriteProductList: {
list:[]
},
},
mutations: {
addList(state, { data }) {
console.log(data)
if(data && data.product_list){
// data.product_list.
let list = state.favoriteProductList.list.concat(data.product_list);
Vue.set(state.favoriteProductList, "list", list);
}
},
},
actions: {
async fetchFavoriteList({ commit }) {
const result = await this.$api.get('/api/ufo/home/favoriteProduct', {uid});
if (result.code === 200) {
let data =result.data;
commit('addList', { data:data });
}
return result.data || [];
},
},
};
}