Authored by biao

update for change type

... ... @@ -213,6 +213,15 @@ const getUnion = (req, res, next) => {
}).catch(next);
};
const getChangeType = (req, res, next) => {
const uid = req.user.uid;
const areaCode = req.query.areaCode;
returns.getChangeType(uid, areaCode).then(result => {
res.json(result);
}).catch(next);
};
module.exports = {
index,
refund,
... ... @@ -224,5 +233,6 @@ module.exports = {
exchangeSubmit,
cancelApply,
setEepress,
getUnion
getUnion,
getChangeType
};
... ...
... ... @@ -192,6 +192,23 @@ const getRefundBank = () => {
});
};
/**
* 获取换货类型API
* @param { number } uid 用户uid
* @param { number } areaCode 地区码
* @return { Object } 换货类型
*/
const getChangeTypeAsync = (uid, areaCode) => {
return api.get('', {
method: 'app.change.getDelivery',
uid: uid,
area_code: areaCode
}, {
code: 200
});
};
module.exports = {
getExpressCompanyAsync,
getOrderInfoAsync,
... ... @@ -204,6 +221,7 @@ module.exports = {
changeSubmitAsync,
setExpressNumberAsync,
cancelReturnAsync,
getRefundBank
getRefundBank,
getChangeTypeAsync
};
... ...
... ... @@ -587,6 +587,27 @@ const getProductInfo = (productId, productSkn) => {
});
};
// `
/**
* 获取换货类型
* @param { number } uid 用户uid
* @param { number } areaCode 地区码
* @return { Object } 换货类型
*/
const getChangeType = (uid, areaCode) => {
return returnsAPI.getChangeTypeAsync(uid, areaCode).then(result => {
camelCase(result);
if (result.data) {
result.data.forEach(data => {
data.isDefault = data.isDefault === 'Y';
});
}
return result;
});
};
/**
* 获取换货商品列表
* @function getChangeGoodsList
... ... @@ -729,5 +750,6 @@ module.exports = {
submitChange,
cancelReturnApply,
setBackEepress,
getUnionData
getUnionData,
getChangeType
};
... ...
... ... @@ -45,6 +45,7 @@ router.post('/return/setEepress', returns.setEepress);
router.get('/return/getProductInfo', returns.getProductInfo);
router.get('/return/submitExchange', returns.exchangeSubmit);
router.get('/return/unionInfo', returns.getUnion);
router.get('/return/getChangeType', returns.getChangeType);
// 个人中心首页/收货地址
router.get('/address', auth, address.index);
... ...
... ... @@ -53,8 +53,6 @@
</div>
<div class="change-type">
<span class="box-title">换货方式</span>
<span class="type active" data-type="10">寄回换货</span>
<span class="type" data-type="11">上门取货</span>
</div>
{{#address}}
... ...
... ... @@ -15,6 +15,7 @@ var phoneReg = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
var validate = require('./order/validation');
var imgBoxTpl = require('../../tpl/me/thumbnail.hbs');
var changeTypeTpl = require('../../tpl/me/change-type.hbs');
var validateMap = {
user: {
... ... @@ -462,13 +463,33 @@ function bindKeyUpEvent() {
});
}
function getChangeType(areaCode) {
$.ajax({
url: '/me/return/getChangeType',
data: {
areaCode: areaCode
}
}).done(function(result) {
var changeTypeHtml = changeTypeTpl({
type: result.data
});
if (changeTypeHtml.length) {
$('.change-type .box-title').after(changeTypeHtml);
bindTypeEvent();
}
});
}
$(document).on('ready', function() {
var areaCode = $('#city').data('code');
getProductInfo();
getChangeType(areaCode);
initAddr(areaCode);
bindSelectEvent();
bindTypeEvent();
bindCheckboxEvent();
bindConfirmEvent();
initAddr($('#city').data('code'));
bindBlurEvent();
bindUploadEvent();
bindKeyUpEvent();
... ...
... ... @@ -105,9 +105,10 @@
.type {
display: inline-block;
width: 120px;
min-width: 120px;
height: 40px;
line-height: 40px;
padding: 0 10px;
margin-right: 15px;
border: 1px solid #f1f1f1;
text-align: center;
... ...
{{#type}}
<span class="type {{#if isDefault}}active{{/if}}" data-type="{{id}}">{{name}}</span>
{{/type}}
... ...