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