Authored by 梁志锋

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -639,7 +639,7 @@ class Helpers
$arr[] = $gift;
// 计算加价购商品数目
$count += $value['max_select_number'];
$count += count($value['goods_list']);
}
return $arr;
... ...
... ... @@ -16,6 +16,8 @@ var $cartContent = $('.cart-content');
var navHammer,
cartType = $('#cartType').val();
var hasChecked = $('.cart-goods .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
require('./good');
lazyLoad($('img.lazy'));
... ... @@ -51,10 +53,10 @@ if ($('.cart-nav').length > 0) {
}
$('.btn-balance').on('touchend', function() {
if ($('.balance span').hasClass('icon-cb-checked')) {
if (hasChecked) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
tip.show('请先勾选商品~');
tip.show('请先勾选商品');
}
});
... ... @@ -63,3 +65,6 @@ $('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel.show();
});
//提前触发lazyload
$(window).scrollTop(1).scrollTop(0);
\ No newline at end of file
... ...
... ... @@ -12,8 +12,7 @@ var $ = require('jquery'),
var dialog = require('../me/dialog'),
tip = require('../plugin/tip');
var $names,
$selectAllBtn = $('.balance .iconfont'),
var $selectAllBtn = $('.balance .checkbox'),
cartType = $('#cartType').val(),
requesting = false;
... ... @@ -23,11 +22,9 @@ lazyLoad({
try_again_css: 'good-failure'
});
$names = $('.name');
if ($names.length > 0) {
$names[0].mlellipsis(2);
}
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
... ... @@ -73,44 +70,12 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
$.ajax({
type: 'GET',
url: 'getCartData',
data: {
id: id
},
success: function(data) {
if (data) {
if (cartType === 'ordinary') {
$('#good-totalprice').html('¥' + data.commonCart.price);
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
$('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)');
if (data.commonCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
} else {
$('#good-totalprice').html('¥' + data.preSellCart.price);
$('#good-activityPrice').html('¥' + data.preSellCart.activityPrice);
$('#good-total').html('总计:¥' + data.preSellCart.sumPrice + ' (' + data.preSellCart.count + '件)');
if (data.preSellCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
}
}
},
error: function() {
tip.show('网络错误');
}
});
window.history.go(0);
} else if (data.code === 400) {
tip.show('网络错误');
tip.show('网络异常');
}
}).fail(function() {
tip.show('网络错误');
}, function() {
tip.show('网络异常');
});
}).on('touchstart', '.icon-del', function(e) {
var $this = $(this);
... ... @@ -143,10 +108,10 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
});
history.go(0);
}
}).fail(function() {
}, function() {
dialog.showDialog({
autoHide: true,
dialogText: '网络错误~'
dialogText: '网络异常'
});
});
});
... ... @@ -203,6 +168,7 @@ function didUpdateAllGoodsCheckStatus() {
$(checkedBox).removeClass('icon-cb-checked').addClass('icon-checkbox');
});
}
window.history.go(0);
}
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
... ... @@ -251,6 +217,7 @@ function willBeSelected($this) {
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
var $this = $(this);
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
});
... ...
... ... @@ -63,36 +63,31 @@
}
.deps {
margin-left: 173rem / $pxConvertRem;
padding-bottom: 72rem / $pxConvertRem;
border-bottom: 1px solid #e0e0e0;
width: 380rem / $pxConvertRem;
position: relative;
min-height: 140rem / $pxConvertRem;
width: 380rem / $pxConvertRem;
height: 5.3rem;
margin-left: 4.7rem;
border-bottom: 1px solid #e0e0e0;
padding-top: 0.5rem;
}
.name {
font-size: 28rem / $pxConvertRem;
font-size: 18px;
color: #5a5a5a;
width: 80%;
display: inline-block;
}
.row:nth-child(2) {
font-size: 22rem / $pxConvertRem;
height: 45rem / $pxConvertRem;
line-height: 45rem / $pxConvertRem;
.color-size-row {
margin: 0.2rem 0;
> span {
margin-right: 15rem / $pxConvertRem;
}
}
.row:nth-child(3) {
position: relative;
}
.color, .size {
font-size: 16px;
color: #b6b6b6;
}
... ... @@ -103,7 +98,7 @@
}
.price {
font-size: 24rem / $pxConvertRem;
font-size: 16px;
color: $cartRed;
}
... ...
... ... @@ -25,7 +25,7 @@
<span class="count">
×{{count}}
</span>
<p class="row">
<p class="row color-size-row">
{{#if color}}
<span class="color">
颜色:{{color}}
... ... @@ -50,23 +50,22 @@
</span>
{{/if}}
<span class="iconfont icon-del" data-count="{{count}}">&#xe621;</span>
</p>
<p class="row">
{{#if lowStocks}}
<p class="row">
<span class="low-stocks">
库存不足
</span>
{{/if}}
</p>
<p class="row">
{{/if}}
{{#if appearDate}}
<p class="row">
<span class="appear-date">
上市期:{{appearDate}}
</span>
{{/if}}
</p>
{{/if}}
</div>
<div class="calculate-num hide">
<div class="calculate">
... ...
... ... @@ -769,12 +769,27 @@ class CartModel
$result['advanceBuy'] = Helpers::formatAdvanceGoods($data['price_gift'], $result['advanceBuyCount']);
}
// 已参加的活动
if (!empty($data['promotion_info'])) {
$result['promotionInfo'] = array();
$info = array();
foreach ($data['promotion_info'] as $val) {
$info = array();
$info['id'] = $val['promotion_id'];
$info['name'] = $val['promotion_title'];
$result['promotionInfo'][] = $info;
}
$result['promotionFormula'] = $data['shopping_cart_data']['promotion_formula'];
}
// 结算数据
$result['price'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
$result['activityPrice'] = Helpers::transPrice($data['shopping_cart_data']['discount_amount']);
$result['count'] = $data['shopping_cart_data']['selected_goods_count'];
$result['isAllSelected'] = ($data['shopping_cart_data']['goods_count'] === $data['shopping_cart_data']['selected_goods_count']) && ($data['shopping_cart_data']['selected_goods_count'] >0);
$result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['order_amount']);
$result['sumPrice'] = Helpers::transPrice($data['shopping_cart_data']['last_order_amount']);
}while(0);
return $result;
... ...