Authored by htoooth

Merge branch 'release/1.0' of http://git.yoho.cn/fe/yoho-blk into release/1.0

@@ -205,6 +205,17 @@ const setEepress = (req, res, next) => { @@ -205,6 +205,17 @@ const setEepress = (req, res, next) => {
205 }).catch(next); 205 }).catch(next);
206 }; 206 };
207 207
  208 +/**
  209 + * 获取银行列表
  210 + * @function setEepress
  211 + * @return { Object } 银行列表
  212 + */
  213 +const getUnion = (req, res, next) => {
  214 + returns.getUnionData().then(result => {
  215 + res.json(result);
  216 + }).catch(next);
  217 +};
  218 +
208 module.exports = { 219 module.exports = {
209 index, 220 index,
210 refund, 221 refund,
@@ -215,5 +226,6 @@ module.exports = { @@ -215,5 +226,6 @@ module.exports = {
215 exchangeDeatail, 226 exchangeDeatail,
216 exchangeSubmit, 227 exchangeSubmit,
217 cancelApply, 228 cancelApply,
218 - setEepress 229 + setEepress,
  230 + getUnion
219 }; 231 };
@@ -101,6 +101,12 @@ const cancelReturnAsync = (id, uid, isChange) => { @@ -101,6 +101,12 @@ const cancelReturnAsync = (id, uid, isChange) => {
101 }); 101 });
102 }; 102 };
103 103
  104 +const getRefundBank = () => {
  105 + return api.get('', {
  106 + method: 'app.refund.refundBank'
  107 + });
  108 +};
  109 +
104 module.exports = { 110 module.exports = {
105 getExpressCompanyAsync, 111 getExpressCompanyAsync,
106 getOrderInfoAsync, 112 getOrderInfoAsync,
@@ -112,6 +118,7 @@ module.exports = { @@ -112,6 +118,7 @@ module.exports = {
112 getExchangeDetail, 118 getExchangeDetail,
113 changeSubmitAsync, 119 changeSubmitAsync,
114 setExpressNumberAsync, 120 setExpressNumberAsync,
115 - cancelReturnAsync 121 + cancelReturnAsync,
  122 + getRefundBank
116 }; 123 };
117 124
@@ -250,6 +250,33 @@ const _setRefundGoodList = (data) => { @@ -250,6 +250,33 @@ const _setRefundGoodList = (data) => {
250 } 250 }
251 resData.speclialReason = data.special_return_reason; 251 resData.speclialReason = data.special_return_reason;
252 252
  253 + let returnMode = [];
  254 +
  255 + _.forEach(data.return_amount_mode, value => {
  256 + let mode = {
  257 + title: value.name,
  258 + id: value.id,
  259 + cur: value.is_default === 'Y'
  260 + };
  261 +
  262 + // 退货类型根据id匹配
  263 + switch (mode.id) {
  264 + case 2:
  265 + mode.class = 'ali-item';
  266 + mode.alipay = true;
  267 + break;
  268 + case 3:
  269 + mode.class = 'union-item';
  270 + mode.unionpay = true;
  271 + break;
  272 + default:
  273 + mode.name = value.name;
  274 + break;
  275 + }
  276 + returnMode.push(mode);
  277 + });
  278 + resData.returnMode = returnMode;
  279 +
253 return resData; 280 return resData;
254 }; 281 };
255 282
@@ -646,6 +673,22 @@ const setBackEepress = (uid, param) => { @@ -646,6 +673,22 @@ const setBackEepress = (uid, param) => {
646 }); 673 });
647 }; 674 };
648 675
  676 +/**
  677 + * 获取银行列表
  678 + * @function getUnionData
  679 + * @return { Object } 银行列表数据
  680 + */
  681 +const getUnionData = () => {
  682 + return returnsAPI.getRefundBank().then(result => {
  683 + let resData = result || {
  684 + code: 400,
  685 + message: '获取银行列表失败'
  686 + };
  687 +
  688 + return resData;
  689 + });
  690 +};
  691 +
649 module.exports = { 692 module.exports = {
650 getUserReturn, 693 getUserReturn,
651 getRefundGoodsData, 694 getRefundGoodsData,
@@ -656,5 +699,6 @@ module.exports = { @@ -656,5 +699,6 @@ module.exports = {
656 getExchangeDetailData, 699 getExchangeDetailData,
657 submitChange, 700 submitChange,
658 cancelReturnApply, 701 cancelReturnApply,
659 - setBackEepress 702 + setBackEepress,
  703 + getUnionData
660 }; 704 };
@@ -45,6 +45,7 @@ router.post('/return/cancel', returns.cancelApply); @@ -45,6 +45,7 @@ router.post('/return/cancel', returns.cancelApply);
45 router.post('/return/setEepress', returns.setEepress); 45 router.post('/return/setEepress', returns.setEepress);
46 router.get('/return/getProductInfo', returns.getProductInfo); 46 router.get('/return/getProductInfo', returns.getProductInfo);
47 router.get('/return/submitExchange', returns.exchangeSubmit); 47 router.get('/return/submitExchange', returns.exchangeSubmit);
  48 +router.get('/return/unionInfo', returns.getUnion);
48 49
49 // 个人中心首页/收货地址 50 // 个人中心首页/收货地址
50 router.get('/address', auth, address.index); 51 router.get('/address', auth, address.index);
@@ -46,28 +46,32 @@ @@ -46,28 +46,32 @@
46 46
47 <div class="refund-type"> 47 <div class="refund-type">
48 <div> 48 <div>
49 - <label class="type-item ali-item cur" title="支付宝"></label>  
50 - <label class="type-item union-item" title="银行卡"></label> 49 + {{# returnMode}}
  50 + <label class="type-item {{class}}{{#if cur}} cur{{/if}}" title="{{title}}" data-id="{{id}}">{{name}}</label>
  51 + {{/ returnMode}}
51 </div> 52 </div>
52 - <dl class="alipay">  
53 - <dd>账号:<input type="text" class="name" placeholder="收款人支付宝账号"></dd>  
54 - <dd>姓名:<input type="text" class="account" placeholder="姓名"></dd>  
55 - </dl>  
56 - <dl class="unionpay hide">  
57 - <dd>  
58 - 银行:  
59 - <select class="bank">  
60 - <option>中国银行</option>  
61 - <option>中国农业银行</option>  
62 - <option>中国工商银行</option>  
63 - <option>中国建设银行</option>  
64 - </select>  
65 - <input type="text" placeholder="开户支行">  
66 - <span class="blue" class="area">例:江苏省南京市奥体支行</span>  
67 - </dd>  
68 - <dd>账号:<input type="text" class="account" placeholder="收款人银行卡号"></dd>  
69 - <dd>姓名:<input type="text" class="name" placeholder="姓名"></dd>  
70 - </dl> 53 + {{# returnMode}}
  54 + {{#if alipay}}
  55 + <dl class="alipay mode{{id}} hide">
  56 + <dd>账号:<input type="text" class="name" placeholder="收款人支付宝账号"></dd>
  57 + <dd>姓名:<input type="text" class="account" placeholder="姓名"></dd>
  58 + </dl>
  59 + {{/if}}
  60 + {{#if unionpay}}
  61 + <dl class="unionpay mode{{id}} hide">
  62 + <dd>
  63 + 银行:
  64 + <select class="bank">
  65 + <option>请选择银行</option>
  66 + </select>
  67 + <input type="text" placeholder="开户支行" class="open-bank">
  68 + <span class="blue" class="area">例:江苏省南京市奥体支行</span>
  69 + </dd>
  70 + <dd>账号:<input type="text" class="account" placeholder="收款人银行卡号"></dd>
  71 + <dd>姓名:<input type="text" class="name" placeholder="姓名"></dd>
  72 + </dl>
  73 + {{/if}}
  74 + {{/ returnMode}}
71 </div> 75 </div>
72 <div class="opt-btn"> 76 <div class="opt-btn">
73 <span class="apply-tip blue hide">请填写完整</span> 77 <span class="apply-tip blue hide">请填写完整</span>
@@ -11,21 +11,21 @@ var $ = require('yoho-jquery'), @@ -11,21 +11,21 @@ var $ = require('yoho-jquery'),
11 var $refundTable = $('.refund-goods'), 11 var $refundTable = $('.refund-goods'),
12 $check = $('.check'), 12 $check = $('.check'),
13 $refundType = $('.refund-type'), 13 $refundType = $('.refund-type'),
14 - $typeInfo = $refundType.children('dl'); 14 + $typeInfo = $refundType.children('dl'),
  15 + $bankSelect = $refundType.find('.unionpay .bank');
15 16
16 var $applyBtn = $('#apply-btn'); 17 var $applyBtn = $('#apply-btn');
17 18
18 var orderCode = $('#order-code').val() || 0, 19 var orderCode = $('#order-code').val() || 0,
19 specialReason = $refundTable.data() || {}, 20 specialReason = $refundTable.data() || {},
20 payInfo = { // 退款信息 21 payInfo = { // 退款信息
21 - type: 3, // 2--银行卡 3--支付宝 4--yoho币  
22 - dom: $typeInfo.eq(0) 22 + type: $refundType.find('.type-item.cur').data('id') // 1--原卡返回 2--银行卡 3--支付宝 4--yoho币
23 }; 23 };
24 24
25 -var tpl = '<div class="img-wrap">' + 25 +var tpl = '<div class="img-wrap" data-img="{{data}}">' +
26 '<div class="img-opt">' + 26 '<div class="img-opt">' +
27 - '<span>查看</span>' +  
28 - '<span>删除</span>' + 27 + '<span class="review-upimg">查看</span>' +
  28 + '<span class="cancel-upimg">删除</span>' +
29 '</div>' + 29 '</div>' +
30 '<div class="img-view"><img src="{{data}}"></div>' + 30 '<div class="img-view"><img src="{{data}}"></div>' +
31 '</div>', 31 '</div>',
@@ -37,6 +37,47 @@ require('../plugins/check'); @@ -37,6 +37,47 @@ require('../plugins/check');
37 37
38 lazyload($('img.lazy')); 38 lazyload($('img.lazy'));
39 39
  40 +function setUnionList(list) {
  41 + var i, html = '';
  42 +
  43 + if (list && list.length) {
  44 + for (i = 0; i < list.length; i++) {
  45 + html += '<option>' + list[i].title + '</option>';
  46 + }
  47 + $bankSelect.html(html);
  48 + }
  49 +}
  50 +
  51 +function getUnionList() {
  52 + var that = this;
  53 +
  54 + if (!this.geted) {
  55 + $.ajax({
  56 + type: 'GET',
  57 + url: '/me/return/unionInfo',
  58 + data: {},
  59 + success: function(data) {
  60 + if (data.code === 200) {
  61 + that.geted = true;
  62 + setUnionList(data.data);
  63 + }
  64 + }
  65 + });
  66 + }
  67 +}
  68 +
  69 +function changePayMode(id) {
  70 + payInfo.type = id;
  71 +
  72 + // 切换退款信息输入容器
  73 + payInfo.dom = $refundType.children('.mode' + payInfo.type);
  74 + $typeInfo.addClass('hide');
  75 + payInfo.dom.removeClass('hide');
  76 + getUnionList();
  77 +}
  78 +
  79 +changePayMode(payInfo.type);
  80 +
40 function restApplyBtn() { 81 function restApplyBtn() {
41 if (checked.documents && checked.documents.length) { 82 if (checked.documents && checked.documents.length) {
42 $applyBtn.removeClass('disable'); 83 $applyBtn.removeClass('disable');
@@ -67,6 +108,7 @@ function packApplyInfo() { @@ -67,6 +108,7 @@ function packApplyInfo() {
67 product_skc: data.skc, 108 product_skc: data.skc,
68 product_sku: data.sku 109 product_sku: data.sku
69 }; 110 };
  111 + var $special = $(dom[key]).siblings('.special-reason');
70 112
71 if (isLack || !data.reason) { 113 if (isLack || !data.reason) {
72 isLack = true; 114 isLack = true;
@@ -74,11 +116,24 @@ function packApplyInfo() { @@ -74,11 +116,24 @@ function packApplyInfo() {
74 } else { 116 } else {
75 good.returned_reason = data.reason; 117 good.returned_reason = data.reason;
76 118
77 - // if (specialReason.hasOwnProperty(data.reason)) {  
78 - // remark: ,  
79 - // returned_reason: 3,  
80 - // evidence_images: ,  
81 - // } 119 + if (specialReason.hasOwnProperty(data.reason)) {
  120 + good.remark = $special.find('.mark-text').val();
  121 + if (!good.remark) {
  122 + isLack = true;
  123 + }
  124 +
  125 + good.evidence_images = [];
  126 + $special.find('.img-wrap').each(function() {
  127 + var img = $(this).data('img');
  128 +
  129 + if (img) {
  130 + good.evidence_images.push(img);
  131 + }
  132 + });
  133 + if (!good.evidence_images.length) {
  134 + isLack = true;
  135 + }
  136 + }
82 } 137 }
83 resData.goods.push(good); 138 resData.goods.push(good);
84 }); 139 });
@@ -91,6 +146,7 @@ function packApplyInfo() { @@ -91,6 +146,7 @@ function packApplyInfo() {
91 switch (payInfo.type) { 146 switch (payInfo.type) {
92 case 2: 147 case 2:
93 payment.bank_name = payInfo.dom.find('.bank').val(); 148 payment.bank_name = payInfo.dom.find('.bank').val();
  149 + payment.bank_name += '-' + payInfo.dom.find('.open-bank').val();
94 payment.bank_card = payInfo.dom.find('.account').val(); 150 payment.bank_card = payInfo.dom.find('.account').val();
95 payment.payee_name = payInfo.dom.find('.name').val(); 151 payment.payee_name = payInfo.dom.find('.name').val();
96 break; 152 break;
@@ -99,7 +155,6 @@ function packApplyInfo() { @@ -99,7 +155,6 @@ function packApplyInfo() {
99 payment.alipay_name = payInfo.dom.find('.name').val(); 155 payment.alipay_name = payInfo.dom.find('.name').val();
100 break; 156 break;
101 default: 157 default:
102 - isLack = true;  
103 break; 158 break;
104 } 159 }
105 160
@@ -140,38 +195,44 @@ $refundTable.on('change', '.refund-reason', function() { @@ -140,38 +195,44 @@ $refundTable.on('change', '.refund-reason', function() {
140 } 195 }
141 $specialDom.siblings('.check').data({reason: val}); 196 $specialDom.siblings('.check').data({reason: val});
142 }).on('click', '.img-upload', function() { 197 }).on('click', '.img-upload', function() {
143 - var $this = $(this); 198 + var $this = $(this),
  199 + num = $this.data('num') || 0;
  200 +
  201 + if (num > 3) {
  202 + return;
  203 + }
144 204
145 upload.up({ 205 upload.up({
146 callback: function(result) { 206 callback: function(result) {
147 if (result && result.code === 200) { 207 if (result && result.code === 200) {
148 $this.before(imgFn(result)); 208 $this.before(imgFn(result));
  209 + $this.siblings('.img-up-tip').text(++num + '/4');
  210 + $this.data('num', num);
149 } 211 }
150 } 212 }
151 }); 213 });
152 -});  
153 - 214 +}).on('click', '.img-opt > span', function() {
  215 + var $this = $(this),
  216 + $wrap = $this.closest('.img-wrap'),
  217 + $upBtn = $wrap.siblings('.img-upload'),
  218 + num = $upBtn.data('num') || 0;
154 219
  220 + if ($this.hasClass('cancel-upimg')) {
  221 + $wrap.siblings('.img-up-tip').text(--num + '/4');
  222 + $wrap.remove();
  223 + $upBtn.data('num', num);
  224 + }
  225 +});
155 226
156 $refundType.on('click', '.type-item', function() { 227 $refundType.on('click', '.type-item', function() {
157 var $this = $(this), 228 var $this = $(this),
158 - index; 229 + id = $this.data('id');
159 230
160 if (!$this.hasClass('cur')) { 231 if (!$this.hasClass('cur')) {
161 - if ($this.hasClass('ali-item')) {  
162 - payInfo.type = 3;  
163 - } else {  
164 - payInfo.type = 2;  
165 - }  
166 - index = $this.index();  
167 -  
168 // 切换退款卡片 232 // 切换退款卡片
169 $this.addClass('cur').siblings('.cur').removeClass('cur'); 233 $this.addClass('cur').siblings('.cur').removeClass('cur');
170 234
171 - // 切换退款信息输入容器  
172 - payInfo.dom = $typeInfo.eq(index);  
173 - $typeInfo.addClass('hide');  
174 - payInfo.dom.removeClass('hide'); 235 + changePayMode(id);
175 } 236 }
176 }); 237 });
177 238
@@ -100,8 +100,11 @@ @@ -100,8 +100,11 @@
100 .type-item { 100 .type-item {
101 width: 118px; 101 width: 118px;
102 height: 38px; 102 height: 38px;
  103 + line-height: 38px;
  104 + text-align: center;
103 border: 1px solid #eee; 105 border: 1px solid #eee;
104 display: inline-block; 106 display: inline-block;
  107 + vertical-align: top;
105 margin-right: 16px; 108 margin-right: 16px;
106 cursor: pointer; 109 cursor: pointer;
107 110