Showing
9 changed files
with
201 additions
and
60 deletions
@@ -4,17 +4,15 @@ | @@ -4,17 +4,15 @@ | ||
4 | */ | 4 | */ |
5 | 'use strict'; | 5 | 'use strict'; |
6 | 6 | ||
7 | -const cookie = global.yoho.cookie; | ||
8 | const returnsModel = require('../models/returns'); | 7 | const returnsModel = require('../models/returns'); |
9 | 8 | ||
10 | /* | 9 | /* |
11 | 我的退换货-列表页 | 10 | 我的退换货-列表页 |
12 | */ | 11 | */ |
13 | const index = (req, res, next) => { | 12 | const index = (req, res, next) => { |
14 | - const uid = cookie.getUid(req); | ||
15 | const page = req.query.page; | 13 | const page = req.query.page; |
16 | 14 | ||
17 | - returnsModel.getReturnsList(uid, page /* ,limit=10*/) | 15 | + returnsModel.getReturnsList(req.user.uid, page, 10) |
18 | .then(data => { | 16 | .then(data => { |
19 | const viewData = Object.assign({ | 17 | const viewData = Object.assign({ |
20 | module: 'home', | 18 | module: 'home', |
@@ -6,13 +6,16 @@ | @@ -6,13 +6,16 @@ | ||
6 | 'use strict'; | 6 | 'use strict'; |
7 | 7 | ||
8 | const _ = require('lodash'); | 8 | const _ = require('lodash'); |
9 | -const path = require('path'); | 9 | + |
10 | +// const path = require('path'); | ||
10 | const Promise = require('bluebird'); | 11 | const Promise = require('bluebird'); |
11 | const returnAPI = require('./returns-api'); | 12 | const returnAPI = require('./returns-api'); |
12 | 13 | ||
14 | +const pager = require(`${global.utils}/pager`).setPager; | ||
15 | + | ||
13 | // 使用 product中的分页逻辑 | 16 | // 使用 product中的分页逻辑 |
14 | -const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js'); | ||
15 | -const pager = require(pagerPath).handlePagerData; | 17 | +// const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js'); |
18 | +// const pager = require(pagerPath).handlePagerData; | ||
16 | 19 | ||
17 | const co = Promise.coroutine; | 20 | const co = Promise.coroutine; |
18 | const api = global.yoho.API; | 21 | const api = global.yoho.API; |
@@ -23,6 +26,8 @@ const REFUND = 1; // 退货 | @@ -23,6 +26,8 @@ const REFUND = 1; // 退货 | ||
23 | const EXCHANGE = 2; // 换货 | 26 | const EXCHANGE = 2; // 换货 |
24 | const TRUE = 'Y'; | 27 | const TRUE = 'Y'; |
25 | const RETURNS_EMPTY = '您没有退/换货订单'; | 28 | const RETURNS_EMPTY = '您没有退/换货订单'; |
29 | +const CANCEL_REFUND_URI = '/home/returns/cancelRefund'; | ||
30 | +const CANCEL_EXCHANGE_URI = '/home/returns/cancelChange'; | ||
26 | const REFUND_URI = '/home/returns/refundDetail'; | 31 | const REFUND_URI = '/home/returns/refundDetail'; |
27 | const EXCHANGE_URI = '/home/returns/exchangeDetail'; | 32 | const EXCHANGE_URI = '/home/returns/exchangeDetail'; |
28 | 33 | ||
@@ -48,19 +53,18 @@ const setDetailGoods = (list) => { | @@ -48,19 +53,18 @@ const setDetailGoods = (list) => { | ||
48 | 53 | ||
49 | // 处理订单商品的数据 | 54 | // 处理订单商品的数据 |
50 | function getGoodsData(goods) { | 55 | function getGoodsData(goods) { |
51 | - const arr = []; | 56 | + let arr = []; |
52 | 57 | ||
53 | goods.forEach(good => { | 58 | goods.forEach(good => { |
54 | - const obj = {}; | ||
55 | - const cnAlphabet = good.cn_alphabet || ''; | ||
56 | - | ||
57 | - obj.href = getProductUrlBySkc(good.product_id, good.goods_id, cnAlphabet); | ||
58 | - obj.thumb = helpers.image(good.goods_image, 60, 60); | ||
59 | - obj.name = good.product_name; | ||
60 | - obj.color = good.color_name; | ||
61 | - obj.size = good.size_name; | ||
62 | - | ||
63 | - arr.push(obj); | 59 | + let cnAlphabet = good.cn_alphabet || ''; |
60 | + | ||
61 | + arr.push({ | ||
62 | + href: getProductUrlBySkc(good.product_id, good.goods_id, cnAlphabet), | ||
63 | + thumb: helpers.image(good.goods_image, 60, 60), | ||
64 | + name: good.product_name, | ||
65 | + color: good.color_name, | ||
66 | + size: good.size_name | ||
67 | + }); | ||
64 | }); | 68 | }); |
65 | 69 | ||
66 | return arr; | 70 | return arr; |
@@ -77,57 +81,60 @@ const getReturnsList = co(function*(uid, page, limit) { | @@ -77,57 +81,60 @@ const getReturnsList = co(function*(uid, page, limit) { | ||
77 | page = Number.parseInt(page, 10) || 1; | 81 | page = Number.parseInt(page, 10) || 1; |
78 | limit = Number.parseInt(limit, 10) || 10; | 82 | limit = Number.parseInt(limit, 10) || 10; |
79 | 83 | ||
80 | - const obj = { | 84 | + let obj = { |
81 | orders: [], | 85 | orders: [], |
82 | pager: {} | 86 | pager: {} |
83 | }; | 87 | }; |
84 | let response = yield api.post('', { | 88 | let response = yield api.post('', { |
85 | method: 'app.refund.getList', | 89 | method: 'app.refund.getList', |
86 | - data: { uid: uid, page: page, limit: limit } | 90 | + uid: uid, |
91 | + page: page, | ||
92 | + limit: limit | ||
87 | }); | 93 | }); |
88 | let repData = response.data; | 94 | let repData = response.data; |
89 | 95 | ||
90 | - | ||
91 | // 处理数据 | 96 | // 处理数据 |
92 | if (response.code === 200 && repData && repData.list.length) { | 97 | if (response.code === 200 && repData && repData.list.length) { |
93 | - obj.pager = pager(repData.total, { | ||
94 | - page: page, | ||
95 | - limit: limit | ||
96 | - }); | 98 | + obj.pager = Object.assign({ |
99 | + count: repData.total, | ||
100 | + curPage: page, | ||
101 | + totalPages: repData.total_page || 1 | ||
102 | + }, pager(repData.total_page, {page: page})); | ||
97 | 103 | ||
98 | repData.list.forEach(item => { | 104 | repData.list.forEach(item => { |
99 | - const t = {}; | ||
100 | - | ||
101 | - t.returnId = item.id; | ||
102 | - t.orderNum = item.order_code; | ||
103 | - t.orderTime = item.oreder_create_time.replace('-', '/'); | ||
104 | - t.returnTime = item.create_time; | ||
105 | - t.returnStatus = item.status_name; | ||
106 | - | 105 | + let t = { |
106 | + returnId: item.id, | ||
107 | + orderNum: item.order_code, | ||
108 | + orderTime: _.replace(item.oreder_create_time, '-', '/'), | ||
109 | + returnTime: item.create_time, | ||
110 | + returnStatus: item.status_name | ||
111 | + }; | ||
107 | 112 | ||
108 | - const canCancel = item.canCancel === TRUE; | ||
109 | - let isChange, uri; | 113 | + let canCancel = item.canCancel === TRUE; |
114 | + let isChange, uri = '', cancelUri = ''; | ||
110 | 115 | ||
111 | switch (item.refund_type) { | 116 | switch (item.refund_type) { |
112 | case REFUND: | 117 | case REFUND: |
113 | isChange = false; | 118 | isChange = false; |
114 | - if (canCancel) { | ||
115 | - uri = REFUND_URI; | ||
116 | - } | 119 | + uri = REFUND_URI; |
120 | + cancelUri = CANCEL_REFUND_URI; | ||
117 | break; | 121 | break; |
118 | case EXCHANGE: | 122 | case EXCHANGE: |
119 | isChange = true; | 123 | isChange = true; |
120 | - if (canCancel) { | ||
121 | - uri = EXCHANGE_URI; | ||
122 | - } | 124 | + uri = EXCHANGE_URI; |
125 | + cancelUri = CANCEL_EXCHANGE_URI; | ||
123 | break; | 126 | break; |
124 | default: | 127 | default: |
128 | + break; | ||
125 | } | 129 | } |
126 | 130 | ||
127 | - t.isChange = isChange; | ||
128 | - t.canCancelUrl = helpers.urlFormat(uri); | ||
129 | - t.moreHref = helpers.urlFormat(uri, { id: item.id }); | ||
130 | - t.goods = getGoodsData(item.goods); | 131 | + Object.assign(t, { |
132 | + isChange: isChange, | ||
133 | + canCancel: canCancel, | ||
134 | + canCancelUrl: cancelUri, | ||
135 | + moreHref: helpers.urlFormat(uri, { id: item.id }), | ||
136 | + goods: getGoodsData(item.goods) | ||
137 | + }); | ||
131 | 138 | ||
132 | obj.orders.push(t); | 139 | obj.orders.push(t); |
133 | }); | 140 | }); |
@@ -21,7 +21,8 @@ const commentController = require(`${cRoot}/comment`); | @@ -21,7 +21,8 @@ const commentController = require(`${cRoot}/comment`); | ||
21 | // const complaintsController = require(`${cRoot}/complaints`); | 21 | // const complaintsController = require(`${cRoot}/complaints`); |
22 | const messageController = require(`${cRoot}/message`); | 22 | const messageController = require(`${cRoot}/message`); |
23 | 23 | ||
24 | -// const returnsController = require(`${cRoot}/returns`); | 24 | +const returnsController = require(`${cRoot}/returns`); |
25 | + | ||
25 | // const IndexController = require(`${cRoot}/index`); | 26 | // const IndexController = require(`${cRoot}/index`); |
26 | // const CurrencyController = require(`${cRoot}/currency`); | 27 | // const CurrencyController = require(`${cRoot}/currency`); |
27 | const personalController = require(`${cRoot}/qrcode`); | 28 | const personalController = require(`${cRoot}/qrcode`); |
@@ -204,12 +205,12 @@ router.get('/message/read', messageController.readMsg); | @@ -204,12 +205,12 @@ router.get('/message/read', messageController.readMsg); | ||
204 | router.get('/message/pickCoupon', messageController.pickCoupon); | 205 | router.get('/message/pickCoupon', messageController.pickCoupon); |
205 | 206 | ||
206 | // 我的退/换货 | 207 | // 我的退/换货 |
207 | -// router.get('/returns', returnsController.index); | ||
208 | -// router.get('/refund/apply', returnsController.refundApply); | ||
209 | -// router.get('/refund/detail', returnsController.refundDetail); | ||
210 | -// router.get('/exchange/apply', returnsController.exchangeApply); | ||
211 | -// router.get('/exchange/detail', returnsController.refundDetail); | ||
212 | -// router.get('/returns/success', returnsController.index); | 208 | +router.get('/returns', [getCommonHeader, getHomeNav], returnsController.index); |
209 | +router.get('/refund/apply', [getCommonHeader, getHomeNav], returnsController.refundApply); | ||
210 | +router.get('/refund/detail', [getCommonHeader, getHomeNav], returnsController.refundDetail); | ||
211 | +router.get('/exchange/apply', [getCommonHeader, getHomeNav], returnsController.exchangeApply); | ||
212 | +router.get('/exchange/detail', [getCommonHeader, getHomeNav], returnsController.refundDetail); | ||
213 | +router.get('/returns/success', returnsController.index); | ||
213 | 214 | ||
214 | // router.get('/index', [getCommonHeader, getHomeNav], IndexController.index); | 215 | // router.get('/index', [getCommonHeader, getHomeNav], IndexController.index); |
215 | 216 |
@@ -50,14 +50,15 @@ | @@ -50,14 +50,15 @@ | ||
50 | {{returnStatus}} | 50 | {{returnStatus}} |
51 | </div> | 51 | </div> |
52 | <div class="operation"> | 52 | <div class="operation"> |
53 | + {{#if canCancel}} | ||
54 | + <a class="op-item cancel-trigger" href="javascript:;" data-id="{{returnId}}" data-url="{{canCancelUrl}}">取消申请</a> | ||
55 | + {{/ if}} | ||
53 | <a class="op-item" href="{{moreHref}}" target="_blank">查看详情</a> | 56 | <a class="op-item" href="{{moreHref}}" target="_blank">查看详情</a> |
54 | </div> | 57 | </div> |
55 | </div> | 58 | </div> |
56 | </div> | 59 | </div> |
57 | {{/each}} | 60 | {{/each}} |
58 | - {{#with ../pager}} | ||
59 | - {{> common/foot-pager footPager=this}} | ||
60 | - {{/with}} | 61 | + {{> pager}} |
61 | {{else}} | 62 | {{else}} |
62 | {{#with orders}} | 63 | {{#with orders}} |
63 | {{> empty}} | 64 | {{> empty}} |
public/img/home/icon-warn.png
0 → 100644

735 Bytes
@@ -4,13 +4,16 @@ | @@ -4,13 +4,16 @@ | ||
4 | * @date: 2016/2/26 | 4 | * @date: 2016/2/26 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | -var $ = require('yoho-jquery'); | 7 | +var $ = require('yoho-jquery'), |
8 | + Handlebars = require('yoho-handlebars'), | ||
9 | + dialog = require('../common/dialog'); | ||
8 | 10 | ||
9 | var $returnState = $('.visual-return-state li'), | 11 | var $returnState = $('.visual-return-state li'), |
10 | $detail = $('.detail-container'), | 12 | $detail = $('.detail-container'), |
11 | $courierCode = $('.courier-code'), | 13 | $courierCode = $('.courier-code'), |
12 | $expressCompany = $('#express-company'), | 14 | $expressCompany = $('#express-company'), |
13 | $expressNumber = $('#express-number'), | 15 | $expressNumber = $('#express-number'), |
16 | + $expressName = $('#express-name'), | ||
14 | $expressViewBox = $('.express-view-box > span'); | 17 | $expressViewBox = $('.express-view-box > span'); |
15 | 18 | ||
16 | var returnId = $('#return-id').val(), | 19 | var returnId = $('#return-id').val(), |
@@ -20,6 +23,10 @@ var returnId = $('#return-id').val(), | @@ -20,6 +23,10 @@ var returnId = $('#return-id').val(), | ||
20 | expList = {}, | 23 | expList = {}, |
21 | isChange = false; | 24 | isChange = false; |
22 | 25 | ||
26 | +var Dialog = dialog.Dialog, | ||
27 | + active, | ||
28 | + cancelApplyDialog = '<p class="message-title"><i class="{{messageIcon}}"></i>{{messageTitle}}</p><p class="message-summary">{{messageSummary}}</p>'; // eslint-disable-line | ||
29 | + | ||
23 | function syncExpressInfo() { | 30 | function syncExpressInfo() { |
24 | expCompany = expList[expId] ? expList[expId] : ''; | 31 | expCompany = expList[expId] ? expList[expId] : ''; |
25 | $expressViewBox.html(expCompany + ' 快递单号:' + expNumber); | 32 | $expressViewBox.html(expCompany + ' 快递单号:' + expNumber); |
@@ -27,20 +34,35 @@ function syncExpressInfo() { | @@ -27,20 +34,35 @@ function syncExpressInfo() { | ||
27 | $expressNumber.val(expNumber); | 34 | $expressNumber.val(expNumber); |
28 | } | 35 | } |
29 | 36 | ||
37 | +// 其他快递公司需要填写物流 | ||
38 | +$expressCompany.on('change', function() { | ||
39 | + if (+$(this).val() === 100) { | ||
40 | + $expressName.removeClass('hide'); | ||
41 | + } else { | ||
42 | + $expressName.addClass('hide'); | ||
43 | + } | ||
44 | +}); | ||
45 | + | ||
30 | function validateExpress() { | 46 | function validateExpress() { |
31 | var send = {}; | 47 | var send = {}; |
32 | 48 | ||
33 | send.number = $expressNumber.val(); | 49 | send.number = $expressNumber.val(); |
34 | send.id = $expressCompany.val() * 1; | 50 | send.id = $expressCompany.val() * 1; |
51 | + send.name = expList[send.id]; | ||
52 | + | ||
53 | + if (send.id === 100) { | ||
54 | + send.name = $expressName.val(); | ||
55 | + } | ||
35 | 56 | ||
36 | if (!send.id) { | 57 | if (!send.id) { |
37 | - alert('请选择快递公司'); | 58 | + new dialog.Alert('请选择快递公司').show(); |
59 | + } else if (!send.name) { | ||
60 | + new dialog.Alert('请填写快递公司').show(); | ||
38 | } else if (!send.number) { | 61 | } else if (!send.number) { |
39 | - alert('请填入快递单号'); | 62 | + new dialog.Alert('请填入快递单号').show(); |
40 | } else { | 63 | } else { |
41 | return send; | 64 | return send; |
42 | } | 65 | } |
43 | - | ||
44 | return false; | 66 | return false; |
45 | } | 67 | } |
46 | 68 | ||
@@ -59,7 +81,7 @@ function sendExpressCode() { | @@ -59,7 +81,7 @@ function sendExpressCode() { | ||
59 | isChange: isChange, | 81 | isChange: isChange, |
60 | expressId: sendParm.id, | 82 | expressId: sendParm.id, |
61 | expressNumber: sendParm.number, | 83 | expressNumber: sendParm.number, |
62 | - expressCompany: expList[sendParm.id] | 84 | + expressCompany: sendParm.name |
63 | } | 85 | } |
64 | }).then(function(jsonData) { | 86 | }).then(function(jsonData) { |
65 | if (jsonData.code === 200) { | 87 | if (jsonData.code === 200) { |
@@ -67,13 +89,57 @@ function sendExpressCode() { | @@ -67,13 +89,57 @@ function sendExpressCode() { | ||
67 | expNumber = sendParm.number; | 89 | expNumber = sendParm.number; |
68 | $returnState.eq(2).addClass('act'); | 90 | $returnState.eq(2).addClass('act'); |
69 | } else { | 91 | } else { |
70 | - alert(jsonData.message); | 92 | + new dialog.Alert(jsonData.message).show(); |
71 | } | 93 | } |
72 | syncExpressInfo(); | 94 | syncExpressInfo(); |
73 | $courierCode.removeClass('in-edit'); | 95 | $courierCode.removeClass('in-edit'); |
74 | }); | 96 | }); |
75 | } | 97 | } |
76 | 98 | ||
99 | +function cancelApply(id, url) { | ||
100 | + var template = Handlebars.compile(cancelApplyDialog); | ||
101 | + var html = template({messageIcon: 'icon-warn', messageTitle: '取消申请', messageSummary: '您确定要请取消申请吗?'}); | ||
102 | + var options = { | ||
103 | + mask: true, | ||
104 | + btns: [ | ||
105 | + { | ||
106 | + id: 'cancel-sure', | ||
107 | + name: '确定', | ||
108 | + btnClass: ['cancel-sure'], | ||
109 | + cb: function() { | ||
110 | + $.ajax({ | ||
111 | + type: 'POST', | ||
112 | + url: url, | ||
113 | + data: { | ||
114 | + id: id | ||
115 | + } | ||
116 | + }).then(function(data) { | ||
117 | + active.close(); | ||
118 | + if (data.code === 200) { | ||
119 | + location.reload(); | ||
120 | + } else { | ||
121 | + new dialog.Alert(data.message).show(); | ||
122 | + } | ||
123 | + }); | ||
124 | + } | ||
125 | + }, | ||
126 | + { | ||
127 | + id: 'cancel-no', | ||
128 | + name: '取消', | ||
129 | + btnClass: ['cancel-no'], | ||
130 | + cb: function() { | ||
131 | + active.close(); | ||
132 | + } | ||
133 | + } | ||
134 | + ], | ||
135 | + content: html, | ||
136 | + className: 'returns-cancel-dialog' | ||
137 | + }; | ||
138 | + | ||
139 | + return new Dialog(options); | ||
140 | +} | ||
141 | + | ||
142 | + | ||
77 | if ($detail.parent().hasClass('exchange-detail')) { | 143 | if ($detail.parent().hasClass('exchange-detail')) { |
78 | isChange = true; | 144 | isChange = true; |
79 | } | 145 | } |
@@ -93,3 +159,8 @@ $('#modify').click(function() { | @@ -93,3 +159,8 @@ $('#modify').click(function() { | ||
93 | $('#submit-btn').click(function() { | 159 | $('#submit-btn').click(function() { |
94 | sendExpressCode(); | 160 | sendExpressCode(); |
95 | }); | 161 | }); |
162 | + | ||
163 | +$('.cancel-trigger').click(function() { | ||
164 | + active = cancelApply($(this).data('id'), $(this).data('url')); | ||
165 | + active.show(); | ||
166 | +}); |
@@ -47,3 +47,65 @@ | @@ -47,3 +47,65 @@ | ||
47 | } | 47 | } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | + | ||
51 | +.returns-cancel-dialog{ | ||
52 | + width: 350px; | ||
53 | + background: #fff; | ||
54 | + padding: 20px 30px 35px 30px; | ||
55 | + .message-title{ | ||
56 | + margin-top: 40px; | ||
57 | + margin-bottom: 27px; | ||
58 | + font-size: 24px; | ||
59 | + font-weight: 700; | ||
60 | + } | ||
61 | + .message-summary{ | ||
62 | + width: 250px; | ||
63 | + margin: 0 auto 22px; | ||
64 | + font-size: 14px; | ||
65 | + word-wrap: break-word; | ||
66 | + line-height: 20px; | ||
67 | + color: #444; | ||
68 | + } | ||
69 | + .btns { | ||
70 | + padding: 15px 30px 0; | ||
71 | + text-align: center; | ||
72 | + | ||
73 | + .btn { | ||
74 | + height: 35px; | ||
75 | + font-size: 15px; | ||
76 | + line-height: 35px; | ||
77 | + } | ||
78 | + | ||
79 | + .cancel-sure { | ||
80 | + width: 130px; | ||
81 | + color: #fff; | ||
82 | + background: #000; | ||
83 | + border: none; | ||
84 | + } | ||
85 | + | ||
86 | + .cancel-no { | ||
87 | + margin-left: 30px; | ||
88 | + background: #fff; | ||
89 | + color: #000; | ||
90 | + border-color: #000; | ||
91 | + width: 126px; | ||
92 | + } | ||
93 | + } | ||
94 | + .close{ | ||
95 | + top: 15px; | ||
96 | + right: 15px; | ||
97 | + .iconfont{ | ||
98 | + font-size: 30px; | ||
99 | + } | ||
100 | + } | ||
101 | + .icon-warn{ | ||
102 | + display: inline-block; | ||
103 | + margin-right: 10px; | ||
104 | + background: url('/home/icon-warn.png') no-repeat; | ||
105 | + width: 30px; | ||
106 | + height: 30px; | ||
107 | + vertical-align: -6px; | ||
108 | + } | ||
109 | +} | ||
110 | + | ||
111 | + |
-
Please register or login to post a comment