orderaction.js
4.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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// src/components/order/orderaction.js
// import event from '../../utils/event.js';
import { formatTimeByMin } from '../../utils/index.js';
import { showDialog } from './orderActionUtil.js';
// import OrderActionService from './orderActionService.js';
// const DEL_ORDER = 'del_order';
const BUY_AGAIN = 'buy_again';
// const CANCEL_ORDER = 'cancel_order';
const NOW_BUY = 'now_buy';
// const CONFIRM_ORDER = 'confirm_order';//确认收货
// //订单操作接口
// const UFO_BUYER_DELETE_ORDER = 'ufo.buyer.delete';//删除订单
// const UFO_BUYER_CANCEL_ORDER = 'ufo.buyer.cancel';//取消订单
// const UFO_BUYER_CONFIRM_ORDER = 'ufo.buyer.confirm';//确认收货
// const api = new OrderActionService();
// var interval;
Component({
/**
* 组件的属性列表
*/
properties: {
buttons: Array,
//默认值:-1(不显示),0:订单列表,1:订单详情
// fromPage: Number,
timer: String,
realPrice: String,
orderCode:String,
productId:String,
},
/**
* 组件的初始数据
*/
data: {
lefttime:"",
lastIndex: 0,
interval:Object,
},
lifetimes: {
},
attached: function () {
let that = this;
if (that.data.buttons){
let lastIndex = that.data.buttons.length - 1;
console.log("lastIndex===" + lastIndex);
that.setData({ lastIndex: lastIndex });
}
if (that.data.timer) {
let leftTime = that.data.lefttime;
let timer = that.data.timer;
// if (interval){
// clearInterval(interval);
// }
if(timer > 0){
let interval = setInterval(() => {
timer = timer - 1;
leftTime = formatTimeByMin(timer, '00:00');
that.setData({
lefttime: leftTime,
timer: timer
});
}, 1000);
that.setData({ interval: interval});
}
}
},
detached: function () {
let interval = this.interval;
if (interval){
clearInterval(interval);
}
},
/**
* 组件的方法列表
*/
methods: {
onButtonClick: function(e){
let actionCode = e.currentTarget.dataset.buttonCode;
let orderCode = e.currentTarget.dataset.orderCode;
let productId = e.currentTarget.dataset.productId;
if (actionCode == BUY_AGAIN) {
wx.navigateTo({
url: '/pages/productDetail/index?id=' + productId,
})
} else if (actionCode == NOW_BUY){
console.log("== 去支付页面===")
wx.navigateTo({
//todo:
//url: '/pages/productDetail/index?id=' + productId,
})
}else {
showDialog(orderCode, actionCode, 0);
}
},
/**
* 订单操作
*/
// actionOrder: function (orderCode, method) {
// let that = this;
// wx.showLoading({
// title: '加载中...',
// })
// let params = {
// uid: '500031132',
// method: method,
// orderCode: orderCode,
// debug: 'XYZ',
// }
// api.actionOrder(params, () => {
// wx.hideLoading();
// }).then(data => {
// event.emit('refresh-order');
// });
// },
/**
* 确认Dialog
*/
// showDialog: function (orderCode, actionType, ) {
// let that = this;
// let content = '';
// let method = '';
// if (actionType == DEL_ORDER) {
// content = '您确定删除订单?';
// method = UFO_BUYER_DELETE_ORDER;
// } else if (actionType == CANCEL_ORDER) {
// content = '您确定取消订单?';
// method = UFO_BUYER_CANCEL_ORDER;
// } else if (actionType == CONFIRM_ORDER) {
// content = '您确定收货?';
// method = UFO_BUYER_CONFIRM_ORDER;
// }
// wx.showModal({
// // title: title,
// content: content,
// showCancel: true,
// cancelText: "确定",
// cancelColor: '#000000',
// confirmText: "取消",
// confirmColor: '#E0E0E0',
// success: function (res) {
// if (res.cancel) {
// that.actionOrder(orderCode, method);
// } else {
// //点击取消,默认隐藏弹框
// }
// },
// fail: function (res) { },
// complete: function (res) { },
// })
// }
}
})