order-list.js
1.59 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
export default function() {
return {
namespaced: true,
state: {
page: 1,
pageSize: 10,
pagetotal: 0,
orderList: [], // 订单列表
// scroll 组件参数,是否触发上拉事件
pullUpLoad: true,
// 当前查询订单状态
currentStatus: 1,
routerParam: {},
},
mutations: {
setOrderList(state, res) {
let { page, pagetotal, data = [] } = res;
state.page = ++page;
state.pagetotal = pagetotal;
state.orderList = state.orderList.concat(data);
// 分页结束
if (page > pagetotal) {
state.pullUpLoad = false;
}
},
setOrderStatus(state, currentStatus) {
state.page = 1;
state.orderList = [];
state.pagetotal = 0;
state.pullUpLoad = true;
state.currentStatus = +currentStatus;
},
},
actions: {
/**
* 获取订单列表
* @param {*} param0 vue store context
* @param {
* owner: 订单来源
* status: 订单状态 默认全部
* }
* r
*/
async fetchOrderList(
{
commit,
state: { page },
},
param = {},
) {
const { owner, status = 1 } = param;
const res = await this.$api.get('/api/order/list', {
tabType: owner,
type: status,
page,
limit: 5,
// Todo 删除
uid: 600043484,
});
if (res.code === 200) {
commit('setOrderList', res.data);
}
},
},
getters: {},
};
}