Authored by 陈峰

Merge branch 'feature/cart' of http://git.yoho.cn/fe/yohobuywap-node into feature/cart

... ... @@ -91,11 +91,11 @@ exports.orderEnsure = (req, res, next) => {
orderEnsure: order,
userMobile: mobile,
pageHeader: headerData,
pageFooter: true,
pageFooter: false,
module: 'cart',
page: 'order-ensure',
width750: true,
title: '确认订单',
title: '确认订单'
};
res.render('order-ensure', viewData);
... ... @@ -300,7 +300,9 @@ exports.selectAddress = (req, res, next) => {
let uid = req.user.uid;
return addressModel.addressData(uid).then(address => {
let moreUrl = req.get('Referer') || '/cart/index/new/orderEnsure'; // 取跳过来的url
let moreUrl = (req.get('Referer') && !/\/home\/addressAct/.test(req.get('Referer'))) ?
req.get('Referer') : helpers.urlFormat('/cart/index/new/orderEnsure'); // 取跳过来的url
address = address.data;
... ...
... ... @@ -21,47 +21,11 @@ const transPrice = (price, isSepcialZero) => {
isSepcialZero = false;
}
if (price || isSepcialZero) {
price = price.toFixed(2);
}
return price;
};
/**
*有货币使用前端方案显示及是否可单击判断
*/
const _yohoCoinCompute = (orderCompute) => {
let yohoCoinData = {
totalYohoCoinNum: 0,
yohoCoin: 0,
useYohoCoin: 0,
yohoCoinClick: 0,
yohoCoinMsg: '',
yoho_coin_pay_rule: []
};
if (!orderCompute || !orderCompute.yoho_coin_pay_rule) {
return yohoCoinData;
}
_.assign(yohoCoinData, {
totalYohoCoinNum: orderCompute.total_yoho_coin_num ? parseInt(orderCompute.total_yoho_coin_num, 10) : 0,
yohoCoin: orderCompute.yoho_coin ? transPrice(orderCompute.yoho_coin) : 0,
useYohoCoin: orderCompute.use_yoho_coin ? transPrice(orderCompute.use_yoho_coin) : 0,
yoho_coin_pay_rule: orderCompute.yoho_coin_pay_rule
});
if (yohoCoinData.totalYohoCoinNum < 100) {
yohoCoinData.yohoCoinMsg = `共${yohoCoinData.totalYohoCoinNum}有货币,满${orderCompute.yoho_coin_pay_rule.num_limit}可用`;
} else if (yohoCoinData.useYohoCoin > 0 || yohoCoinData.yohoCoin > 0) {
yohoCoinData.yohoCoinMsg = '可抵¥' + (yohoCoinData.useYohoCoin > 0 ? yohoCoinData.useYohoCoin : yohoCoinData.yohoCoin);
yohoCoinData.yohoCoinClick = 1;
if ((price || isSepcialZero) && _.isNumber(price)) {
return price.toFixed(2);
} else {
yohoCoinData.yohoCoinMsg = '不满足有货币使用条件';
return price;
}
return yohoCoinData;
};
/**
... ... @@ -168,7 +132,7 @@ exports.orderCompute = (uid, cartType, deliveryWay, paymentType, couponCode, yoh
return shoppingAPI.orderComputeAPI(uid, cartType, deliveryWay, paymentType, couponCode, yohoCoin, skuList, activityInfo).then(result => {
if (result && result.data) {
result.data.use_yoho_coin = transPrice(result.data.use_yoho_coin);
result.data.yohoCoinCompute = _yohoCoinCompute(result.data);
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data);
return result.data;
} else {
return {};
... ... @@ -181,7 +145,7 @@ exports.ticketsOrderCompute = (uid, productSku, buyNumber, yohoCoin) => {
return shoppingAPI.checkTickets(uid, productSku, buyNumber, yohoCoin).then(result => {
if (result && result.data) {
result.data.shopping_cart_data.use_yoho_coin = transPrice(result.data.shopping_cart_data.use_yoho_coin);
result.data.yohoCoinCompute = _.yohoCoinCompute(result.data.shopping_cart_data);
result.data.yohoCoinCompute = paymentProcess.yohoCoinCompute(result.data.shopping_cart_data);
return result.data;
} else {
... ...
... ... @@ -165,6 +165,12 @@
{{/if}}
</section>
{{#if addressInfo}}
<div class="address-bottom">
<div class="back"></div>
<span>送至:{{addressInfo}}</span>
</div>
{{/if}}
<div class="bill">
您需要支付:<span>¥{{round price 2}}</span>
<a href="javascript:;">提交订单</a>
... ...
... ... @@ -6,13 +6,13 @@
<span class="tel">{{mobile}}</span>
<p class="address-info">{{area}} {{address}}</p>
<div class="action iconfont">
<span class="edit" href="/home/addressAct?id={{address_id}}&refer=shopping">&#xe61e;</span>
<span class="edit" data-href="/home/addressAct?id={{address_id}}&refer=shopping">&#xe61e;</span>
<span class="del" data-id="{{address_id}}">&#xe621;</span>
</div>
</div>
{{/ address}}
<a class="add-address" href="/home/addressAct?refer=shopping">
<a class="add-address" data-href="/home/addressAct?refer=shopping">
添加新地址
</a>
... ...
... ... @@ -73,7 +73,8 @@ exports.orderComputeAPI = (uid, cartType, deliveWay, paymentType, couponCode, yo
method: activityInfo ? 'app.Shopping.easyCompute' : 'app.Shopping.compute',
cart_type: cartType,
delive_way: deliveWay,
payment_type: paymentType
payment_type: paymentType,
uid: uid
};
if (couponCode) {
... ...
/**
* Created by PhpStorm.
* User: Targaryen
* Date: 2016/8/17
* Time: 13:55
*/
/**
* 地址管理
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/11/17
*/
var $ = require('yoho-jquery'),
tip = require('../../plugin/tip'),
loading = require('../../plugin/loading');
var $action = $('.action'),
$addAddress = $('.add-address'),
$footer = $('#yoho-footer'),
$confim = $('.confim-mask'),
$pageWrap = $('.page-wrap'),
$addressItem = $('.address-item'),
deleteId;
require('../../common');
$pageWrap.first().css('min-height', function() {
return $(window).height() - $('#yoho-header').height() - $footer.height();
});
window.rePosFooter();
$confim.on('touchend', '.cancel', function() {
deleteId = null;
$confim.fadeOut();
return false;
}).on('touchend', '.confim', function() {
loading.showLoadingMask();
$confim.fadeOut();
$.ajax({
method: 'POST',
url: '/home/delAddress',
data: {
id: deleteId
}
}).then(function(res) {
if ($.type(res) !== 'object') {
res = {};
}
if (res.code !== 200) {
tip.show(res.message || '网络出了点问题~');
loading.hideLoadingMask();
} else {
window.location.reload();
}
}).fail(function() {
tip.show('网络出了点问题~');
loading.hideLoadingMask();
}).always(function() {
deleteId = null;
});
return false;
});
// 添加地址
if ($addressItem.length < 5) {
$addAddress.attr('href', $addAddress.data('href'));
}
$addAddress.on('touchend', function() {
if ($addressItem.length >= 5) {
tip.show('您最多添加5个收货地址');
return false;
}
});
// 删除
$action.on('touchend', '.del', function() {
deleteId = $(this).data('id');
$confim.fadeIn();
return false;
});
$action.on('touchstart', 'a,span', function() {
$(this).css('background', '#eee');
}).on('touchend touchcancel', 'a,span', function() {
$(this).css('background', 'transparent');
});
... ...
... ... @@ -10,6 +10,7 @@ var $ = require('yoho-jquery'),
var $confim = $('.confim-mask'),
deleteId;
require('./address/address');
require('../common');
$('.address-item').on('click', function() {
... ...
... ... @@ -224,13 +224,12 @@
.goods-num {
width: 100%;
height: 52px;
height: 80px;
color: #b0b0b0;
background: #fff;
padding: 20px 0;
text-align: right;
font-size: 32px;
line-height: 52px;
span {
padding-right: 20px;
... ... @@ -304,6 +303,38 @@
}
}
.address-bottom {
display: none;
position: fixed;
left: 0;
width: 100%;
height: 70px;
overflow: hidden;
line-height: 2rem;
font-size: 24px;
bottom: 100px;
.back {
width: 100%;
height: 100%;
background: #000;
filter: alpha(opacity=70); /*IE滤镜,透明度70%*/
-moz-opacity: 0.7; /*Firefox私有,透明度70%*/
opacity: 0.7;/*其他,透明度70%*/
}
span {
color: #fff;
display: block;
padding-left: 4%;
position: relative;
top: -70px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
.order-good {
position: relative;
padding: 20px 0;
... ...
... ... @@ -31,7 +31,7 @@ function yohoCoinCompute(orderCompute) {
}
if (yohoCoinData.totalYohoCoinNum < 100) {
yohoCoinData.yohoCoinMsg = `共${yohoCoinData.totalYohoCoinNum}有货币,满${_.get(orderCompute, 'yoho_coin_pay_rule.num_limit', '')}可用`;
yohoCoinData.yohoCoinMsg = `共${yohoCoinData.totalYohoCoinNum}有货币,满${_.get(orderCompute, 'yoho_coin_pay_rule.num_limit', '100')}可用`;
} else if (yohoCoinData.useYohoCoin > 0 || yohoCoinData.yohoCoin > 0) {
yohoCoinData.yohoCoinMsg = '可抵¥' + (yohoCoinData.useYohoCoin > 0 ? yohoCoinData.useYohoCoin : yohoCoinData.yohoCoin);
yohoCoinData.yohoCoinClick = 1;
... ... @@ -247,7 +247,7 @@ function tranformPayment(data, orderInfo, cartType, skuList, orderComputeData) {
// 判断 是否为jit商品
if (cartData.is_multi_package === 'Y') {
result.isJit = true;
let jitInfo = {};
if (orderInfo) {
... ... @@ -302,13 +302,13 @@ function coupon(count, orderInfo, orderComputeData) {
};
if (
orderComputeData.coupon_amount ||
orderComputeData.coupon_amount ||
(orderComputeData.coupon_amount === 0 && orderComputeData.shipping_cost === 0)
) {
coupons.couponName = orderInfo.couponName;
}
//选中已使用的优惠劵,则剩余多少张优惠劵,不提示
// 选中已使用的优惠劵,则剩余多少张优惠劵,不提示
if (!coupons.couponName || coupons.count) {
coupons.isCoupon = true;
}
... ...