Authored by 毕凯

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

... ... @@ -5,7 +5,6 @@
*/
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var chosePanel = require('./chose-panel'),
... ... @@ -16,14 +15,21 @@ var $cartContent = $('.cart-content'),
cartType = $('#cartType').val(),
hasShowCartPresellTip = false;
var $cartContentShow = $cartContent.not('.hide');
var navHammer,
advanceBuyHammer,
freebieHammer;
freebieHammer,
switchChose = false;
require('../product/recommend-for-you');
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
function hasChecked() {
return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false;
}
function shouldSelectGift() {
var $freebie = $('.freebie');
var $freebie = $cartContentShow.find('.freebie');
if ($freebie.length <= 0) {
return false;
... ... @@ -33,9 +39,15 @@ function shouldSelectGift() {
}
function shouldLowStocks() {
var $lowStocks = $('.low-stocks'),
var $lowStocks,
result = false;
if ('ordinary' === cartType) {
$lowStocks = $('.common .low-stocks');
} else if ('advance' === cartType) {
$lowStocks = $('.presell .low-stocks');
}
if ($lowStocks.length <= 0) {
return result;
}
... ... @@ -58,7 +70,7 @@ function showChooseGifDialog() {
rightBtnText: '去选择'
}
}, function() {
window.location.href = $('.freebie').find('a').attr('href');
window.location.href = $cartContentShow.find('.freebie > a').attr('href');
}, function() {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
});
... ... @@ -66,7 +78,7 @@ function showChooseGifDialog() {
require('./good');
lazyLoad($('img.lazy'));
//lazyLoad($('img.lazy'));
if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
$('#presell-tip').removeClass('show').addClass('hide');
... ... @@ -93,10 +105,6 @@ if ($('.cart-nav').length > 0) {
return;
}
$('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
if (cartType === 'ordinary') {
cartType = 'advance';
$('#cartType').val('advance');
... ... @@ -111,7 +119,14 @@ if ($('.cart-nav').length > 0) {
//切换普通商品和预售商品购物车显示
$cartContent.toggleClass('hide');
hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false;
$cartContentShow = $cartContent.not('.hide');
if (switchChose === false) {
$cartContentShow.find('.shopping-cart-good .name').each(function() {
this.mlellipsis(2);
});
switchChose = true;
}
//trigger lazyload
$(window).trigger('scroll');
... ... @@ -141,7 +156,7 @@ if ($('.freebie').length > 0) {
$('.btn-balance').on('touchend', function() {
if (shouldLowStocks()) {
tip.show('库存不足无法结算');
tip.show('所选商品中含有库存不足的商品');
return false;
}
... ... @@ -150,7 +165,7 @@ $('.btn-balance').on('touchend', function() {
return false;
}
if (hasChecked) {
if (hasChecked()) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
} else {
tip.show('请先勾选商品');
... ... @@ -161,10 +176,6 @@ $('.chose').on('touchend', function() {
chosePanel.show();
});
if ($('.shopping-cart-good').length <= 0) {
require('../product/recommend-for-you');
}
function notAllowScroll() {
var docH = $(document).height(),
winH = $(window).height();
... ...
... ... @@ -192,13 +192,22 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
var isSelect = $(this).hasClass('icon-cb-checked');
var cartType = $('#cartType').val(),
isSelect = $(this).hasClass('icon-cb-checked');
if (!isSelect && $('.low-stocks').length > 0) {
if ('ordinary' === cartType) {
if (!isSelect && $('.common .low-stocks').length > 0) {
tip.show('所选商品中含有库存不足的商品');
return false;
}
bottomCheckBoxHandeler(isSelect, $('#cartType').val(), didUpdateAllGoodsCheckStatus);
} else if ('advance' === cartType) {
if (!isSelect && $('.presell .low-stocks').length > 0) {
tip.show('所选商品中含有库存不足的商品');
return false;
}
}
bottomCheckBoxHandeler(isSelect, cartType, didUpdateAllGoodsCheckStatus);
});
$('.down').on('touchend', function() {
... ...
... ... @@ -3,7 +3,6 @@
* @author: chenglong<chenglong.wang@yoho.cn>
* @date: 2015/11/12
*/
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
Swiper = require('yoho.iswiper');
... ...
... ... @@ -27,7 +27,7 @@
}
}
.few-tag{
.few-tag {
width: 148rem / $pxConvertRem;
position: absolute;
left: 92rem / $pxConvertRem;
... ... @@ -90,6 +90,7 @@
width: 80%;
color: #5a5a5a;
font-size: 0.6rem;
line-height: 0.7rem;
}
.color-size-row > span {
... ...
... ... @@ -313,10 +313,10 @@ class CartModel
*
* @param int $uid 用户ID
* @param string $cartType 购物车类型,ordinary表示普通购物车
* @param null|string $cookieData cookie中记录的一些订单有关数据
* @param array $orderInfo cookie中记录的一些订单有关数据
* @return array 接口返回的数据
*/
public static function cartPay($uid, $cartType, $cookieData)
public static function cartPay($uid, $cartType, $orderInfo)
{
$result = array();
... ... @@ -324,13 +324,11 @@ class CartModel
if ($pay && isset($pay['code']) && $pay['code'] === 200) {
$payReturn = $pay['data'];
$orderInfo = array();
$address = array();
$orderCompute = array();
// cookie保存的数据
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
if (!empty($orderInfo)) {
$orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
}
... ...
... ... @@ -277,6 +277,12 @@ class IndexController extends AbstractAction
// 购物车商品为空跳转到购物车页面
$cartType = $this->get('cartType', 'ordinary');
$cookieData = $this->getCookie('order-info', null);
$orderInfo = array();
if (!empty($cookieData)) {
$orderInfo = json_decode($cookieData, true);
$cartType = $orderInfo['cartType'];
}
$cartKey = 'commonCart';
if ($cartType === 'advance') {
$cartKey = 'preSellCart';
... ... @@ -289,12 +295,10 @@ class IndexController extends AbstractAction
$this->go(Helpers::url('/cart/index/index'));
}
$cookieData = $this->getCookie('order-info', null);
$uid = $this->getUid(true);
$data = array(
'orderEnsurePage' => true,
'isOrdinaryCart' => ($cartType !== 'advance'),
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
'orderEnsure' => CartModel::cartPay($uid, $cartType, $orderInfo)
);
$this->_view->display('order-ensure', $data);
... ...