order-detail.vue
12.1 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<template>
<div>
<template v-if="show">
<div class="order-status">
<p v-if="order.is_cancel === 'Y'">交易已取消</p>
<p v-else>{{order.status | convertOrderState}}</p>
<p v-if="order.is_cancel !== 'Y' && order.status == 0 && order.pay_lefttime != 0">剩余: <span v-count-down="{leftTime: order.pay_lefttime}"></span>,订单将被取消</p>
</div>
<div class="order-address">
<p><span>{{order.user_name}}</span><span>{{order.mobile}}</span></p>
<p>{{order.area}} <br>{{order.address}}</p>
</div>
<div class="order-code">
<p>订单号: {{order.order_code}}</p>
<p>下单时间: {{order.create_time | convertTime}}</p>
</div>
<div class="order-goods">
<ul>
<li class="goods-info" v-for="(product, index) in order.order_goods" :key="index">
<a v-good-href.collect="product">
<div class="img-box">
<img v-img-src="{src: product.goods_image, width: 49, height: 65}">
<label v-if="product.goods_type === 'gift'">赠品</label>
<label class="price-gift" v-if="product.goods_type === 'price_gift'">加价购</label>
</div>
<div class="goods-detail">
<p class="name">{{product.product_name}}</p>
<p class="size">
<span>颜色:{{product.color_name}}</span>
<span>尺码:{{product.size_name}}</span>
</p>
</div>
<div class="goods-price">
<p>¥{{product.goods_price}}</p>
<p>×{{product.buy_number}}</p>
<p v-if="product.goods_status"><span class="goods-status">{{product.goods_status}}</span></p>
</div>
</a>
</li>
</ul>
</div>
<div class="order-amount">
<ul>
<li v-for="(promotion, index) in order.promotion_formulas" :key="index">
<label>{{promotion.promotion}}:</label><span>{{promotion.promotion_amount}}</span>
</li>
<li class="sum"><label>总计:</label><span>{{order.amount}}</span></li>
</ul>
</div>
<div class="order-button" v-show="order.status != 1 && order.status != 2 && order.status != 3">
<template v-if="order.is_cancel === 'Y'">
<button @click="deleteOrder(order.order_code)" class="leftpad">删除订单</button>
<button @click="readdOrder(order)" class="normal">再次购买</button>
</template>
<template v-else>
<button v-if="order.status == 0" @click="cancelOrder">取消订单</button>
<button v-if="order.status == 0 " class="countdown" @click="goBuy(order)">去支付 <span class="count-down" v-count-down="{leftTime: order.pay_lefttime, callback: autoCancel()}"></span></button>
<a v-if="order.status == 4 || order.status == 5 || order.status == 6" :href="`/me/logistic?order_code=${order.order_code}`">查看物流</a>
<button v-if="order.status == 4 || order.status == 5 " class="black" @click="confirmGoods(order.order_code)">确认收货</button>
<button v-if="order.is_support_refund == 'Y' || order.is_support_exchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button>
</template>
</div>
</template>
</div>
</template>
<script>
'use strict';
import $ from 'jquery';
import tip from 'common/tip';
import Modal from 'common/modal';
import yoho from 'yoho';
import interceptClick from 'common/intercept-click';
import genderSelect from 'common/select';
export default {
props: ['order_code'],
data() {
return {
show: false,
order: {},
genderSel: {}
};
},
created() {
this.updateNavBar();
this.getOrderData();
yoho.addNativeMethod('goToService', () => {
interceptClick.intercept('/me/service');
return false;
});
document.addEventListener('visibilitychange', () => {
if (!document.hidden) {
const cr = yoho.store.get('cancelReason');
if (cr && cr.iscancel) {
this.reasonChange(cr);
yoho.store.remove('cancelReason');
} else if (yoho.store.get('orderDetail')) {
this.reload();
}
}
});
},
methods: {
updateNavBar() {
const header = Object.assign({}, interceptClick.defaultTitleMap[2]);
header.title.des = '订单详情';
setTimeout(() => {
yoho.updateNavigationBar({
header: header
});
}, 200);
},
reload() {
this.show = false;
this.order = {};
this.getOrderData();
},
getOrderData() {
yoho.store.remove('orderDetail');
$.ajax({
url: '/me/get-order',
data: {
orderCode: this.order_code
}
}).then(result => {
if (result.code === 200) {
this.show = true;
this.order = result.data;
this.genderSel = genderSelect([{
key: this.order.is_support_refund,
val: this.order.is_support_refund === 'Y' ? '申请退货' : '申请退货(已过期限)',
url: '/me/return/refund?orderCode=' + this.order.order_code,
disabled: this.order.is_support_refund !== 'Y'
}, {
key: this.order.is_support_exchange,
val: this.order.is_support_exchange === 'Y' ? '申请换货' : '申请换货(已过期限)',
url: '/me/return/exchange?orderCode=' + this.order.order_code,
disabled: this.order.is_support_exchange !== 'Y'
}, {
key: 'onlineService',
val: '在线客服',
url: '/me/service'
}
]);
} else if (result.code !== 500) {
tip(result.message);
} else {
tip('数据获取失败');
}
}).fail(() => {
tip('网络错误');
});
},
reasonChange(cr) {
this.orderDetail().cancel({
orderCode: this.order.order_code,
reasonId: cr.id,
reason: cr.reason
}, (result) => {
if (result.code === 200) {
tip('取消成功');
this.order.is_cancel = 'Y';
yoho.store.set('orderReload', true);
} else if (result.code !== 500) {
tip(result.message);
}
}, () => {
tip('操作失败');
});
},
orderDetail() {
return {
cancel(param, success, fail) {
$.ajax({
url: '/me/cancelOrder',
type: 'post',
data: param
}).then(success).fail(fail);
}
};
},
autoCancel() {
return () => {
this.order.is_cancel = 'Y';
yoho.store.set('orderReload', true);
};
},
cancelOrder() {
Modal.confirm('', '取消后不能恢复,确认取消吗?', function() {
this.hide();
interceptClick.intercept('/me/order/cancelreason');
});
},
deleteOrder(code) {
Modal.confirm('', '确认删除订单?', function() {
this.hide();
$.ajax({
url: '/me/deleteOrder',
type: 'post',
data: {
orderCode: code
}
}).then(result => {
if (result.code === 200) {
yoho.goBack();
yoho.store.set('orderReload', true);
return false;
} else if (result.code !== 500) {
tip(result.message);
}
}).fail(() => {
tip('操作失败');
});
});
},
confirmGoods(code) {
let _this = this;
Modal.confirm('', '确认收货吗?', function() {
this.hide();
$.ajax({
url: '/me/confirmReceive',
type: 'post',
data: {
orderCode: code
}
}).then(result => {
if (result.code === 200) {
_this.reload();
yoho.store.set('orderReload', true);
} else if (result.code !== 500) {
tip(result.message);
}
}).fail(() => {
tip('操作失败');
});
});
},
goBuy(order) {
let orderDesc = [];
let goods = order.order_goods || [];
goods.forEach((g) => {
orderDesc.push(g.product_name);
});
yoho.goPay({
orderid: order.order_code,
amount: order.amount,
orderDesc: orderDesc.join(','),
type: 'orderDetail'
}, () => {
this.reload();
yoho.store.set('orderReload', true);
});
},
readdOrder(order) {
$.post('/me/readdorder', {
orderCode: order.order_code
}).then((result)=> {
tip({
txt: result.message,
delay: 1000
}, ()=> {
if (result.code === 200) {
if (yoho.goShopingKey && result.data && result.data.shopping_key) {
yoho.goShopingKey({shoppingKey: result.data.shopping_key});
}
yoho.goShopingCart();
}
});
});
},
applyRefund() {
this.genderSel.show(item => {
if (item.url) {
interceptClick.intercept(item.url);
}
return false;
});
}
}
};
</script>
<style>
@import "../../scss/me/_order-detail.css";
</style>