Authored by 刘传洋

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

... ... @@ -16,7 +16,7 @@ const stepper = [
];
const index = (req, res, next) => {
let cartType = req.query.cartType === '2' ? 'advance' : 'ordinary';
let cartType = req.query.type === '2' ? 'advance' : 'ordinary';
oeModel.index(req.user.uid, cartType).then(result => {
let header = headerModel.setSimpleHeaderData() || {};
... ...
... ... @@ -57,11 +57,6 @@ const handleUseYohoCoin = (info) => {
const handlePaymentInfo = (d, address) => {
let resData = {};
// 地址信息加密
// d.delivery_address.id = crypto.encryption('', `${d.delivery_address.address_id}`);
// delete d.delivery_address.address_id;
// resData.deliveryAddress = d.delivery_address;
_.forEach(address, dd => {
if (dd.is_default === 'Y') {
dd.default = true;
... ... @@ -81,26 +76,6 @@ const handlePaymentInfo = (d, address) => {
d.shopping_cart_data.hasCoin = _.round(d.yoho_coin * 100); // 有货币稀释
// let supportLine = [];
// _.forEach(['zhifubao', 'zaixianzhifu', 'weixinzhifu', 'wangyinzaixian',
// 'caifutong', 'shengfutong', 'tonglianzhifu'], sl => {
// supportLine.push(`//static.yohobuy.com/images/pay/icon/${sl}.png`);
// }
// );
// resData.supportLine = supportLine;
// let supportBank = [];
// _.forEach(
// ['BOC', 'ICBC', 'CMB', 'CCB', 'ABC', 'SPDB', 'CIB', 'GDB', 'SDB', 'CMBC',
// 'COMM', 'CITIC', 'HZCBB2C', 'CEB', 'SHBANK', 'NBBANK', 'SZPAB', 'BJRCB', 'FDB', 'PSBC'],
// sb => {
// supportBank.push(`//static.yohobuy.com/images/bankico/${sb}.gif`);
// }
// );
// resData.supportBank = supportBank;
_.forEach(d.goods_list, g => {
// link to goods
g.linkToGoods = helper.urlFormat(`/product/pro_${g.product_id}_${g.goods_id}/${g.cn_alphabet}.html`,
... ... @@ -108,22 +83,6 @@ const handlePaymentInfo = (d, address) => {
});
resData.goodsList = d.goods_list;
_.remove(d.payment_way, function(n) {
return n.is_support === 'N';
});
// let dPw = _.find(d.payment_way, {default: 'Y'});
// let dDt = _.find(d.delivery_time, {default: 'Y'});
// resData.defaultPayDelivery = {
// paymentTypeName: dPw ? dPw.payment_type_name : '在线支付(推荐)',
// paymentType: dPw ? dPw.payment_type : 1,
// paymentTypeId: dPw ? dPw.payment_id : 15,
// deliveryTimeStr: dDt ? dDt.delivery_time_string : '送货时间不限',
// deliveryTimeId: dDt ? dDt.delivery_time_id : 2,
// contractMe: false
// };
if (d.shopping_cart_data && d.shopping_cart_data.promotion_formula_list) {
handleViewPrice(d.shopping_cart_data.promotion_formula_list);
}
... ...
... ... @@ -25,6 +25,7 @@ router.post('/address/setdefault', address.setDefault); // 设置默认地址
router.get('/ensure', ensure.index); // 限购商品快捷结算页
router.get('/ensure/coupons', ensure.getCoupons); // 限购商品快捷结算页
router.post('/ensure/compute', ensure.compute); // 价格重新计算
router.post('/ensure/submit', ensure.submit); // 价格重新计算
router.get('/easypay', easypay.index); // 限购商品快捷结算页
router.post('/easypay/compute', easypay.compute); // 价格重新计算
... ...
... ... @@ -291,20 +291,32 @@
<div class="individual-slide">
<div class="individual-item individual-item-togetherGoods {{#unless cart.deleteShop}}none{{/unless}}">
<input id="" type="hidden" value="">
<div id="" class="goods clearfix">
<ul id="" class="goods clearfix img-list">
{{>individual-slide}}
</ul>
<div class="img-brand-switch">
<a class="prev iconfont" href="javascript:;">&#xe609;</a>
<a class="next iconfont" href="javascript:;">&#xe608;</a>
</div>
</div>
<div class="individual-item individual-item-recommendGoods {{#if cart.deleteShop}}none{{/if}}">
<input id="" type="hidden" value="{{latestWalk}}">
<div id="" class="goods clearfix">
<ul id="" class="goods img-list clearfix">
{{>individual-slide}}
</ul>
<div class="img-brand-switch">
<a class="prev iconfont " href="javascript:;"></a>
<a class="next iconfont" href="javascript:;"></a>
</div>
</div>
<div class="individual-item individual-item-latestWalk none">
<input id="latest-walk-count" type="hidden" value="">
<div id="latest-walk-goods" class="goods clearfix">
<ul id="latest-walk-goods" class="goods clearfix img-list">
{{>individual-slide}}
</ul>
<div class="img-brand-switch">
<a class="prev iconfont" href="javascript:;">&#xe609;</a>
<a class="next iconfont" href="javascript:;">&#xe608;</a>
</div>
</div>
</div>
... ...
... ... @@ -35,7 +35,7 @@
<div class="pay-wrap">
<div class="block-title">支付方式</div>
{{#each paymentWay}}
<p>
<p{{#isEqual is_support 'N'}} class="unsp-pay"{{/isEqual}}>
<label class="check-btn{{#isY default}} checked{{/isY}}" data-id="{{payment_id}}" data-type="{{payment_type}}" data-name="{{payment_type_name}}">{{payment_type_name}}</label>
{{#isEqual payment_type 1}}
<span>支持主流银行卡、微信、支付宝、银联等平台付款,方便快捷</span>
... ... @@ -48,12 +48,13 @@
</div>
<div class="delivery-way-wrap">
<div class="block-title">配送方式</div>
<input type="hidden" id="support-way2">
{{# deliveryWay}}
<p>
<p{{#isEqual is_support 'N'}} class="unsp-way"{{/isEqual}}>
<label class="check-btn{{#isY default}} checked{{/isY}}" data-id="{{delivery_way_id}}"
title="{{delivery_way_name}}:运费 ¥ {{delivery_way_cost}}">{{delivery_way_name}}:运费 ¥ {{delivery_way_cost}}</label>
{{#isEqual delivery_way_id 2}}
<span>您所选择的区域暂不在支持顺丰派送范围内,点击<a href="#">查看详情></a> </span>
<span>您所选择的区域暂不在支持顺丰派送范围内,点击<a href="#" class="more-info">查看详情></a> </span>
{{/isEqual}}
</p>
{{/ deliveryWay}}
... ... @@ -104,7 +105,7 @@
颜色:<span class="color">{{color_name}}</span>
尺码:<span class="size">{{size_name}}</span>
</td>
<td class="border-top price">¥ {{round last_vip_price 2}}</td>
<td class="border-top price">¥ {{round last_price 2}}</td>
<td class="border-top">× {{buy_number}}</td>
<td{{#if @first}} class="border-top"{{/if}}></td>
</tr>
... ...
<div class="good">
<li class="good img-item">
<span class="hide goods-id">{{goods_id}}</span>
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}"/>
</a>
... ... @@ -6,9 +7,10 @@
<p class="price">
<span class="sale-price">8888{{salePrice}}</span>
</p>
<button>加入购物车</button>
</div>
<div class="good">
<a class="btn-add-cart">加入购物车</a>
</li>
<li class="good img-item">
<span class="hide goods-id">{{goods_id}}</span>
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}"/>
</a>
... ... @@ -16,9 +18,10 @@
<p class="price">
<span class="sale-price">8888{{salePrice}}</span>
</p>
<button>加入购物车</button>
</div>
<div class="good">
<a class="btn-add-cart">加入购物车</a>
</li>
<li class="good img-item">
<span class="hide goods-id">{{goods_id}}</span>
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}"/>
</a>
... ... @@ -27,9 +30,10 @@
<span class="sale-price sale-price-new">8888{{salePrice}}</span>
<span class="market-price">7777{{marketPrice}}</span>
</p>
<button>加入购物车</button>
</div>
<div class="good">
<a class="btn-add-cart">加入购物车</a>
</li>
<li class="good img-item">
<span class="hide goods-id">{{goods_id}}</span>
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}"/>
</a>
... ... @@ -37,9 +41,10 @@
<p class="price">
<span class="sale-price">8888{{salePrice}}</span>
</p>
<button>加入购物车</button>
</div>
<div class="good">
<a class="btn-add-cart">加入购物车</a>
</li>
<li class="good img-item">
<span class="hide goods-id">{{goods_id}}</span>
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}"/>
</a>
... ... @@ -47,9 +52,10 @@
<p class="price">
<span class="sale-price">8888{{salePrice}}</span>
</p>
<button>加入购物车</button>
</div>
<div class="good">
<a class="btn-add-cart">加入购物车</a>
</li>
<li class="good img-item">
<span class="hide goods-id">{{goods_id}}</span>
<a href="{{href}}" target="_blank">
<img class="lazy" data-original="{{img}}"/>
</a>
... ... @@ -57,5 +63,6 @@
<p class="price">
<span class="sale-price">8888{{salePrice}}</span>
</p>
<button>加入购物车</button>
</div>
<a class="btn-add-cart">加入购物车</a>
</li>
... ...
... ... @@ -46,47 +46,6 @@ $('.sale-info').mouseenter(function() {
$(this).removeClass('active').children('ul').addClass('none');
});
// 推荐、优选、浏览切换
$('.bottom-tab-slide').on('click', '.bottom-title', function() {
var $this = $(this),
index = $this.index();
console.log(index);
var $togetherGoods = $('.individual-item-togetherGoods'),
$latestWalk = $('.individual-item-latestWalk'),
$recommendGoods = $('.individual-item-recommendGoods');
if ($this.hasClass('cur')) {
return;
}
$this.addClass('cur');
$this.siblings('.cur').removeClass('cur');
switch (index) {
case 0: {
$togetherGoods.removeClass('none');
$recommendGoods.addClass('none');
$latestWalk.addClass('none');
break;
}
case 1: {
$togetherGoods.addClass('none');
$recommendGoods.removeClass('none');
$latestWalk.addClass('none');
break;
}
case 2: {
$togetherGoods.addClass('none');
$recommendGoods.addClass('none');
$latestWalk.removeClass('none');
break;
}
}
});
// 删除购物车商品,把删除的商品移入cookie中
function cartDel(data, delUrl, cookieList) {
$.ajax({
... ... @@ -191,6 +150,73 @@ function loadTogetherGoods() {
}
loadTogetherGoods();
// ----------------底部 为你优选,最近浏览 begin--------------
// 推荐、优选、浏览切换
$('.bottom-tab-slide').on('click', '.bottom-title', function() {
var $this = $(this),
index = $this.index();
console.log(index);
var $togetherGoods = $('.individual-item-togetherGoods'),
$latestWalk = $('.individual-item-latestWalk'),
$recommendGoods = $('.individual-item-recommendGoods');
if ($this.hasClass('cur')) {
return;
}
$this.addClass('cur');
$this.siblings('.cur').removeClass('cur');
switch (index) {
case 0: {
$togetherGoods.removeClass('none');
$recommendGoods.addClass('none');
$latestWalk.addClass('none');
break;
}
case 1: {
$togetherGoods.addClass('none');
$recommendGoods.removeClass('none');
$latestWalk.addClass('none');
break;
}
case 2: {
$togetherGoods.addClass('none');
$recommendGoods.addClass('none');
$latestWalk.removeClass('none');
break;
}
}
});
function loadSlideGoods() {
// $.ajax({
// type: 'GET',
// url: '',
// data: {
// // skn: skn,
// size: 20,
// num: 1
// }
// }).then(function(data) {
// var pro = data.data.products;
// if (data.code === 200) {
// if (pro.length === 0) {
// return;
// }
$('.individual-item').slider2({
shownum: 5,
isCircle: true
});
}
loadSlideGoods();
// ----------------底部 为你优选,最近浏览 end--------------
// 凑单弹框 详情切换
$('body').on('click', '.piclist li', function() {
pacList = $(this).index();
... ... @@ -474,6 +500,7 @@ $paySum.on('click', '.btn-account', function() {
// }
// }
$('.cart-preSell-dialog').show();
// $('.togethor').show();
// $('.cart-togetherGoods').show();
... ... @@ -492,7 +519,7 @@ $('.shop-cart').on('click', giftBtn, function() {
$win.show();
});
$('.shop-cart').on('click', '[data-role="cart-gift-win"] .close', function(){
$('.shop-cart').on('click', '[data-role="cart-gift-win"] .close', function() {
$(this).closest('[data-role="cart-gift-win"]').hide();
});
... ...
... ... @@ -107,11 +107,12 @@ function compute(coin) {
// 支付方式
payWay = {
$payType: $('.pay-wrap .check-btn'),
$allType: $('.pay-wrap > p'),
init: function() {
var that = this;
this.payType = {};
this.$payType = this.$allType.not('.unsp-pay').find('.check-btn');
this.$payType.each(function() {
var $this = $(this),
data = $this.data();
... ... @@ -177,7 +178,8 @@ deliveryWay = {
that.deliveryType[data.id] = {
dom: $this,
id: data.id
id: data.id,
unsupport: $this.parent().hasClass('unsp-way')
};
// 更新订单配送方式数据
... ... @@ -200,16 +202,18 @@ deliveryWay = {
var that = this;
this.$deliveryType.click(function() {
var $this = $(this);
var $this = $(this),
id = $this.data('id');
var dt = that.deliveryType[id];
if ($this.hasClass('checked')) {
if ($this.hasClass('checked') || (dt && dt.unsupport)) {
return;
}
that.$deliveryType.removeClass('checked');
$this.addClass('checked');
// 更新订单配送方式数据
that.updateOrder({way: $this.data('id')});
that.updateOrder({way: id});
// 重新计算订单价格
compute();
... ... @@ -227,6 +231,31 @@ deliveryWay = {
// 更新订单送货时间数据
that.updateOrder({time: $this.data('id')});
});
$('#support-way2').change(function() {
that.setSupportStatus(2, $(this).val() * 1);
});
},
setSupportStatus: function(id, support) {
var dt;
if (!id || !this.deliveryType[id]) {
return;
}
dt = this.deliveryType[id];
if (support) {
dt.dom.parent().removeClass('unsp-way');
dt.unsupport = false;
} else {
dt.dom.parent().addClass('unsp-way');
dt.unsupport = true;
}
if (dt.dom.hasClass('checked')) {
this.$deliveryType.eq(0).trigger('click');
}
},
updateOrder: function(info) {
if (!info) {
... ...
... ... @@ -14,7 +14,8 @@ var Dialog = dialog.Dialog,
Alert = dialog.Alert;
var $addrWrap = $('#addr-list'),
$deliveryAddr = $('#delivery-detail');
$deliveryAddr = $('#delivery-detail'),
$supportWay2 = $('#support-way2');
var addressTpl = hbs.compile($('#address-tpl').html()),
addressItemTpl = hbs.compile($('#address-item-tpl').html());
... ... @@ -170,7 +171,12 @@ function setShowDeliveryAddr(data) {
}
if (data) {
// 修改地址选中状态
addrSelect = data.id;
// 触发配送方式2是否支持状态改变
$supportWay2.val(data.delivery ? 1 : 0).change();
_h = '寄送至:' + data.area + '&nbsp;&nbsp;&nbsp;&nbsp;' + data.address +
'<br>收货人:' + data.consignee + '&nbsp;&nbsp;&nbsp;&nbsp;' + data.mobile;
}
... ... @@ -190,7 +196,7 @@ function handelAddrInfo(data, reqData, $el) {
mobile: reqData.mobile,
code: reqData.areaCode,
phone: reqData.phone,
delivery: data.delivery === 'Y'
delivery: data.is_delivery === 'Y'
});
$dom = $(addressItemTpl(addrList[reqData.id]));
... ... @@ -213,7 +219,7 @@ function handelAddrInfo(data, reqData, $el) {
mobile: data.mobile,
code: data.area_code,
phone: data.phone,
delivery: data.delivery === 'Y'
delivery: data.is_delivery === 'Y'
};
$dom = $(addressItemTpl(addrList[data.id]));
... ...
... ... @@ -1386,6 +1386,7 @@
height: 368px;
overflow: hidden;
.individual-item {
position: relative;
width:100%;
overflow: hidden;
font-size: 12px;
... ... @@ -1427,7 +1428,7 @@
.price {
text-align: center;
margin-bottom: 10px;
margin-bottom: 8px;
}
.sale-price,.market-price {
... ... @@ -1444,7 +1445,7 @@
text-decoration: line-through;
}
button {
.btn-add-cart {
display: block;
margin: 0 auto;
color: #3a3a3a;
... ... @@ -1452,6 +1453,7 @@
width: 110px;
height: 28px;
line-height: 28px;
text-align: center;
border:1px solid #b0b0b0;
border-radius: 0;
-webkit-border-radius: 0;
... ... @@ -1461,6 +1463,40 @@
cursor: pointer;
outline: none;
}
.img-brand-switch {
a{
position: absolute;
top: 131px;
font-size: 20px;
color: #000;
width: 30px;
height: 30px;
padding: 0;
text-align: center;
background-color: #e1e1e1;
&:before {
display: inline-block;
margin-top: 5px;
}
&.active{
background-color: #e9e9e9;
border: none;
}
}
.next {
right: 0px;
&:before{
content:"\e609";
}
}
.prev {
left: 0px;
&:before{
content:"\e608";
}
}
}
}
}
.r-dialog{
... ...
... ... @@ -356,6 +356,40 @@
min-width: 100px;
text-align: center;
}
.unsp-pay {
color: #999;
.check-btn {
color: #999;
border-color: #999;
}
}
}
.delivery-way-wrap {
.more-info {
color: $red;
margin-left: 10px;
}
p > span {
display: none;
}
.unsp-way {
color: #999;
.check-btn {
color: #999;
border-color: #999;
cursor: not-allowed;
}
> span {
display: inline-block;
}
}
}
.delivery-time-wrap {
... ... @@ -366,6 +400,16 @@
min-width: 138px;
text-align: center;
}
.unsp-way {
color: #999;
.check-btn {
color: #999;
border-color: #999;
cursor: not-allowed;
}
}
}
.goods-wrap {
... ...