Showing
7 changed files
with
170 additions
and
43 deletions
@@ -79,8 +79,8 @@ const order = { | @@ -79,8 +79,8 @@ const order = { | ||
79 | let orderCode = req.body.orderCode; | 79 | let orderCode = req.body.orderCode; |
80 | let reasonId = req.body.reasonId; | 80 | let reasonId = req.body.reasonId; |
81 | let reason = req.body.reason; | 81 | let reason = req.body.reason; |
82 | - | ||
83 | - orderModel.cancelOrder(orderCode, reasonId, reason).then(result => { | 82 | + console.log(orderCode+'------'+reasonId); |
83 | + orderModel.cancelOrder(orderCode, reasonId, reason, isBLK).then(result => { | ||
84 | return res.json(result); | 84 | return res.json(result); |
85 | }); | 85 | }); |
86 | 86 | ||
@@ -160,6 +160,17 @@ const order = { | @@ -160,6 +160,17 @@ const order = { | ||
160 | }).then(result => { | 160 | }).then(result => { |
161 | res.json(result); | 161 | res.json(result); |
162 | }); | 162 | }); |
163 | + }, | ||
164 | + | ||
165 | + /** | ||
166 | + * 获取退换货原因 | ||
167 | + * @param req | ||
168 | + * @param res | ||
169 | + */ | ||
170 | + getCancelReason: (req, res) => { | ||
171 | + orderModel.getCancelReason().then(result => { | ||
172 | + return res.json(result); | ||
173 | + }); | ||
163 | } | 174 | } |
164 | }; | 175 | }; |
165 | 176 |
@@ -43,18 +43,20 @@ exports.getOrderDetail = (uid, orderCode) => { | @@ -43,18 +43,20 @@ exports.getOrderDetail = (uid, orderCode) => { | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | * 取消订单 | 45 | * 取消订单 |
46 | - * @param orderCode | ||
47 | - * @param reasonId | ||
48 | - * @param reason | 46 | + * @param orderCode 订单号 |
47 | + * @param reasonId 原因id | ||
48 | + * @param reason 原因描述 | ||
49 | + * @param appType 0:yohobuy 1:blk(blk必传) | ||
49 | * @returns {Promise.<T>|*} | 50 | * @returns {Promise.<T>|*} |
50 | */ | 51 | */ |
51 | -exports.cancelOrder = (orderCode, reasonId, reason) => { | 52 | +exports.cancelOrder = (orderCode, reasonId, reason, appType) => { |
52 | 53 | ||
53 | return api.post('', { | 54 | return api.post('', { |
54 | method: 'app.SpaceOrders.close', | 55 | method: 'app.SpaceOrders.close', |
55 | order_code: orderCode, | 56 | order_code: orderCode, |
56 | reason_id: reasonId, | 57 | reason_id: reasonId, |
57 | - reason: reason | 58 | + reason: reason, |
59 | + app_type: appType | ||
58 | }).then(result => { | 60 | }).then(result => { |
59 | return result; | 61 | return result; |
60 | }); | 62 | }); |
@@ -148,3 +150,13 @@ exports.getCoinDetail = (uid, page, limit) => { | @@ -148,3 +150,13 @@ exports.getCoinDetail = (uid, page, limit) => { | ||
148 | method: 'app.yohocoin.lists' | 150 | method: 'app.yohocoin.lists' |
149 | }).then(camelCase); | 151 | }).then(camelCase); |
150 | }; | 152 | }; |
153 | + | ||
154 | +/** | ||
155 | + * 获取退换货原因 | ||
156 | + * @returns {*|Promise.<T>} | ||
157 | + */ | ||
158 | +exports.getCancelReason = () => { | ||
159 | + return api.get('', { | ||
160 | + method: 'app.SpaceOrders.closeReasons' | ||
161 | + }).then(camelCase); | ||
162 | +}; |
@@ -24,6 +24,7 @@ router.get('/order-detail', order.orderDetail); // 订单详情 | @@ -24,6 +24,7 @@ router.get('/order-detail', order.orderDetail); // 订单详情 | ||
24 | router.get('/get-orders', order.getOrderData); // 获取订单数据 | 24 | router.get('/get-orders', order.getOrderData); // 获取订单数据 |
25 | router.get('/get-order', order.getOrderDetailData); // 获取订单详情数据 | 25 | router.get('/get-order', order.getOrderDetailData); // 获取订单详情数据 |
26 | router.get('/order-detail', order.orderDetail); // 订单详情 | 26 | router.get('/order-detail', order.orderDetail); // 订单详情 |
27 | +router.get('/order/cancel-reason', order.getCancelReason); // 获取订单原因 | ||
27 | router.post('/cancel-order', order.cancelOrder); // 取消订单 | 28 | router.post('/cancel-order', order.cancelOrder); // 取消订单 |
28 | router.post('/delete-order', order.deleteOrder); // 删除订单 | 29 | router.post('/delete-order', order.deleteOrder); // 删除订单 |
29 | router.post('/confirm-order', order.confirmOrder); // 确认订单 | 30 | router.post('/confirm-order', order.confirmOrder); // 确认订单 |
@@ -49,6 +49,9 @@ | @@ -49,6 +49,9 @@ | ||
49 | <button v-if="order.status == 6" class="normal">再次购买</button> | 49 | <button v-if="order.status == 6" class="normal">再次购买</button> |
50 | <button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button> | 50 | <button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button> |
51 | </div> | 51 | </div> |
52 | + <select id="cancel-reason" class="cancel-reason" v-on:change="reasonChange" v-model="selected"> | ||
53 | + <option v-for="option in options" v-bind:value="{id:option.id}">{{option.reason}}</option> | ||
54 | + </select> | ||
52 | </template> | 55 | </template> |
53 | <script> | 56 | <script> |
54 | 'use strict'; | 57 | 'use strict'; |
@@ -62,7 +65,9 @@ | @@ -62,7 +65,9 @@ | ||
62 | module.exports = { | 65 | module.exports = { |
63 | data() { | 66 | data() { |
64 | return { | 67 | return { |
65 | - order: {} | 68 | + order: {}, |
69 | + options: [], | ||
70 | + selected: null | ||
66 | }; | 71 | }; |
67 | }, | 72 | }, |
68 | ready() { | 73 | ready() { |
@@ -96,6 +101,9 @@ | @@ -96,6 +101,9 @@ | ||
96 | val: '在线客服' | 101 | val: '在线客服' |
97 | } | 102 | } |
98 | ]); | 103 | ]); |
104 | + if (this.order.status == 0) { | ||
105 | + this.getCancelReason(); | ||
106 | + } | ||
99 | } else { | 107 | } else { |
100 | tip(result.message); | 108 | tip(result.message); |
101 | } | 109 | } |
@@ -103,15 +111,40 @@ | @@ -103,15 +111,40 @@ | ||
103 | tip('网络错误'); | 111 | tip('网络错误'); |
104 | }); | 112 | }); |
105 | }, | 113 | }, |
114 | + reasonChange(){ | ||
115 | + this.orderDetail().cancel({ | ||
116 | + orderCode: this.order.orderCode, | ||
117 | + reasonId: this.selected.id | ||
118 | + }, (result) => { | ||
119 | + if (result.code === 200) { | ||
120 | + location.reload(); | ||
121 | + } else { | ||
122 | + tip(result.message); | ||
123 | + } | ||
124 | + }, () => { | ||
125 | + tip('操作失败'); | ||
126 | + }); | ||
127 | + }, | ||
128 | + getCancelReason() { | ||
129 | + let that = this; | ||
130 | + | ||
131 | + $.ajax({ | ||
132 | + url: '/home/order/cancel-reason', | ||
133 | + }).then(result => { | ||
134 | + if (result.data.length > 0) { | ||
135 | + that.options = result.data; | ||
136 | + } | ||
137 | + }).fail(() => { | ||
138 | + tip('操作失败'); | ||
139 | + }); | ||
140 | + }, | ||
106 | orderDetail() { | 141 | orderDetail() { |
107 | return { | 142 | return { |
108 | - cancel(code, success, fail) { | 143 | + cancel(param, success, fail) { |
109 | $.ajax({ | 144 | $.ajax({ |
110 | url: '/home/cancel-order', | 145 | url: '/home/cancel-order', |
111 | type: 'post', | 146 | type: 'post', |
112 | - data: { | ||
113 | - orderCode: code | ||
114 | - } | 147 | + data: param |
115 | }).then(success).fail(fail); | 148 | }).then(success).fail(fail); |
116 | } | 149 | } |
117 | }; | 150 | }; |
@@ -120,7 +153,9 @@ | @@ -120,7 +153,9 @@ | ||
120 | let _that = this; | 153 | let _that = this; |
121 | 154 | ||
122 | return () => { | 155 | return () => { |
123 | - _that.orderDetail().cancel(code, (result) => { | 156 | + _that.orderDetail({ |
157 | + orderCode: code | ||
158 | + }).cancel({orderCode: code}, (result) => { | ||
124 | if (result.code === 200) { | 159 | if (result.code === 200) { |
125 | location.href = '/home/orders?type=2'; | 160 | location.href = '/home/orders?type=2'; |
126 | } | 161 | } |
@@ -131,19 +166,13 @@ | @@ -131,19 +166,13 @@ | ||
131 | let _that = this; | 166 | let _that = this; |
132 | 167 | ||
133 | Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() { | 168 | Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() { |
134 | - _that.orderDetail().cancel(code, (result) => { | ||
135 | - if (result.code === 200) { | ||
136 | - location.href = '/home/orders?type=2'; | ||
137 | - } else { | ||
138 | - tip(result.message); | ||
139 | - } | ||
140 | - }, () => { | ||
141 | - tip('操作失敗'); | ||
142 | - }); | 169 | + this.hide(); |
170 | + _that.dropDown('cancel-reason'); | ||
143 | }); | 171 | }); |
144 | }, | 172 | }, |
145 | deleteOrder(code) { | 173 | deleteOrder(code) { |
146 | Modal.confirm('确认删除订单?', '', function() { | 174 | Modal.confirm('确认删除订单?', '', function() { |
175 | + this.hide(); | ||
147 | $.ajax({ | 176 | $.ajax({ |
148 | url: '/home/delete-order', | 177 | url: '/home/delete-order', |
149 | type: 'post', | 178 | type: 'post', |
@@ -157,7 +186,7 @@ | @@ -157,7 +186,7 @@ | ||
157 | tip(result.message); | 186 | tip(result.message); |
158 | } | 187 | } |
159 | }).fail(() => { | 188 | }).fail(() => { |
160 | - tip('操作失敗'); | 189 | + tip('操作失败'); |
161 | }); | 190 | }); |
162 | }); | 191 | }); |
163 | }, | 192 | }, |
@@ -175,7 +204,7 @@ | @@ -175,7 +204,7 @@ | ||
175 | tip(result.message); | 204 | tip(result.message); |
176 | } | 205 | } |
177 | }).fail(() => { | 206 | }).fail(() => { |
178 | - tip('操作失敗'); | 207 | + tip('操作失败'); |
179 | }); | 208 | }); |
180 | }, | 209 | }, |
181 | goBuy(code) { | 210 | goBuy(code) { |
@@ -194,6 +223,22 @@ | @@ -194,6 +223,22 @@ | ||
194 | return; | 223 | return; |
195 | location.href = item.url; | 224 | location.href = item.url; |
196 | }); | 225 | }); |
226 | + }, | ||
227 | + dropDown(elementId){ | ||
228 | + let dropdown = document.getElementById(elementId); | ||
229 | + try { | ||
230 | + this.showDropdown(dropdown); | ||
231 | + } catch(e) { | ||
232 | + console.log(e) | ||
233 | + } | ||
234 | + return false; | ||
235 | + }, | ||
236 | + | ||
237 | + showDropdown(element) { | ||
238 | + let event; | ||
239 | + event = document.createEvent('MouseEvents'); | ||
240 | + event.initMouseEvent('mousedown', true, true, window); | ||
241 | + element.dispatchEvent(event); | ||
197 | } | 242 | } |
198 | } | 243 | } |
199 | }; | 244 | }; |
@@ -44,6 +44,9 @@ | @@ -44,6 +44,9 @@ | ||
44 | <p>Your do not have an order <br>for the time being</p> | 44 | <p>Your do not have an order <br>for the time being</p> |
45 | <a href="">去购物</a> | 45 | <a href="">去购物</a> |
46 | </div> | 46 | </div> |
47 | + <select id="cancel-reason" class="cancel-reason" v-on:change="reasonChange" v-model="selected"> | ||
48 | + <option v-for="option in options" v-bind:value="{id:option.id}">{{option.reason}}</option> | ||
49 | + </select> | ||
47 | </template> | 50 | </template> |
48 | 51 | ||
49 | <script> | 52 | <script> |
@@ -63,12 +66,16 @@ | @@ -63,12 +66,16 @@ | ||
63 | type: this.$parent.$data.type, | 66 | type: this.$parent.$data.type, |
64 | orderList: [], | 67 | orderList: [], |
65 | busy: false, | 68 | busy: false, |
66 | - emptybox: 'hide' | 69 | + emptybox: 'hide', |
70 | + selected: null, | ||
71 | + options: [], | ||
72 | + currentCode: '' | ||
67 | }; | 73 | }; |
68 | }, | 74 | }, |
69 | 75 | ||
70 | ready() { | 76 | ready() { |
71 | this.getOrderData(); | 77 | this.getOrderData(); |
78 | + this.getCancelReason(); | ||
72 | }, | 79 | }, |
73 | 80 | ||
74 | methods: { | 81 | methods: { |
@@ -102,11 +109,39 @@ | @@ -102,11 +109,39 @@ | ||
102 | tip('网络错误'); | 109 | tip('网络错误'); |
103 | }); | 110 | }); |
104 | }, | 111 | }, |
112 | + reasonChange(){ | ||
113 | + console.log(this.currentCode) | ||
114 | + this.order().cancel({ | ||
115 | + orderCode: this.currentCode, | ||
116 | + reasonId: this.selected.id | ||
117 | + }, (result) => { | ||
118 | + if (result.code === 200) { | ||
119 | + location.href = '/home/orders?type=2'; | ||
120 | + } else { | ||
121 | + tip(result.message); | ||
122 | + } | ||
123 | + }, () => { | ||
124 | + tip('操作失败'); | ||
125 | + }); | ||
126 | + }, | ||
127 | + getCancelReason() { | ||
128 | + let that = this; | ||
129 | + | ||
130 | + $.ajax({ | ||
131 | + url: '/home/order/cancel-reason', | ||
132 | + }).then(result => { | ||
133 | + if (result.data.length > 0) { | ||
134 | + that.options = result.data; | ||
135 | + } | ||
136 | + }).fail(() => { | ||
137 | + tip('操作失败'); | ||
138 | + }); | ||
139 | + }, | ||
105 | autoCancel(code) { | 140 | autoCancel(code) { |
106 | let _that = this; | 141 | let _that = this; |
107 | 142 | ||
108 | return () => { | 143 | return () => { |
109 | - _that.order().cancel(code, (result) => { | 144 | + _that.order().cancel({orderCode: code}, (result) => { |
110 | if (result.code === 200) { | 145 | if (result.code === 200) { |
111 | location.reload(); | 146 | location.reload(); |
112 | } | 147 | } |
@@ -115,13 +150,11 @@ | @@ -115,13 +150,11 @@ | ||
115 | }, | 150 | }, |
116 | order() { | 151 | order() { |
117 | return { | 152 | return { |
118 | - cancel(code, success, fail) { | 153 | + cancel(param, success, fail) { |
119 | $.ajax({ | 154 | $.ajax({ |
120 | url: '/home/cancel-order', | 155 | url: '/home/cancel-order', |
121 | type: 'post', | 156 | type: 'post', |
122 | - data: { | ||
123 | - orderCode: code | ||
124 | - } | 157 | + data: param |
125 | }).then(success).fail(fail); | 158 | }).then(success).fail(fail); |
126 | } | 159 | } |
127 | }; | 160 | }; |
@@ -130,21 +163,16 @@ | @@ -130,21 +163,16 @@ | ||
130 | let _that = this; | 163 | let _that = this; |
131 | 164 | ||
132 | Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() { | 165 | Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() { |
133 | - _that.order().cancel(code, (result) => { | ||
134 | - if (result.code === 200) { | ||
135 | - location.reload(); | ||
136 | - } else { | ||
137 | - tip(result.message); | ||
138 | - } | ||
139 | - }, () => { | ||
140 | - tip('操作失敗'); | ||
141 | - }); | 166 | + this.hide(); |
167 | + _that.currentCode = code; | ||
168 | + _that.dropDown('cancel-reason'); | ||
142 | }); | 169 | }); |
143 | }, | 170 | }, |
144 | deleteOrder(order, index) { | 171 | deleteOrder(order, index) { |
145 | let that = this; | 172 | let that = this; |
146 | 173 | ||
147 | Modal.confirm('确认删除订单?', '', function() { | 174 | Modal.confirm('确认删除订单?', '', function() { |
175 | + this.hide(); | ||
148 | $.ajax({ | 176 | $.ajax({ |
149 | url: '/home/delete-order', | 177 | url: '/home/delete-order', |
150 | type: 'post', | 178 | type: 'post', |
@@ -153,12 +181,12 @@ | @@ -153,12 +181,12 @@ | ||
153 | } | 181 | } |
154 | }).then(result => { | 182 | }).then(result => { |
155 | if (result.code === 200) { | 183 | if (result.code === 200) { |
156 | - that.$el.querySelectorAll('.order-item')[index].remove(); | 184 | + that.orderList.splice(index, 1); |
157 | } else { | 185 | } else { |
158 | tip(result.message); | 186 | tip(result.message); |
159 | } | 187 | } |
160 | }).fail(() => { | 188 | }).fail(() => { |
161 | - tip('操作失敗'); | 189 | + tip('操作失败'); |
162 | }); | 190 | }); |
163 | }); | 191 | }); |
164 | }, | 192 | }, |
@@ -176,7 +204,7 @@ | @@ -176,7 +204,7 @@ | ||
176 | tip(result.message); | 204 | tip(result.message); |
177 | } | 205 | } |
178 | }).fail(() => { | 206 | }).fail(() => { |
179 | - tip('操作失敗'); | 207 | + tip('操作失败'); |
180 | }); | 208 | }); |
181 | }, | 209 | }, |
182 | goBuy(code) { | 210 | goBuy(code) { |
@@ -184,6 +212,22 @@ | @@ -184,6 +212,22 @@ | ||
184 | }, | 212 | }, |
185 | seeExpress(code) { | 213 | seeExpress(code) { |
186 | location.href = '/home/logistic?order_code='+code; | 214 | location.href = '/home/logistic?order_code='+code; |
215 | + }, | ||
216 | + dropDown(elementId){ | ||
217 | + let dropdown = document.getElementById(elementId); | ||
218 | + try { | ||
219 | + this.showDropdown(dropdown); | ||
220 | + } catch(e) { | ||
221 | + console.log(e) | ||
222 | + } | ||
223 | + return false; | ||
224 | + }, | ||
225 | + | ||
226 | + showDropdown(element) { | ||
227 | + let event; | ||
228 | + event = document.createEvent('MouseEvents'); | ||
229 | + event.initMouseEvent('mousedown', true, true, window); | ||
230 | + element.dispatchEvent(event); | ||
187 | } | 231 | } |
188 | } | 232 | } |
189 | }; | 233 | }; |
-
Please register or login to post a comment