1
|
-// src/components/order/orderButton.js
|
|
|
2
|
-import OrderActionService from './orderActionService.js';
|
|
|
3
|
-const DEL_ORDER = 'del_order';
|
|
|
4
|
-const BUY_AGAIN = 'buy_again';
|
|
|
5
|
-const CANCEL_ORDER = 'cancel_order';
|
|
|
6
|
-const NOW_BUY = 'now_buy';
|
|
|
7
|
-//订单操作接口
|
|
|
8
|
-const UFO_BUYER_DELETE_ORDER = 'ufo.buyer.delete';
|
|
|
9
|
-const UFO_BUYER_CANCEL_ORDER = 'ufo.buyer.cancel';
|
|
|
10
|
-const api = new OrderActionService();
|
|
|
11
|
-Component({
|
|
|
12
|
- /**
|
|
|
13
|
- * 组件的属性列表
|
|
|
14
|
- */
|
|
|
15
|
- properties: {
|
|
|
16
|
- button: Object,
|
|
|
17
|
- cIndex: Number,
|
|
|
18
|
- lastIndex: Number,
|
|
|
19
|
- isLast: Boolean,
|
|
|
20
|
- orderCode: String,
|
|
|
21
|
-
|
|
|
22
|
- },
|
|
|
23
|
-
|
|
|
24
|
- /**
|
|
|
25
|
- * 组件的初始数据
|
|
|
26
|
- */
|
|
|
27
|
- data: {
|
|
|
28
|
- isSelected: false,
|
|
|
29
|
-
|
|
|
30
|
- },
|
|
|
31
|
-
|
|
|
32
|
- lifetimes: {
|
|
|
33
|
-
|
|
|
34
|
- },
|
|
|
35
|
-
|
|
|
36
|
- attached: function () {
|
|
|
37
|
- let that = this;
|
|
|
38
|
- // let buttonInfo = that.button;
|
|
|
39
|
- // let code = buttonInfo.code;
|
|
|
40
|
- console.log(that.cIndex + "====orderCode===" + that.orderCode + "===" +that.isLast);
|
|
|
41
|
- // let sum = that.id + 1;
|
|
|
42
|
- // if (that.length === sum){
|
|
|
43
|
- // that.setData({isSelected : true});
|
|
|
44
|
- // }
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
- },
|
|
|
48
|
-
|
|
|
49
|
- /**
|
|
|
50
|
- * 组件的方法列表
|
|
|
51
|
- */
|
|
|
52
|
- methods: {
|
|
|
53
|
- onButtonClick: function (e) {
|
|
|
54
|
- let actionCode = e.currentTarget.dataset.buttonCode;
|
|
|
55
|
- let orderCode = e.currentTarget.dataset.orderCode;
|
|
|
56
|
- let productId = e.currentTarget.dataset.productId;
|
|
|
57
|
-
|
|
|
58
|
- if (actionCode == BUY_AGAIN) {
|
|
|
59
|
- wx.navigateTo({
|
|
|
60
|
- url: '/pages/productDetail/index?id=' + productId,
|
|
|
61
|
- })
|
|
|
62
|
- } else if (actionCode == NOW_BUY) {
|
|
|
63
|
- console.log("== 去支付页面===")
|
|
|
64
|
- wx.navigateTo({
|
|
|
65
|
- //todo:
|
|
|
66
|
-
|
|
|
67
|
- //url: '/pages/productDetail/index?id=' + productId,
|
|
|
68
|
- })
|
|
|
69
|
- } else {
|
|
|
70
|
- this.triggerEvent('buttonClick', actionCode)
|
|
|
71
|
- // this.showDialog(orderCode, actionCode);
|
|
|
72
|
- }
|
|
|
73
|
-
|
|
|
74
|
- },
|
|
|
75
|
- /**
|
|
|
76
|
- * 订单操作
|
|
|
77
|
- */
|
|
|
78
|
- actionOrder: function (orderCode, method) {
|
|
|
79
|
- let that = this;
|
|
|
80
|
- wx.showLoading({
|
|
|
81
|
- title: '加载中...',
|
|
|
82
|
- })
|
|
|
83
|
- let params = {
|
|
|
84
|
- uid: '500031132',
|
|
|
85
|
- method: method,
|
|
|
86
|
- orderCode: orderCode,
|
|
|
87
|
- debug: 'XYZ',
|
|
|
88
|
- }
|
|
|
89
|
- api.actionOrder(params, () => {
|
|
|
90
|
- wx.hideLoading();
|
|
|
91
|
- }).then(data => {
|
|
|
92
|
- event.emit('refresh-order');
|
|
|
93
|
- });
|
|
|
94
|
- },
|
|
|
95
|
- /**
|
|
|
96
|
- * 确认Dialog
|
|
|
97
|
- */
|
|
|
98
|
- showDialog: function (orderCode, actionType, ) {
|
|
|
99
|
- let that = this;
|
|
|
100
|
- let content = '';
|
|
|
101
|
- let method = '';
|
|
|
102
|
- if (actionType == DEL_ORDER) {
|
|
|
103
|
- content = '您确定删除订单?';
|
|
|
104
|
- method = UFO_BUYER_DELETE_ORDER;
|
|
|
105
|
- } else if (actionType == CANCEL_ORDER) {
|
|
|
106
|
- content = '您确定取消订单?';
|
|
|
107
|
- method = UFO_BUYER_CANCEL_ORDER;
|
|
|
108
|
-
|
|
|
109
|
- }
|
|
|
110
|
- wx.showModal({
|
|
|
111
|
- // title: title,
|
|
|
112
|
- content: content,
|
|
|
113
|
- showCancel: true,
|
|
|
114
|
- cancelText: "确定",
|
|
|
115
|
- cancelColor: '#000000',
|
|
|
116
|
- confirmText: "取消",
|
|
|
117
|
- confirmColor: '#E0E0E0',
|
|
|
118
|
- success: function (res) {
|
|
|
119
|
- if (res.cancel) {
|
|
|
120
|
- that.actionOrder(orderCode, method);
|
|
|
121
|
- } else {
|
|
|
122
|
- //点击取消,默认隐藏弹框
|
|
|
123
|
- }
|
|
|
124
|
- },
|
|
|
125
|
- fail: function (res) { },
|
|
|
126
|
- complete: function (res) { },
|
|
|
127
|
- })
|
|
|
128
|
-
|
|
|
129
|
- }
|
|
|
130
|
-
|
|
|
131
|
- }
|
|
|
132
|
-}) |
|
|