order-detail.vue
9.55 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
<template>
<div class="order-status">
<p>{{order.status | convertOrderState}}</p>
<p v-if="order.status == 0 && order.payLefttime != 0">剩余: <span v-count-down v-bind:left-time="order.payLefttime"></span>,订单将被取消</p>
</div>
<div class="order-address">
<p><span>{{order.userName}}</span><span>{{order.mobile}}</span></p>
<p>{{order.area}} <br>{{order.address}}</p>
</div>
<div class="order-code">
<p>订单号:{{order.orderCode}}</p>
<p>下单时间:{{order.createTime | convertTime}}</p>
</div>
<div class="order-goods">
<ul>
<li class="goods-info" v-for="product in order.orderGoods">
<div class="img-box">
<img v-bind:src="product.goodsImage | resize 49 65" alt="">
<!--<label>赠品</label>-->
</div>
<div class="goods-detail">
<p class="name">{{product.productName}}</p>
<p class="size">
<span>颜色:{{product.colorName}}</span>
<span>尺码:{{product.sizeName}}</span>
</p>
</div>
<div class="goods-price">
<p>¥{{product.goodsPrice}}</p>
<p>×{{product.buyNumber}}</p>
</div>
</li>
</ul>
</div>
<div class="order-amount">
<ul>
<li v-for="promotion in order.promotionFormulas">
<label>{{promotion.promotion}}:</label><span>{{promotion.promotionAmount}}</span>
</li>
<li><label>总计:</label><span>{{order.amount}}</span></li>
</ul>
</div>
<div class="order-button" v-show="order.status != 1 && order.status != 2 && order.status != 3">
<button v-if="order.status == 0" @click="cancelOrder(order.orderCode)">取消订单</button>
<button v-if="order.status == 0 " class="countdown" @click="goBuy(order.orderCode)">去支付 <span v-count-down v-bind:left-time="order.payLefttime" v-bind:callback="autoCancel(order.orderCode)"></span></button>
<button v-if="order.status == 4 || order.status == 5 " @click="seeExpress(order.orderCode)">查看物流</button>
<button v-if="order.status == 4 || order.status == 5 " class="black" @click="confirmGoods(order.orderCode)">确认收货</button>
<button v-if="order.status == 6" @click="deleteOrder(order,index)">删除订单</button>
<button v-if="order.status == 6" class="normal">再次购买</button>
<button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button>
</div>
<select id="cancel-reason" class="cancel-reason" v-on:change="reasonChange" v-model="selected">
<option v-for="option in options" v-bind:value="{id:option.id}">{{option.reason}}</option>
</select>
</template>
<script>
'use strict';
const $ = require('jquery');
const tip = require('common/tip');
const Modal = require('common/modal');
const yohoAPI = require('yoho');
let genderSel = require('common/select');
module.exports = {
data() {
return {
order: {},
options: [],
selected: null
};
},
ready() {
this.getOrderData();
},
methods: {
getOrderData() {
$.ajax({
url: '/me/get-order',
data: {
orderCode: this.$parent.$data.orderCode
}
}).then(result => {
if (result.code === 200) {
this.$set('order', result.data);
genderSel = genderSel([
{
key: this.order.isSupportRefund,
val: this.order.isSupportRefund === 'Y' ? '申请退货' : '<span class="overdue">申请退货(已过期限)</span>',
url: '/me/return/refund?orderCode=' + this.order.orderCode,
disabled: this.order.isSupportRefund !== 'Y'
},
{
key: this.order.isSupportExchange,
val: this.order.isSupportExchange === 'Y' ? '申请换货' : '<span class="overdue">申请换货(已过期限)</span>',
url: '/me/return/exchange?orderCode=' + this.order.orderCode,
disabled: this.order.isSupportExchange !== 'Y'
},
{
key: 'onlineService',
val: '在线客服'
}
]);
if (Number(this.order.status) === 0) {
this.getCancelReason();
}
} else {
tip(result.message);
}
}).fail(() => {
tip('网络错误');
});
},
reasonChange() {
this.orderDetail().cancel({
orderCode: this.order.orderCode,
reasonId: this.selected.id
}, (result) => {
if (result.code === 200) {
location.reload();
} else {
tip(result.message);
}
}, () => {
tip('操作失败');
});
},
getCancelReason() {
let that = this;
$.ajax({
url: '/me/getCancelOrderReason',
}).then(result => {
if (result.data.length > 0) {
that.options = result.data;
}
}).fail(() => {
tip('操作失败');
});
},
orderDetail() {
return {
cancel(param, success, fail) {
$.ajax({
url: '/me/cancelOrder',
type: 'post',
data: param
}).then(success).fail(fail);
}
};
},
autoCancel(code) {
let _that = this;
return () => {
_that.orderDetail({
orderCode: code
}).cancel({orderCode: code}, (result) => {
if (result.code === 200) {
location.href = '/me/order?type=2';
}
});
};
},
cancelOrder() {
let _that = this;
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
this.hide();
_that.dropDown('cancel-reason');
});
},
deleteOrder(code) {
Modal.confirm('确认删除订单?', '', function() {
this.hide();
$.ajax({
url: '/me/deleteOrder',
type: 'post',
data: {
orderCode: code
}
}).then(result => {
if (result.code === 200) {
location.href = '/me/order';
} else {
tip(result.message);
}
}).fail(() => {
tip('操作失败');
});
});
},
confirmGoods(code) {
$.ajax({
url: '/me/confirmReceive',
type: 'post',
data: {
orderCode: code
}
}).then(result => {
if (result.code === 200) {
location.reload();
} else {
tip(result.message);
}
}).fail(() => {
tip('操作失败');
});
},
goBuy(code) {
yohoAPI.goPay({orderid: code});
},
seeExpress(code) {
location.href = '/me/logistic?order_code=' + code;
},
/**
* 申请售后
*/
applyRefund() {
genderSel.show(function(item) {
console.log(item);
return; // todo
location.href = item.url;
});
},
dropDown(elementId) {
let dropdown = document.getElementById(elementId);
try {
this.showDropdown(dropdown);
} catch(e) {
console.log(e)
}
return false;
},
showDropdown(element) {
let event;
event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
}
}
};
</script>
<style>
@import "../../scss/me/_order-detail.css";
</style>