skupList.js
1.97 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import Vue from 'vue';
export default function() {
return {
namespaced: true,
state: {
page: 1,
pageTotal: 0,
skupList: {
list: []
},
isMore: false,
isShowEmpty: false
},
mutations: {
addList(state, { data, isReset }) {
if (data && data.skup_list) {
let { page, skup_list = [], page_total } = data;
if (page_total > page) {
state.isMore = true;
state.pageTotal = page_total;
state.page = page + 1;
} else {
state.isMore = false;
}
if (isReset) {
state.skupList.list = skup_list;
} else {
let list = state.skupList.list.concat(skup_list);
Vue.set(state.skupList, 'list', list);
}
}
},
errorData(state) {
state.isShowEmpty = true;
}
},
actions: {
async fetchSecondSkupList({ commit, state }, {isReset} = {}) {
let page = 1;
if (isReset) {
page = 1;
} else {
page = state.page;
}
let limit = 10;
const result = await this.$api.get('/api/ufo/secondhand/skupList', {page, limit});
if (result.code === 200) {
let data = result.data;
commit('addList', { data, isReset });
} else {
commit('errorData');
}
return result.data || [];
},
// 查询二手/瑕疵商品列表
async fetchSecondProductList({commit, state}, params) {
let result = await this.$api.get('/api/ufo/list/productList', {
...params
});
return result;
},
// 查询二手/瑕疵筛选列表
async fetchSecondFilterData() {
let result = await this.$api.get('/api/ufo/secondhand/filterData', {});
if (result.code === 200) {
let {data} = result;
return data.filter;
} else {
return [];
}
},
},
};
}