order-action.js
4.84 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
174
/* eslint-disable space-before-function-paren */
import { createNamespacedHelpers } from 'vuex';
const { mapActions } = createNamespacedHelpers('order/orderList');
import { orderActionsMap, ownType } from 'constants/order-constants';
export default {
data() {
return {
isMixin: true,
};
},
methods: {
...mapActions(['cancelTradeConfirmInfo', 'cancelTrade', 'deleteOrder']),
async onSellerOrderAction({ action, order }) {
const { owner = ownType.SELL } = this.$route.params;
const { orderCode, earnestMoney } = order;
switch (action.name) {
case orderActionsMap.DEL_ORDER.name: {
this.deleteOrderConfirmDialog({ orderCode, owner });
break;
}
case orderActionsMap.NOT_SOLD.name: {
const confirmInfo = await this.cancelTradeConfirmInfo({
orderCode,
owner,
});
this.$createConfirmDialog({
content: confirmInfo.confirmDesc,
confirmBtn: {
text: '不卖了',
style: { color: '#D0021B' },
},
cancelBtn: { text: '继续出售', active: true },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner,
});
if (isOk) {
this.fetchOrderDetail(this.$route.params);
}
// const txt = isOk ? "取消成功" : "取消失败";
// this.$createToast({ txt, type: "txt" }).show();
},
}).show();
break;
}
case orderActionsMap.PAY_EARNESTMONEY.name: {
this.$createOrderPayType({
orderCode,
price: earnestMoney,
desc: '保证金',
// 支付成功会跳route
extra: JSON.stringify({
back: {
name: 'sellOrderDetail',
params: { owner, orderCode },
},
}),
}).show();
break;
}
default:
return;
}
},
async onBuyerOrderAction({ action, order }) {
const { owner = ownType.SELL } = this.$route.params;
const { orderCode, priceInfo = {} } = order;
switch (action.name) {
case orderActionsMap.DEL_ORDER.name: {
this.deleteOrderConfirmDialog({ orderCode, owner });
break;
}
case orderActionsMap.CANCEL_ORDER.name: {
const confirmInfo = await this.cancelTradeConfirmInfo({
orderCode,
owner,
});
this.$createConfirmDialog({
content: confirmInfo.confirmDesc,
confirmBtn: { text: '取消订单', style: { color: '#D0021B' } },
cancelBtn: { text: '保留订单', active: true },
onConfirm: async () => {
const isOk = await this.cancelTrade({
orderCode,
owner,
});
if (isOk) {
this.fetchOrderDetail(this.$route.params);
}
const txt = isOk ? '取消成功' : '取消失败';
this.$createToast({ txt, type: 'txt' }).show();
},
}).show();
break;
}
case orderActionsMap.NOW_BUY.name: {
this.$createOrderPayType({
orderCode,
price: parseFloat(priceInfo.realPayPrice || ''),
desc: '',
extra: JSON.stringify({
back: {
name: 'buyOrderDetail',
params: {
owner,
orderCode,
},
},
}),
}).show();
break;
}
case orderActionsMap.CONFIRM_DELIVERY.name: {
this.$createConfirmDialog({
onConfirm: async () => {
const isOk = await this.confirmReceipt({
orderCode,
owner,
});
if (isOk) {
this.fetchOrderDetail(this.$route.params);
}
// const txt = isOk ? "收货成功" : "收货失败";
// this.$createToast({ txt, type: "txt" }).show();
},
});
break;
}
default:
return;
}
},
// 删除订单
deleteOrderConfirmDialog({ orderCode, owner }) {
this.$createConfirmDialog({
type: 'confirm',
content: '确认删除订单?',
confirmBtn: { style: { color: '#D0021B' } },
onConfirm: async () => {
const isOk = await this.deleteOrder({
orderCode,
owner,
});
if (isOk) {
this.$router.back();
}
// const txt = isOk ? "删除成功" : "删除失败";
// this.$createToast({ txt, type: "txt" }).show();
},
}).show();
},
},
};