Authored by hongweigao

Merge branch 'release/5.4.1' of http://git.yoho.cn/fe/yohobuy-node into release/5.4.1

... ... @@ -27,6 +27,11 @@ const index = (req, res, next) => {
stepper: stepper
});
// 预售购物车不支持使用优惠券
if (req.query.type === '2') {
result.notUseCoupon = true;
}
res.render('order-ensure2016', {
title: '填写订单 | ' + (res.locals.title || ''),
page: 'ensure',
... ...
... ... @@ -56,17 +56,28 @@ const handleUseYohoCoin = (info) => {
const handlePaymentInfo = (d, address) => {
let resData = {};
let defAddrId = _.get(d, 'delivery_address.address_id', 0);
_.forEach(address, dd => {
if (dd.is_default === 'Y') {
dd.default = true;
}
// 三级地址默认4级显示全部
if (dd.area_code && dd.area_code.length === 6) {
dd.area += ' 全部';
}
// 地址加密
let id = dd.address_id;
dd.id = crypto.encryption('', `${id}`);
// 设置默认选中地址
if (id === defAddrId) {
dd.selected = true;
}
// 删除uid,用户数据保密
_.unset(dd, 'address_id');
_.unset(dd, 'uid');
... ...
... ... @@ -8,7 +8,7 @@
<div class="block-title">收货信息<span id="new-address-btn" class="right">新增收货地址 <i>+</i></span></div>
<div id="addr-list" class="addr-list clearfix">
{{# deliveryAddress}}
<div class="addr-item{{#isY is_default}} addr-default addr-select{{/isY}}" data-id="{{id}}" data-consignee="{{consignee}}" data-mobile="{{mobile}}" data-phone="{{phone}}" data-area="{{area}}" data-code="{{area_code}}" data-address="{{address}}"{{#isY is_default}} data-default="1"{{/isY}}{{#isY is_delivery}} data-delivery="1"{{/isY}}{{#isY is_cash_delivery}} data-cashdelivery="1"{{/isY}}>
<div class="addr-item{{#isY is_default}} addr-default{{/isY}}{{#if selected}} addr-select{{/if}}" data-id="{{id}}" data-consignee="{{consignee}}" data-mobile="{{mobile}}" data-phone="{{phone}}" data-area="{{area}}" data-code="{{area_code}}" data-address="{{address}}"{{#isY is_default}} data-default="1"{{/isY}}{{#isY is_delivery}} data-delivery="1"{{/isY}}{{#isY is_cash_delivery}} data-cashdelivery="1"{{/isY}}>
<p class="name">
{{consignee}}
<span class="right">{{mobile}}</span>
... ... @@ -166,52 +166,58 @@
{{# shoppingCartData}}
<div class="extra-wrap">
<dl>
<dt id="use-coupons" class="use-coupons">
<span class="locker-switch"></span>使用优惠券/优惠码
<div class="tip-box right">
<p>优惠码不可与优惠券同时使用</p>
<p class="coupon-err-tip"></p>
</div>
</dt>
<dd>
<div class="coupon-opt-title">
<label class="radio-btn on">使用优惠券</label>
<label class="radio-btn code">使用优惠码</label>
<span class="ticket-use-tip hide">
已成功使用<em class="red num">1</em>张优惠券,<em class="red price"></em>
<b class="cancel-use-ticket">取消使用</b>
</span>
<div class="opt-area right">
<input type="text" class="coupon-code">
<label class="sure-use-code fw300">直接使用</label>
<label class="sure-use-ticket fw300">确定</label>
{{#unless ../notUseCoupon}}
<dt id="use-coupons" class="use-coupons">
<span class="locker-switch"></span>使用优惠券/优惠码
<div class="tip-box right">
<p>优惠码不可与优惠券同时使用</p>
<p class="coupon-err-tip"></p>
</div>
</div>
<div class="coupon-list-wrap"></div>
</dd>
<dt><span class="locker-switch"></span>使用YOHO币</dt>
<dd id="yoho-coin-box" class="yoho-coin-box" data-coin="{{usedCoinNum}}" data-max={{canUseCoinNum}}>
<div class="outer-view">
<p class="coin-err-tip">{{coinErrorTip}}</p>
<p>有货币满<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>的整数倍</p>
<i class="help-icon"></i>
<div class="coin-tip-help">
<p>有货币使用提示:</p>
<p>
1.订单金额大于20元(含20元)<br>
2.有货币数量大于{{yoho_coin_pay_rule.num_limit}}个(含{{yoho_coin_pay_rule.num_limit}}个) <br>
3.有货币支付上限为每笔订单应付金额的{{yoho_coin_pay_rule.max_pay_rate_desc}}
</p>
<p class="rs-text">备注:使用有货币数量为{{yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元</p>
</dt>
<dd>
<div class="coupon-opt-title">
<label class="radio-btn on">使用优惠券</label>
<label class="radio-btn code">使用优惠码</label>
<span class="ticket-use-tip hide">
已成功使用<em class="red num">1</em>张优惠券,<em class="red price"></em>
<b class="cancel-use-ticket">取消使用</b>
</span>
<div class="opt-area right">
<input type="text" class="coupon-code">
<label class="sure-use-code fw300">直接使用</label>
<label class="sure-use-ticket fw300">确定</label>
</div>
</div>
</div>
<div class="coin-main-view">
<p>本次使用有货币<span class="red">{{canUseCoinNum}}</span>个,抵扣 <span class="red">¥{{yoho_coin}}</span></p>
<p class="grey fw300">您当前共有有货币 <span class="red">{{total_yoho_coin_num}}</span> 个,可用 <span class="red">{{canUseCoinNum}}</span></p>
<label class="coin-cancel-btn fw300">取消使用</label>
<label class="coin-use-btn">确定</label>
</div>
</dd>
<div class="coupon-list-wrap"></div>
</dd>
{{/unless}}
{{#unless ../notUseYohoCoin}}
<dt><span class="locker-switch"></span>使用YOHO币</dt>
<dd id="yoho-coin-box" class="yoho-coin-box" data-coin="{{usedCoinNum}}" data-max={{canUseCoinNum}} data-total="{{total_yoho_coin_num}}">
<div class="outer-view">
<p class="coin-err-tip">{{coinErrorTip}}</p>
<p>有货币满<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>的整数倍</p>
<i class="help-icon"></i>
<div class="coin-tip-help">
<p>有货币使用提示:</p>
<p>
1.订单金额大于20元(含20元)<br>
2.有货币数量大于{{yoho_coin_pay_rule.num_limit}}个(含{{yoho_coin_pay_rule.num_limit}}个) <br>
3.有货币支付上限为每笔订单应付金额的{{yoho_coin_pay_rule.max_pay_rate_desc}}
</p>
<p class="rs-text">备注:使用有货币数量为{{yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元</p>
</div>
</div>
<div class="coin-main-view">
<p>本次使用有货币<span class="red">{{canUseCoinNum}}</span>个,抵扣 <span class="red">¥{{yoho_coin}}</span></p>
<p class="grey fw300">您当前共有有货币 <span class="red">{{total_yoho_coin_num}}</span> 个,可用 <span class="red">{{canUseCoinNum}}</span></p>
<label class="coin-cancel-btn fw300">取消使用</label>
<label class="coin-use-btn">确定</label>
</div>
</dd>
{{/unless}}
{{#if redEnvelopes}}
<dt><span class="locker-switch"></span>使用红包</dt>
<dd id="red-packet-box" class="red-packet-box">
... ...
... ... @@ -66,8 +66,6 @@ function compute(coin, cb) {
coin: coin ? coin : 0
};
order.coin = reqData.coin;
// 支付方式
if (order.paymentType) {
reqData.paymentType = order.paymentType;
... ... @@ -85,6 +83,11 @@ function compute(coin, cb) {
reqData.promotionCode = order.promotionCode;
}
// 有货币(保证更改其他价格yoho币不清零,调接口传最大数量,接口限制可使用数量)
if (!coin && order.coin) {
reqData.coin = yohoCoin.totalCoin;
}
// 红包
if (order.redEnvelopes) {
reqData.redEnvelopes = order.redEnvelopes;
... ... @@ -100,14 +103,14 @@ function compute(coin, cb) {
if (data.code === 200) {
res = data.data;
// update order used yoho coin
order.coin = res.usedCoinNum;
// update yoho coin max use num
yohoCoin.maxCoin = res.canUseCoinNum;
// update yoho coin using
yohoCoin.$el.html(coinTpl(res));
if (!reqData.coin) {
yohoCoin.$el.removeClass('used');
}
// update last order amount
$orderPrice.html('¥ ' + res.last_order_amount);
... ... @@ -115,18 +118,11 @@ function compute(coin, cb) {
// update promotion formula list
$balanceDetail.html(promotionTpl(res));
// callback
if (cb && typeof cb === 'function') {
return cb();
}
} else if (data.code === 317) {
if (coupon.$errorTip) {
coupon.$errorTip.text(data.message);
}
if (order.couponCode) {
delete order.couponCode;
}
}
// callback
if (cb && typeof cb === 'function') {
return cb(data);
}
});
}
... ... @@ -498,8 +494,16 @@ coupon = {
order.promotionCode = couponId;
// 重新计算订单价格
compute(0, function() {
that.close();
compute(0, function(resData) {
if (resData.code === 200) {
that.close();
} else {
that.$errorTip.text(resData.message);
if (order.promotionCode) {
delete order.promotionCode;
}
}
});
}
}).on('click', '.coupon-radio', function() {
... ... @@ -576,6 +580,7 @@ yohoCoin = {
if (data) {
order.coin = data.coin || 0;
this.maxCoin = data.max;
this.totalCoin = data.total;
}
this.eventBind();
... ... @@ -591,6 +596,7 @@ yohoCoin = {
that.close();
}).on('click', '.coin-cancel-btn', function() {
if (order.coin * 1 !== 0) {
order.coin = 0;
compute();
}
... ...