Showing
9 changed files
with
184 additions
and
16 deletions
@@ -36,8 +36,12 @@ exports.order = (req, res, next) => { | @@ -36,8 +36,12 @@ exports.order = (req, res, next) => { | ||
36 | 36 | ||
37 | return Promise.all([ | 37 | return Promise.all([ |
38 | orderModel.order(params), | 38 | orderModel.order(params), |
39 | - orderModel.getOrders(initialData) | 39 | + orderModel.getOrders(initialData), |
40 | + orderModel.refundReason() | ||
40 | ]).then(result => { | 41 | ]).then(result => { |
42 | + // 申请退款原因 | ||
43 | + let refundReason = result[2]; | ||
44 | + | ||
41 | res.render('order', { | 45 | res.render('order', { |
42 | module: 'home', | 46 | module: 'home', |
43 | page: 'order', | 47 | page: 'order', |
@@ -49,6 +53,7 @@ exports.order = (req, res, next) => { | @@ -49,6 +53,7 @@ exports.order = (req, res, next) => { | ||
49 | localCss: true, | 53 | localCss: true, |
50 | pageFooter: true, | 54 | pageFooter: true, |
51 | order: result[0] || [], | 55 | order: result[0] || [], |
56 | + refundReason: refundReason, | ||
52 | walkwayUrl: result[1] && result[1].length ? '' : '//m.yohobuy.com/product/new', | 57 | walkwayUrl: result[1] && result[1].length ? '' : '//m.yohobuy.com/product/new', |
53 | firstPageOrdersList: result[1] || [] | 58 | firstPageOrdersList: result[1] || [] |
54 | }); | 59 | }); |
@@ -81,6 +81,28 @@ const cancelOrder = (req, res, next) => { | @@ -81,6 +81,28 @@ const cancelOrder = (req, res, next) => { | ||
81 | }; | 81 | }; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | + * 申请退款 | ||
85 | + */ | ||
86 | +const refundApply = (req, res, next) => { | ||
87 | + let orderCode = req.query.id; | ||
88 | + | ||
89 | + if (!orderCode) { | ||
90 | + return res.json({ | ||
91 | + code: 404, | ||
92 | + msg: '订单号不存在!' | ||
93 | + }); | ||
94 | + } | ||
95 | + orderDetailModel.refundApply({ | ||
96 | + orderCode: req.query.id, | ||
97 | + uid: req.user.uid, | ||
98 | + reasonId: req.query.reasonId || 1, | ||
99 | + reason: req.query.reason | ||
100 | + }).then(result => { | ||
101 | + res.json(result); | ||
102 | + }).catch(next); | ||
103 | +}; | ||
104 | + | ||
105 | +/** | ||
84 | * 我的订单-查看物流信息 | 106 | * 我的订单-查看物流信息 |
85 | */ | 107 | */ |
86 | const logistic = (req, res, next) => { | 108 | const logistic = (req, res, next) => { |
@@ -102,5 +124,6 @@ module.exports = { | @@ -102,5 +124,6 @@ module.exports = { | ||
102 | delOrder, | 124 | delOrder, |
103 | readdData, | 125 | readdData, |
104 | cancelOrder, | 126 | cancelOrder, |
127 | + refundApply, | ||
105 | logistic | 128 | logistic |
106 | }; | 129 | }; |
@@ -263,21 +263,21 @@ const _getNavs = (type) => { | @@ -263,21 +263,21 @@ const _getNavs = (type) => { | ||
263 | }; | 263 | }; |
264 | 264 | ||
265 | /** | 265 | /** |
266 | - * 订单页面数据 | 266 | + * 订单页面导航条和取消订单原因 |
267 | * @param params | 267 | * @param params |
268 | * @returns {*|Promise.<TResult>} | 268 | * @returns {*|Promise.<TResult>} |
269 | */ | 269 | */ |
270 | const order = (params) => { | 270 | const order = (params) => { |
271 | - let finalResult = {}; | ||
272 | - | ||
273 | - Object.assign(finalResult, {navs: _getNavs(params.type)}); | 271 | + let finalResult = { |
272 | + navs: _getNavs(params.type) | ||
273 | + }; | ||
274 | 274 | ||
275 | return api.get('', _.assign({ | 275 | return api.get('', _.assign({ |
276 | method: 'app.SpaceOrders.closeReasons' | 276 | method: 'app.SpaceOrders.closeReasons' |
277 | }, params), { | 277 | }, params), { |
278 | cache: true, | 278 | cache: true, |
279 | code: 200 | 279 | code: 200 |
280 | - }).then((result) => { | 280 | + }).then(result => { |
281 | 281 | ||
282 | if (result.data) { | 282 | if (result.data) { |
283 | Object.assign(finalResult, {cancelReason: result.data}); | 283 | Object.assign(finalResult, {cancelReason: result.data}); |
@@ -288,6 +288,17 @@ const order = (params) => { | @@ -288,6 +288,17 @@ const order = (params) => { | ||
288 | }; | 288 | }; |
289 | 289 | ||
290 | /** | 290 | /** |
291 | + * 申请退款原因 | ||
292 | + */ | ||
293 | +const refundReason = () => { | ||
294 | + return api.get('', { | ||
295 | + method: 'app.SpaceOrders.refundApplyReasons' | ||
296 | + }, {code: 200, cache: true}).then(result => { | ||
297 | + return _.get(result, 'data', []); | ||
298 | + }); | ||
299 | +}; | ||
300 | + | ||
301 | +/** | ||
291 | * 获取订单列表 | 302 | * 获取订单列表 |
292 | * @param params | 303 | * @param params |
293 | */ | 304 | */ |
@@ -333,6 +344,15 @@ const getOrders = (params) => { | @@ -333,6 +344,15 @@ const getOrders = (params) => { | ||
333 | }); | 344 | }); |
334 | } | 345 | } |
335 | 346 | ||
347 | + /* 申请退款 */ | ||
348 | + if (parseInt(value.payment_type, 10) === 1 && | ||
349 | + value.payment_status === 'Y' && | ||
350 | + 4 <= parseInt(value.status, 10) <= 5) { | ||
351 | + Object.assign(perOrder, { | ||
352 | + refundApply: true | ||
353 | + }); | ||
354 | + } | ||
355 | + | ||
336 | finalResult.push(perOrder); | 356 | finalResult.push(perOrder); |
337 | }); | 357 | }); |
338 | } | 358 | } |
@@ -343,5 +363,6 @@ const getOrders = (params) => { | @@ -343,5 +363,6 @@ const getOrders = (params) => { | ||
343 | 363 | ||
344 | module.exports = { | 364 | module.exports = { |
345 | order, | 365 | order, |
346 | - getOrders | 366 | + getOrders, |
367 | + refundReason | ||
347 | }; | 368 | }; |
@@ -373,6 +373,19 @@ const cancelOrder = (orderCode, uid, reasonId, gender, channel, reason) => { | @@ -373,6 +373,19 @@ const cancelOrder = (orderCode, uid, reasonId, gender, channel, reason) => { | ||
373 | }); | 373 | }); |
374 | }; | 374 | }; |
375 | 375 | ||
376 | +/** | ||
377 | + * 申请退款 | ||
378 | + */ | ||
379 | +const refundApply = (params) => { | ||
380 | + return api.get('', { | ||
381 | + method: 'app.SpaceOrders.refundApply', | ||
382 | + uid: params.uid, | ||
383 | + order_code: params.orderCode, | ||
384 | + reason_id: params.reasonId, | ||
385 | + reason: params.reason | ||
386 | + }); | ||
387 | +}; | ||
388 | + | ||
376 | /* | 389 | /* |
377 | * 我的订单-查看物流 | 390 | * 我的订单-查看物流 |
378 | * @param int $orderCode 订单号 | 391 | * @param int $orderCode 订单号 |
@@ -452,5 +465,6 @@ module.exports = { | @@ -452,5 +465,6 @@ module.exports = { | ||
452 | delOrder, | 465 | delOrder, |
453 | readdData, | 466 | readdData, |
454 | cancelOrder, | 467 | cancelOrder, |
468 | + refundApply, | ||
455 | logistics | 469 | logistics |
456 | }; | 470 | }; |
@@ -55,6 +55,7 @@ router.get('/orders/detail', auth, orderDetailController.orderDetailData); // è® | @@ -55,6 +55,7 @@ router.get('/orders/detail', auth, orderDetailController.orderDetailData); // è® | ||
55 | router.get('/delOrder', auth, orderDetailController.delOrder); // 删除订单 | 55 | router.get('/delOrder', auth, orderDetailController.delOrder); // 删除订单 |
56 | router.get('/readd', auth, orderDetailController.readdData); // 再次购买 | 56 | router.get('/readd', auth, orderDetailController.readdData); // 再次购买 |
57 | router.get('/cancelOrder', auth, orderDetailController.cancelOrder); // 取消订单 | 57 | router.get('/cancelOrder', auth, orderDetailController.cancelOrder); // 取消订单 |
58 | +router.get('/refundApply', auth, orderDetailController.refundApply); // 申请退款 | ||
58 | 59 | ||
59 | router.get('/', homeController.index); // 个人中心首页 | 60 | router.get('/', homeController.index); // 个人中心首页 |
60 | router.get('/mydetails', auth, homeController.myDetails); // 个人基本资料页面 | 61 | router.get('/mydetails', auth, homeController.myDetails); // 个人基本资料页面 |
@@ -44,5 +44,21 @@ | @@ -44,5 +44,21 @@ | ||
44 | </div> | 44 | </div> |
45 | </div> | 45 | </div> |
46 | {{/ order}} | 46 | {{/ order}} |
47 | + | ||
48 | + {{!-- 申请退款原因 --}} | ||
49 | + <div class="refund-reason-mask"> | ||
50 | + <div class="refund-reason-box" > | ||
51 | + <div class="box-head"><span class="box-cmp">完成</span></div> | ||
52 | + <div class="swiper-container refund-box-main"> | ||
53 | + | ||
54 | + <ul class="swiper-wrapper"> | ||
55 | + {{#refundReason}} | ||
56 | + <li class="swiper-slide" data-reason-id="{{id}}"><span >{{reason}}</span></li> | ||
57 | + {{/refundReason}} | ||
58 | + </ul> | ||
59 | + <div class="refund-active-mask"></div> | ||
60 | + </div> | ||
61 | + </div> | ||
62 | + </div> | ||
47 | </div> | 63 | </div> |
48 | 64 |
@@ -37,6 +37,11 @@ | @@ -37,6 +37,11 @@ | ||
37 | <span class="btn check-logistics">查看二维码</span> | 37 | <span class="btn check-logistics">查看二维码</span> |
38 | </a> | 38 | </a> |
39 | {{/if}} | 39 | {{/if}} |
40 | + | ||
41 | + {{!-- 申请退款 --}} | ||
42 | + {{#if refundApply}} | ||
43 | + <span class="btn refund">申请退款</span> | ||
44 | + {{/if}} | ||
40 | </div> | 45 | </div> |
41 | {{/unless}} | 46 | {{/unless}} |
42 | {{/unless}} | 47 | {{/unless}} |
@@ -32,7 +32,9 @@ var dialog = require('../plugin/dialog'); | @@ -32,7 +32,9 @@ var dialog = require('../plugin/dialog'); | ||
32 | 32 | ||
33 | var orderHammer, | 33 | var orderHammer, |
34 | $reaMask = $('.reason-mask'), | 34 | $reaMask = $('.reason-mask'), |
35 | - reasonSwiper; | 35 | + $refundReaMask = $('.refund-reason-mask'), |
36 | + reasonSwiper, | ||
37 | + refundReasonSwiper; | ||
36 | 38 | ||
37 | // 首屏加载标志 | 39 | // 首屏加载标志 |
38 | var firstScreen = $('.firstscreen-orders').children().size() > 0; | 40 | var firstScreen = $('.firstscreen-orders').children().size() > 0; |
@@ -110,14 +112,13 @@ function getOrders(option) { | @@ -110,14 +112,13 @@ function getOrders(option) { | ||
110 | type: activeType, | 112 | type: activeType, |
111 | page: order.page + 1 | 113 | page: order.page + 1 |
112 | }; | 114 | }; |
115 | + var show = option && !option.noLoadingMask; | ||
113 | 116 | ||
114 | if (firstScreen) { | 117 | if (firstScreen) { |
115 | // 如果首屏加载了,则去掉10条记录 | 118 | // 如果首屏加载了,则去掉10条记录 |
116 | opt.start = 10; | 119 | opt.start = 10; |
117 | } | 120 | } |
118 | 121 | ||
119 | - var show = option && !option.noLoadingMask; | ||
120 | - | ||
121 | if (inAjax) { | 122 | if (inAjax) { |
122 | return; | 123 | return; |
123 | } | 124 | } |
@@ -155,7 +156,8 @@ function getOrders(option) { | @@ -155,7 +156,8 @@ function getOrders(option) { | ||
155 | if (opt.page > 1) { | 156 | if (opt.page > 1) { |
156 | return; | 157 | return; |
157 | } | 158 | } |
158 | - $curContainer.html('<div class="no-order"><div class="icon"></div><span>你还没有订单!</span><a class="walk-way" href="//m.yohobuy.com/product/new">随便逛逛</a></div>'); | 159 | + $curContainer.html('<div class="no-order"><div class="icon"></div><span>' + |
160 | + '你还没有订单!</span><a class="walk-way" href="//m.yohobuy.com/product/new">随便逛逛</a></div>'); | ||
159 | order.end = true; | 161 | order.end = true; |
160 | } | 162 | } |
161 | 163 | ||
@@ -203,6 +205,7 @@ orderHammer.on('tap', function(e) { | @@ -203,6 +205,7 @@ orderHammer.on('tap', function(e) { | ||
203 | id = $order.data('id'); | 205 | id = $order.data('id'); |
204 | 206 | ||
205 | $reaMask.data('orderId', id); | 207 | $reaMask.data('orderId', id); |
208 | + $refundReaMask.data('orderId', id); | ||
206 | 209 | ||
207 | if ($cur.closest('.del').length > 0) { | 210 | if ($cur.closest('.del').length > 0) { |
208 | 211 | ||
@@ -237,7 +240,11 @@ orderHammer.on('tap', function(e) { | @@ -237,7 +240,11 @@ orderHammer.on('tap', function(e) { | ||
237 | }); | 240 | }); |
238 | }); | 241 | }); |
239 | } else if ($cur.closest('.cancel').length > 0) { | 242 | } else if ($cur.closest('.cancel').length > 0) { |
243 | + // 取消订单 | ||
240 | $reaMask.css('visibility', 'visible'); | 244 | $reaMask.css('visibility', 'visible'); |
245 | + } else if ($cur.closest('.refund').length > 0) { | ||
246 | + // 申请退款 | ||
247 | + $refundReaMask.css('visibility', 'visible'); | ||
241 | } else if ($cur.closest('.order-goods').length > 0) { | 248 | } else if ($cur.closest('.order-goods').length > 0) { |
242 | 249 | ||
243 | // Location to order detail | 250 | // Location to order detail |
@@ -287,7 +294,7 @@ $(function() { | @@ -287,7 +294,7 @@ $(function() { | ||
287 | centeredSlides: true, | 294 | centeredSlides: true, |
288 | initialSlide: 0, | 295 | initialSlide: 0, |
289 | onSlideChangeStart: function(reasonSwiper) {//eslint-disable-line | 296 | onSlideChangeStart: function(reasonSwiper) {//eslint-disable-line |
290 | - var activeIndex = reasonSwiper.activeIndex, | 297 | + let activeIndex = reasonSwiper.activeIndex, |
291 | slides = reasonSwiper.slides, | 298 | slides = reasonSwiper.slides, |
292 | i = 0; | 299 | i = 0; |
293 | 300 | ||
@@ -312,10 +319,43 @@ $(function() { | @@ -312,10 +319,43 @@ $(function() { | ||
312 | $(slides[activeIndex]).css('transform', ''); | 319 | $(slides[activeIndex]).css('transform', ''); |
313 | } | 320 | } |
314 | }); | 321 | }); |
322 | + | ||
323 | + // 申请退款 Swiper | ||
324 | + refundReasonSwiper = new Swiper('.refund-box-main', { | ||
325 | + direction: 'vertical', | ||
326 | + slidesPerView: 5, | ||
327 | + centeredSlides: true, | ||
328 | + initialSlide: 0, | ||
329 | + onSlideChangeStart: function(refundReasonSwiper) {//eslint-disable-line | ||
330 | + let activeIndex = refundReasonSwiper.activeIndex, | ||
331 | + slides = refundReasonSwiper.slides, | ||
332 | + i = 0; | ||
333 | + | ||
334 | + if (slides.length !== 1) { | ||
335 | + if (activeIndex === 0) { | ||
336 | + for (i = 1; i < slides.length; i++) { | ||
337 | + $(slides[i]).css('transform', ''); | ||
338 | + } | ||
339 | + } else if (activeIndex === slides.length - 1) { | ||
340 | + for (i = 0; i < activeIndex; i++) { | ||
341 | + $(slides[i]).css('transform', 'rotateX(' + (30 + (activeIndex - i) * 12) + 'deg)'); | ||
342 | + } | ||
343 | + } else { | ||
344 | + for (i = 0; i < activeIndex; i++) { | ||
345 | + $(slides[i]).css('transform', 'rotateX(' + (30 + (activeIndex - i) * 12) + 'deg)'); | ||
346 | + } | ||
347 | + for (i = activeIndex + 1; i < slides.length; i++) { | ||
348 | + $(slides[i]).css('transform', ''); | ||
349 | + } | ||
350 | + } | ||
351 | + } | ||
352 | + $(slides[activeIndex]).css('transform', ''); | ||
353 | + } | ||
354 | + }); | ||
315 | }); | 355 | }); |
316 | 356 | ||
317 | $reaMask.find('.box-cmp').on('touchend', function() { | 357 | $reaMask.find('.box-cmp').on('touchend', function() { |
318 | - var selSolid = reasonSwiper.slides[reasonSwiper.activeIndex], | 358 | + let selSolid = reasonSwiper.slides[reasonSwiper.activeIndex], |
319 | reason = $(selSolid).text(), | 359 | reason = $(selSolid).text(), |
320 | reasonId = $(selSolid).data('reasonId'); | 360 | reasonId = $(selSolid).data('reasonId'); |
321 | 361 | ||
@@ -343,6 +383,36 @@ $reaMask.find('.box-cmp').on('touchend', function() { | @@ -343,6 +383,36 @@ $reaMask.find('.box-cmp').on('touchend', function() { | ||
343 | }); | 383 | }); |
344 | }); | 384 | }); |
345 | 385 | ||
386 | +// 申请退款 | ||
387 | +$refundReaMask.find('.box-cmp').on('touchend', function() { | ||
388 | + let selSolid = refundReasonSwiper.slides[refundReasonSwiper.activeIndex], | ||
389 | + reason = $(selSolid).text(), | ||
390 | + reasonId = $(selSolid).data('reasonId'); | ||
391 | + | ||
392 | + $.ajax({ | ||
393 | + type: 'GET', | ||
394 | + url: '/home/refundApply', | ||
395 | + data: { | ||
396 | + id: $refundReaMask.data('orderId'), | ||
397 | + reason: reason, | ||
398 | + reasonId: reasonId | ||
399 | + } | ||
400 | + }).then(function(res) { | ||
401 | + $refundReaMask.fadeOut(); | ||
402 | + if ($.type(res) !== 'object') { | ||
403 | + return; | ||
404 | + } | ||
405 | + if (res.message) { | ||
406 | + tip.show(res.message); | ||
407 | + } | ||
408 | + setTimeout(function() { | ||
409 | + window.location.href = '/home/orders'; | ||
410 | + }, 2000); | ||
411 | + }).fail(function() { | ||
412 | + tip.show('网络错误'); | ||
413 | + }); | ||
414 | +}); | ||
415 | + | ||
346 | $reaMask.on('touchend', function(event) { | 416 | $reaMask.on('touchend', function(event) { |
347 | if (event.target.className !== 'reason-mask') { | 417 | if (event.target.className !== 'reason-mask') { |
348 | return false; | 418 | return false; |
@@ -352,6 +422,16 @@ $reaMask.on('touchend', function(event) { | @@ -352,6 +422,16 @@ $reaMask.on('touchend', function(event) { | ||
352 | event.stopPropagation(); | 422 | event.stopPropagation(); |
353 | }); | 423 | }); |
354 | 424 | ||
425 | +// 申请退款 | ||
426 | +$refundReaMask.on('touchend', function(event) { | ||
427 | + if (event.target.className !== 'reason-mask') { | ||
428 | + return false; | ||
429 | + } | ||
430 | + | ||
431 | + $refundReaMask.css('visibility', 'hidden'); | ||
432 | + event.stopPropagation(); | ||
433 | +}); | ||
434 | + | ||
355 | $('.nav-tap').on('click', function(e) { | 435 | $('.nav-tap').on('click', function(e) { |
356 | var $cur = $(e.target); | 436 | var $cur = $(e.target); |
357 | 437 |
1 | .order-page { | 1 | .order-page { |
2 | background: #f0f0f0; | 2 | background: #f0f0f0; |
3 | 3 | ||
4 | - .reason-mask { | 4 | + .reason-mask, |
5 | + .refund-reason-mask { | ||
5 | position: fixed; | 6 | position: fixed; |
6 | width: 100%; | 7 | width: 100%; |
7 | height: 100%; | 8 | height: 100%; |
@@ -11,7 +12,8 @@ | @@ -11,7 +12,8 @@ | ||
11 | z-index: 5; | 12 | z-index: 5; |
12 | visibility: hidden; | 13 | visibility: hidden; |
13 | 14 | ||
14 | - .reason-box { | 15 | + .reason-box, |
16 | + .refund-reason-box { | ||
15 | border-bottom: 1px solid #ccc; | 17 | border-bottom: 1px solid #ccc; |
16 | font: inherit; | 18 | font: inherit; |
17 | position: absolute; | 19 | position: absolute; |
@@ -32,7 +34,8 @@ | @@ -32,7 +34,8 @@ | ||
32 | padding-right: 30px; | 34 | padding-right: 30px; |
33 | } | 35 | } |
34 | 36 | ||
35 | - .box-main { | 37 | + .box-main, |
38 | + .refund-box-main { | ||
36 | background: #fff; | 39 | background: #fff; |
37 | padding: 20px; | 40 | padding: 20px; |
38 | height: 300px; | 41 | height: 300px; |
-
Please register or login to post a comment