myOrder.js
1.21 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
// pages/tab/mine/components/myOrder/myOrder.js
import { ORDER_STATUS, OrderStatusTypes } from "~/constants/mine.js";
Component({
/**
* 组件的属性列表
*/
properties: {
orderNumberList: Object,
},
/**
* 组件的初始数据
*/
data: {
orderList: Object.freeze(
Object.values(ORDER_STATUS).filter(
(item) => item.type == OrderStatusTypes.MY_ORDER
)
),
},
/**
* 组件生命周期
*/
lifetimes: {
attached() {
// 获取订单状态对应的图片
this.getOrderNumberList();
},
},
/**
* 组件的方法列表
*/
methods: {
goOrder(e) {
// 直接使用 ORDER_LIST 中的索引作为 tabIndex
const index = e.currentTarget.dataset.index;
wx.p.router.go("/packageMine/pages/order/index/index", {
index,
});
},
getOrderNumberList() {
const loginStatus = !wx.p.isLogin;
if (loginStatus) return;
wx.p.api.mineApi.getOrderNumberList().then((res) => {
this.setData({
orderNumberList: [
res.unPayCount,
res.unShippedCount,
res.unReceivedCount,
res.unServiceCount,
],
});
});
},
},
});