Authored by hf

Merge branch 'develop' into test

... ... @@ -846,7 +846,16 @@
{
id: 1,
inValid: true, //是否是失效商品,
showCheckbox: true, //是否显示checkbox【赠品和加价购不显示】
checked: true, //是否选中
thumb: '',
isAdvanceBuy: true, //是否是加价购商品
isGift: ture, //是否是赠品
name: '',
color: '黄色',
size: 'L',
... ...
/**
* 购物车信息读取
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/12/15
*/
var info = window.cookie('cart-info');
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
info = {
deliveryId: null,
deliveryTimeId: null,
paymentTypeId: null,
yohoCoin: null,
addressId: null,
couponCode: null,
couponValue: null,
invoice: null,
invoiceText: null,
invoiceType: null,
msg: null
};
window.setCookie('cart-info', JSON.stringify(info));
}
exports.cartInfo = function(key, value) {
if (value === undefined) {
return info[key];
}
info[key] = value;
window.setCookie('cart-info', JSON.stringify(info));
};
... ... @@ -50,6 +50,10 @@ if ($('.cart-nav').length > 0) {
//trigger lazyload
$(window).trigger('scroll');
});
setTimeout(function() {
$('#presell-tip').addClass('hide');
}, 3000);
}
$('.btn-balance').on('touchend', function() {
... ...
... ... @@ -10,56 +10,37 @@
// 异步渲染的模板统一插入 #chose-panel ,兼容页面多个选择框
var $ = require('jquery'),
Handlebars = require('yoho.handlebars'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading');
var panelTmpl,
$chosePanel = $('#chose-panel'),
var $chosePanel = $('#chose-panel'),
$num,
$chosed,
// re = /\d+/,
leftNum,
confirming,
hasChooseColor = false,
hasChooseSize = false,
curColorIndex,
curSizeIndex,
$curSizeRow,
$curSizeBlock = null,
$sizeRowList = $('.size-list ul');
// 读取模板
$.get('/cart/index/giftinfoTpl', function(html) {
if (!html) {
tip.show('网络错误');
return;
}
panelTmpl = Handlebars.compile(html);
}).fail(function() {
tip.show('网络错误');
});
hasChooseColor,
hasChooseSize,
$curSizeBlock,
$sizeRowList;
//初始化购物车面板显示
function init() {
var $firstRow;
//$colorList = $('.chose-panel .color-list ul>li');
//$sizeList = $('.chose-panel .size-list ul>li');
//firstColorId = $colorList.eq(0).data('id');
//$sizeList.each(function() {
// colorIndex = $(this).data('colorid');
//
// if (colorIndex === firstColorId) {
// $(this).removeClass('hide');
// }
//});
var $firstRow = $sizeRowList.eq(0);
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
$sizeRowList = $('.size-list ul');
$firstRow = $sizeRowList.eq(0);
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
}
init();
function checkColorSizeNum() {
if (!hasChooseColor && !hasChooseSize) {
... ... @@ -75,11 +56,9 @@ function checkColorSizeNum() {
return true;
}
init();
function show(data) {
if (data) {
$chosePanel.html(panelTmpl(data));
function show(html) {
if (html) {
$chosePanel.html(html);
init();
}
$('.chose-panel').show();
... ... @@ -88,20 +67,55 @@ function show(data) {
$num = $('#good-num');
}
////显示当前Panel
//function show() {
// $('.chose-panel').show();
//
// $('body').css('overflow', 'hidden');
// $num = $('#good-num');
//}
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
$('body').css('overflow', 'auto');
}
//修改加入购物车的文字和背景
function updateConformButtonClassAndText() {
$chosed = $('.chose-items').find('.chosed');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0');
$('#chose-btn-sure').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
}
}
//重置颜色块的库存为0的样式
function resetColorZeroStock($siblingBlock) {
var numArray = ($curSizeBlock.data('numstr') + '').split('/'),
i;
if (!hasChooseSize) {
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
} else {
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
}
}
// 选择了颜色切换商品图片
function changeGoodImgWhenClickColor() {
if (hasChooseColor && curColorIndex) {
$('.chose-panel').find('.thumb').addClass('hide').eq(curColorIndex).removeClass('hide');
}
}
init();
$('.yoho-page').on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
... ... @@ -143,11 +157,6 @@ $('.color-list').on('touchstart', '.block', function(e) {
} else {
hasChooseColor = true;
//根据颜色切换图片
if ($this.closest('.block-list').hasClass('color-list')) {
$('.chose-panel').find('.thumb').addClass('hide').eq(index).removeClass('hide');
}
//把当前选中颜色对应的尺码那一行显示出来
$sizeRowList.addClass('hide');
$curSizeRow.removeClass('hide').addClass('show');
... ... @@ -180,91 +189,22 @@ $('.color-list').on('touchstart', '.block', function(e) {
curColorIndex = index;
// 设置按钮的样式和文字
$chosed = $('.chose-items').find('.chosed');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0');
$('#chose-btn-sure').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
}
/**if ($chosed.length === 0) {
$this.closest('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
$sizeList.addClass('hide');
//切换尺码信息
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === $this.data('id')) {
$(this).removeClass('hide');
}
});
numArray = ($chosed.data('numstr') + '').split('/');
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
$that.find('.num .left-num').html('');
} else if ($chosed.length === 2) {
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < currentNumArray.length; i++) {
if ('0' === currentNumArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
numArray = ($siblingBlock.find('.chosed').data('numstr') + '').split('/');
$that.find('.num .left-num').html('剩余' + numArray[index] + '件');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0');
$('#chose-btn-sure').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
}
}**/
updateConformButtonClassAndText();
// 修改颜色时修改商品图片
changeGoodImgWhenClickColor();
});
$('.size-list').on('touchstart', '.block', function(e) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
index,
$colorChosed,
curGoodNum;
var $siblingBlock = $this.closest('.block-list').siblings(':first');
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
$colorChosed = $siblingBlock.find('.chosed');
$curSizeRow = $sizeRowList.eq(index);
// 当前尺码已经是选中状态,再点击时
... ... @@ -275,11 +215,6 @@ $('.size-list').on('touchstart', '.block', function(e) {
$('#left-num').val(0);
hasChooseSize = false;
// 去掉已经选中颜色的 数量为0的样式
if ($colorChosed.length > 0) {
$colorChosed.removeClass('zero-stock').addClass('zero-stock');
}
// 当前尺码不是选中状态,选中时
} else {
hasChooseSize = true;
... ... @@ -296,10 +231,10 @@ $('.size-list').on('touchstart', '.block', function(e) {
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
$colorChosed.removeClass('zero-stock').addClass('zero-stock');
$that.find('.num .left-num').html('');
$('#left-num').val(0);
}
}
$this.toggleClass('chosed');
... ... @@ -307,78 +242,10 @@ $('.size-list').on('touchstart', '.block', function(e) {
$curSizeBlock = $this;
// 设置按钮的样式和文字
$chosed = $('.chose-items').find('.chosed');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0');
$('#chose-btn-sure').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
}
/**if ($chosed.length === 0) {
$this.closest('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
} else if ($chosed.length === 1 && $this.hasClass('chosed')) {
if ($this.closest('.block-list').hasClass('color-list')) {
$sizeList.addClass('hide');
//切换尺码信息
$sizeList.each(function() {
colorIndex = $(this).data('colorid');
if (colorIndex === $this.data('id')) {
$(this).removeClass('hide');
}
});
}
numArray = ($chosed.data('numstr') + '').split('/');
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < numArray.length; i++) {
if ('0' === numArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
} else if ($chosed.length === 1 && !$this.hasClass('chosed')) {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
updateConformButtonClassAndText();
$siblingBlock.find('ul>li').each(function() {
$(this).removeClass('zero-stock');
if ('0' === $(this).data('num')) {
$(this).addClass('zero-stock');
}
});
$that.find('.num .left-num').html('');
} else if ($chosed.length === 2) {
$siblingBlock.find('.block').removeClass('zero-stock');
for (i = 0; i < currentNumArray.length; i++) {
if ('0' === currentNumArray[i]) {
$siblingBlock.find('.block').eq(i).addClass('zero-stock');
}
}
numArray = ($siblingBlock.find('.chosed').data('numstr') + '').split('/');
$that.find('.num .left-num').html('剩余' + numArray[index] + '件');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0');
$('#chose-btn-sure').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
}
}**/
// 重置颜色块的样式
resetColorZeroStock($siblingBlock);
});
... ... @@ -426,6 +293,7 @@ $('#chose-btn-sure').on('touchstart', function() {
numInCart = $('.num-tag').html() - 0,
num = $num.val();
//颜色尺码没有选择
if (!checkColorSizeNum()) {
return;
}
... ...
... ... @@ -19,19 +19,13 @@ function getProductInfo(skn, promotionId) {
$.get('/cart/index/giftinfo', {
skn: skn,
promotionId: promotionId
}).then(function(res) {
if (!res) {
}).then(function(html) {
if (!html) {
tip.show('网络错误');
return;
}
if (res.code === 200) {
chosePanel.show({
cartInfo: res.data
});
} else {
tip.show(res.message || '网络错误');
}
}).fail(function() {
chosePanel.show(html);
}, function() {
tip.show('网络错误');
}).always(function() {
loading.hideLoadingMask();
... ...
... ... @@ -107,12 +107,11 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
fast: true
});
history.go(0);
} else {
tip.show(data.message);
}
}, function() {
dialog.showDialog({
autoHide: true,
dialogText: '网络异常'
});
tip.show('网络异常');
});
});
... ...
... ... @@ -78,7 +78,7 @@ function orderCompute() {
method: 'POST',
url: '/cart/index/orderCompute',
data: {
cartType: orderInfo('cartType'),
cartType: queryString.cartType || queryString.carttype || 'ordinary',
deliveryId: orderInfo('deliveryId'),
paymentTypeId: orderInfo('paymentTypeId'),
couponCode: orderInfo('couponCode'),
... ... @@ -89,6 +89,7 @@ function orderCompute() {
if (!res) {
tip.show('网络出错');
window.location.reload();
} else {
/*if (res.order_amount) {
res.order_amount = (+res.order_amount).toFixed(2);
... ... @@ -108,6 +109,7 @@ function orderCompute() {
}
}).fail(function() {
tip.show('网络出错');
window.location.reload();
});
}
... ...
... ... @@ -7,9 +7,20 @@
var $ = require('jquery'),
orderInfo = require('./order-info').orderInfo;
var $confim = $('.confim-mask'),
deleteId;
$('.address-item').on('touchend', function() {
orderInfo('addressId', $(this).data('address-id'));
}).on('touchend', '.edit', function() {
window.location.href = $(this).data('href');
return false;
}).on('touchend', '.del', function() {
deleteId = $(this).data('address-id');
});
$confim.on('touchend', '.confim', function() {
if (orderInfo('addressId') === deleteId) {
orderInfo('addressId', null);
}
});
... ...
... ... @@ -36,6 +36,37 @@
li:first-child span {
border-right: 1px solid #e0e0e0;
}
li:last-child {
position: relative;
}
.presell-tip {
position: absolute;
z-index: 1;
left: -2rem;
top: 1.75rem;
}
.triangle {
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 12px solid #000;
margin-left: 6rem;
}
.pt-content {
position: relative;
padding: 10px;
background: #000;
color: #fff;
font-size: 20px;
@include border-radius(5px);
text-align: center;
width: 7rem;
}
}
.login-info {
... ... @@ -195,8 +226,6 @@
}
}
}
.shopping-cart-zero{
.cart-zero{
width: 100%;
height: auto;
... ...
{{> cart/chose-panel}}
\ No newline at end of file
... ...
{{> layout/header}}
{{# shoppingCart}}
{{#if isEmptyCart}}
<div class="shopping-cart-zero yoho-page">
<div class="cart-zero">
<i class="iconfont">&#xe62c</i>
<p>您的购物车暂无商品</p>
<a href="/product/new">随便逛逛</a>
</div>
{{> product/recommend-for-you}}
</div>
{{^}}
<div id="mainCart" class="shopping-cart-page yoho-page">
{{#if showLoginInfo}}
<div id="mainCart" class="shopping-cart-page yoho-page">
{{# shoppingCart}}
{{#if showLoginInfo}}
<p class="login-info">
<span class="iconfont">&#xe628;</span>
请您先
<a class="btn btn-login" href="{{signurl}}">登录</a>
可以同步电脑和手机中的商品
</p>
{{^}}
{{#if cartNav}}
{{/if}}
{{#if isEmptyCart}}
<div class="cart-zero">
<i class="iconfont">&#xe62c</i>
<p>您的购物车暂无商品</p>
<a href="/product/new">随便逛逛</a>
</div>
{{> product/recommend-for-you}}
{{^}}
{{#if cartNav}}
<ul class="cart-nav clearfix">
<li class="active">
<span>
... ... @@ -33,33 +28,33 @@
<span>
预售商品({{presellGoodsCount}})
</span>
<div id="presell-tip" class="presell-tip">
<div class="triangle"></div>
<p class="pt-content">预售商品点这里结算哦~</p>
</div>
</li>
</ul>
{{/if}}
{{/if}}
{{# commonCart}}
<div class="cart-content common">
{{> cart/cart-content}}
</div>
<div class="cart-content common">
{{> cart/cart-content}}
</div>
{{/ commonCart}}
{{# preSellCart}}
<div class="cart-content presell hide">
<p class="presell-info">
<span class="iconfont">&#xe61a;</span>
<span class="txt">预售商品全场包邮,到货后立即发货</span>
<span class="txt">预售商品不参加活动,不可使用优惠券</span>
</p>
{{> cart/cart-content}}
</div>
<div class="cart-content presell hide">
<p class="presell-info">
<span class="iconfont">&#xe61a;</span>
<span class="txt">预售商品全场包邮,到货后立即发货</span>
<span class="txt">预售商品不参加活动,不可使用优惠券</span>
</p>
{{> cart/cart-content}}
</div>
{{/ preSellCart}}
</div>
{{/if}}
<input id="cartType" type="hidden" value="{{cartType}}">
{{/ shoppingCart}}
{{> cart/chose-panel}}
{{/ shoppingCart}}
</div>
{{> layout/footer}}
... ...
... ... @@ -65,11 +65,18 @@
</li>
<li class="coin" data-yoho-coin="{{yohoCoin}}">
<span class="title">YOHO币</span>
<span class="desc">可抵¥{{yohoCoin}}</span>
<span class="coin-check">
<em>- ¥ {{yohoCoin}}</em>
<i class="iconfont checkbox icon-cb-checked"></i>
</span>
{{#if yohoCoin}}
<span class="desc">可抵¥{{yohoCoin}}</span>
<span class="coin-check">
<em>- ¥ {{yohoCoin}}</em>
<i class="iconfont checkbox icon-cb-checked"></i>
</span>
{{^}}
<span class="not-used coin-check">
无YOHO币可用
</span>
{{/if}}
</li>
{{#if invoice}}
... ...
... ... @@ -38,33 +38,33 @@
<ul class="size-row clearfix hide">
{{# size}}
<li class="block {{#if chosed}}chosed{{/if}} {{#unless sizeNum}}zero-stock{{/unless}}" data-id={{id}} data-colorid="{{colorId}}" data-num="{{sizeNum}}" data-numstr="{{colorNumStr}}" data-skuid="{{skuId}}" data-goodid="{{goodsId}}">
{{name}}
</li>
{{/ size}}
</ul>
{{name}}
</li>
{{/ size}}
</ul>
{{/ sizes}}
</div>
<p>
<div class="num">
<span>数量</span>
<div class="clearfix">
<a class="btn btn-minus" href="javascript:void(0);">
<span class="iconfont">&#xe625;</span>
</a>
<input id="good-num" class="good-num" type="text" value="1">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont">&#xe624;</span>
</a>
{{/ sizes}}
</div>
<p>
<div class="num">
<span>数量</span>
<div class="clearfix">
<a class="btn btn-minus" href="javascript:void(0);">
<span class="iconfont">&#xe625;</span>
</a>
<input id="good-num" class="good-num" type="text" value="1">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont">&#xe624;</span>
</a>
</div>
<span class="left-num"></span>
<input id="left-num" type="hidden" value="0">
</div>
<span class="left-num"></span>
<input id="left-num" type="hidden" value="0">
</div>
</div>
</div>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure">确定</button>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure">确定</button>
</div>
</div>
</div>
</div>
{{/cartInfo}}
\ No newline at end of file
{{/cartInfo}}
\ No newline at end of file
... ...
<div class="shopping-cart-good clearfix" data-id={{id}}>
{{#if isSoldOut}}
<div class="shopping-cart-good clearfix" data-id="{{id}}">
{{#if inValid}}
<span class="few-tag-expire">失效</span>
{{^}}
{{#if isSelected}}
<span class="checkbox icon-cb-checked iconfont"></span>
{{^}}
<span class="checkbox icon-checkbox iconfont"></span>
{{/if}}
{{/if}}
{{#if showCheckbox}}
<span class="checkbox{{#if checked}} icon-cb-checked{{^}} icon-checkbox{{/if}}iconfont"></span>
{{/if}}
<div class="info">
<img class="thumb lazy" data-original={{thumb}}>
<img class="thumb lazy" data-original="{{thumb}}">
{{#if isAdvanceBuy}}
<p class="few-tag plus-tag">加价购</p>
{{^}}
{{#if isGift}}
{{/if}}
{{#if isGift}}
<p class="few-tag gift-tag">赠品</p>
{{/if}}
{{/if}}
</a>
<div class="deps show">
<p class="name row">{{name}}</p>
... ... @@ -67,15 +63,5 @@
</p>
{{/if}}
</div>
<div class="calculate-num hide">
<div class="calculate">
<p><i class="iconfont cut">&#xe625;</i><span>{{count}}</span><i class="iconfont add">&#xe624;</i></p>
<p><span>颜色:{{color}}尺码:{{size}}{{name}}</span><i class="iconfont down">&#xe616;</i></p>
</div>
<p><span class="price"> ¥{{price}}</span></p>
<span class="count">
×{{count}}
</span>
</div>
</div>
</div>
... ...
... ... @@ -196,7 +196,7 @@ class DetailModel
);
$colorStorageNum += intval($size['goodsSizeStorageNum']);
$sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
$colorStorageGroup[$size['sizeName']][$value['colorId']] = $size['goodsSizeStorageNum'];
$colorStorageGroup[$size['sizeName']][$value['productSkc']] = $size['goodsSizeStorageNum'];
}
// 颜色分组
... ...
... ... @@ -192,15 +192,15 @@ class IndexController extends AbstractAction
$this->echoJson($result);
}
/*
* 获取购物车加价购商品数据模板
*/
public function giftinfoTplAction()
{
if ($this->isAjax()) {
echo file_get_contents($this->_view->getScriptPath() . '/../partials/cart/chose-panel.phtml');
}
}
// /*
// * 获取购物车加价购商品数据模板
// */
// public function giftinfoTplAction()
// {
// if ($this->isAjax()) {
// echo file_get_contents($this->_view->getScriptPath() . '/../partials/cart/chose-panel.phtml');
// }
// }
/*
* 获取购物车加价购商品数据
... ... @@ -215,7 +215,9 @@ class IndexController extends AbstractAction
$result = CartModel::giftProductData($skn, $promotionId);
}
$this->echoJson($result);
$this->_view->display('gift-info', array(
'cartInfo' => $result['data']
));
}
/**
... ... @@ -269,7 +271,7 @@ class IndexController extends AbstractAction
$this->auditJumpLogin();
$this->setTitle('确认订单');
$this->setNavHeader('确认订单');
$this->setNavHeader('确认订单', true, false); // 不显示右上角home按钮
// 购物车商品为空跳转到购物车页面
$shoppingKey = Helpers::getShoppingKeyByCookie();
... ...