Authored by hf

code review by hf: fixes bugs to merge liangzhifeng bikai zhangzhen codes

... ... @@ -3340,7 +3340,15 @@ var api = require("js/passport/api"),
var trim = $.trim;
var showErrTip = tip.show;
var requesting = false;
function nextStep(url, mobileNo, areaCode) {
if (requesting) {
return false;
}
requesting = true;
$.ajax({
type: 'POST',
url: '/passport/bind/sendBindMsg',
... ... @@ -3351,9 +3359,13 @@ function nextStep(url, mobileNo, areaCode) {
success: function(res) {
console.log(res.data);
location.href = url;
requesting = false;
},
error: function() {
tip.show('出错了,请重试!');
requesting = false;
}
});
}
... ... @@ -5402,7 +5414,7 @@ if (navtabHammer) {
if (gotoConsultHammer) {
gotoConsultHammer.on('tap', function() {
location.href = $(gotoConsultEle).data('href');
location.href = $(gotoConsultEle).find('a').attr('href');
});
}
... ... @@ -5585,8 +5597,8 @@ var $ = require("jquery"),
var $chosePanel = $('#chose-panel'),
$num,
$chosed,
// re = /\d+/,
$imgsThumb,
$leftNum,
leftNum,
confirming,
curColorIndex,
... ... @@ -5595,7 +5607,11 @@ var $chosePanel = $('#chose-panel'),
hasChooseColor,
hasChooseSize,
$curSizeBlock,
$sizeRowList;
$sizeRowList,
cbFn,
$allChoseItems,
queryString,
$yohoPage = $('.yoho-page');
//初始化购物车面板显示
function init() {
... ... @@ -5604,12 +5620,15 @@ function init() {
hasChooseColor = false;
hasChooseSize = false;
$curSizeBlock = null;
queryString = $.queryString();
$imgsThumb = $('.chose-panel').find('.thumb');
$allChoseItems = $('.chose-items');
$sizeRowList = $('.size-list ul');
$leftNum = $('#left-num');
$firstRow = $sizeRowList.eq(0);
$firstRow.toggleClass('hide');
$curSizeRow = $firstRow;
}
init();
function checkColorSizeNum() {
if (!hasChooseColor && !hasChooseSize) {
... ... @@ -5625,32 +5644,28 @@ function checkColorSizeNum() {
return true;
}
function show(html) {
function show(html, cb) {
if (html) {
$chosePanel.html(html);
init();
}
$('.chose-panel').show();
$('body').css('overflow', 'hidden');
$num = $('#good-num');
cbFn = cb;
}
//隐藏当前Panel
function hide() {
$('.chose-panel').hide();
$('body').css('overflow', 'auto');
}
//修改加入购物车的文字和背景
function updateConformButtonClassAndText() {
$chosed = $('.chose-items').find('.chosed');
$chosed = $allChoseItems.find('.chosed');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0');
$('#chose-btn-sure').html('已售罄');
$('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313');
$('#chose-btn-sure').html('确定');
$('#chose-btn-sure').css('background-color', '#eb0313').html('确定');
}
}
... ... @@ -5679,13 +5694,13 @@ function resetColorZeroStock($siblingBlock) {
// 选择了颜色切换商品图片
function changeGoodImgWhenClickColor() {
if (hasChooseColor && curColorIndex) {
$('.chose-panel').find('.thumb').addClass('hide').eq(curColorIndex).removeClass('hide');
$imgsThumb.addClass('hide').eq(curColorIndex).removeClass('hide');
}
}
init();
$('.yoho-page').on('touchstart', '.chose-panel', function(e) {
$yohoPage.on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
if ($cur.closest('.main').length > 0) {
... ... @@ -5696,12 +5711,11 @@ $('.yoho-page').on('touchstart', '.chose-panel', function(e) {
hide();
});
$('.color-list').on('touchstart', '.block', function(e) {
$yohoPage.on('touchstart', '.color-list .block', function(e) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
index,
curSelectedSizeBlock,
$sizeChosed,
curSizeBlock,
$preSiblingBlock,
scindex,
curGoodNum;
... ... @@ -5710,16 +5724,16 @@ $('.color-list').on('touchstart', '.block', function(e) {
$this.siblings('.chosed').removeClass('chosed');
index = $this.index();
$sizeChosed = $siblingBlock.find('.chosed');
scindex = $sizeChosed.index();
$preSiblingBlock = $siblingBlock.find('.chosed');
scindex = $preSiblingBlock.index();
$curSizeRow = $sizeRowList.eq(index);
// 当前颜色已经是选中状态,再点击时
if ($this.hasClass('chosed')) {
//颜色原来已经是勾选时,要清空剩余件数的提示
$that.find('.num .left-num').html('');
$('#left-num').val(0);
$allChoseItems.find('.num .left-num').html('');
$leftNum.val(0);
hasChooseColor = false;
// 当前颜色不是选中状态,选中时
... ... @@ -5731,24 +5745,23 @@ $('.color-list').on('touchstart', '.block', function(e) {
$curSizeRow.removeClass('hide').addClass('show');
// 之前选中的尺码去掉勾选样式
if ($sizeChosed.length > 0) {
$sizeChosed.removeClass('chosed');
curSelectedSizeBlock = $curSizeRow.children().get(scindex);
if ($preSiblingBlock.length > 0) {
$preSiblingBlock.removeClass('chosed');
curSizeBlock = $curSizeRow.children().get(scindex);
}
// 当前选中颜色对应的尺码行,其对应的尺码加上勾选样式 (前提是要判断下这个尺码是否存在)
if (curSelectedSizeBlock) {
curGoodNum = $(curSelectedSizeBlock).data('num');
$(curSelectedSizeBlock).addClass('chosed');
if (curSizeBlock) {
curGoodNum = $(curSizeBlock).data('num');
$(curSizeBlock).addClass('chosed');
//如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式
if (curGoodNum > 0) {
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
$leftNum.val(curGoodNum);
} else {
$(curSelectedSizeBlock).removeClass('zero-stock').addClass('zero-stock');
$that.find('.num .left-num').html('');
$('#left-num').val(0);
$allChoseItems.find('.num .left-num').html('');
$leftNum.val(0);
}
}
}
... ... @@ -5764,9 +5777,8 @@ $('.color-list').on('touchstart', '.block', function(e) {
changeGoodImgWhenClickColor();
});
$('.size-list').on('touchstart', '.block', function(e) {
$yohoPage.on('touchstart', '.size-list .block', function(e) {
var $this = $(this),
$that = $(e.target).closest('.chose-items'),
index,
curGoodNum;
... ... @@ -5780,7 +5792,7 @@ $('.size-list').on('touchstart', '.block', function(e) {
if ($this.hasClass('chosed')) {
//尺码原来已经是勾选时,要清空剩余件数的提示
$that.find('.num .left-num').html('');
$allChoseItems.find('.num .left-num').html('');
$('#left-num').val(0);
hasChooseSize = false;
... ... @@ -5795,12 +5807,12 @@ $('.size-list').on('touchstart', '.block', function(e) {
$curSizeBlock.removeClass('chosed');
}
// 如果当前有尺码被选中,且数量等于0,则颜色块添加数量为0的样式, 否则显示剩余件数
// 如果当前有尺码被选中,且数量等于0, 否则显示剩余件数
if (curGoodNum > 0 && hasChooseColor) {
$that.find('.num .left-num').html('剩余' + curGoodNum + '件');
$allChoseItems.find('.num .left-num').html('剩余' + curGoodNum + '件');
$('#left-num').val(curGoodNum);
} else {
$that.find('.num .left-num').html('');
$allChoseItems.find('.num .left-num').html('');
$('#left-num').val(0);
}
... ... @@ -5818,8 +5830,8 @@ $('.size-list').on('touchstart', '.block', function(e) {
});
$('.btn-minus').on('touchstart', function() {
var num = $num.val();
$yohoPage.on('touchstart', '.btn-minus', function() {
var num = parseInt($num.val(), 10);
leftNum = $('#left-num').val();
... ... @@ -5832,10 +5844,8 @@ $('.btn-minus').on('touchstart', function() {
}
$num.val(num - 1);
});
$('.btn-plus').on('touchstart', function() {
var num = $num.val();
}).on('touchstart', '.btn-plus', function() {
var num = parseInt($num.val(), 10);
leftNum = $('#left-num').val();
... ... @@ -5850,9 +5860,7 @@ $('.btn-plus').on('touchstart', function() {
//TODO:库存数验证
$num.val(num + 1);
});
$('#chose-btn-sure').on('touchstart', function() {
}).on('touchstart', '#chose-btn-sure', function() {
var productSku,
buyNumber = $('#good-num').val() - 0,
... ... @@ -5867,6 +5875,7 @@ $('#chose-btn-sure').on('touchstart', function() {
return;
}
//TODO status change
if ($('#chose-btn-sure').html() === '已售罄') {
return;
}
... ... @@ -5896,15 +5905,19 @@ $('#chose-btn-sure').on('touchstart', function() {
productSku: productSku,
buyNumber: buyNumber,
promotionId: promotionId,
isEdit: isEdit
isEdit: isEdit,
cartType: queryString.cartType
}
}).done(function(res) {
loading.hideLoadingMask();
if (res.code === 200) {
$('.num-tag').html(numInCart + buyNumber);
$('.num-tag').removeClass('hide');
$('.num-tag').html(numInCart + buyNumber).removeClass('hide');
confirming = false;
hide();
if (cbFn) {
cbFn();
}
}
if (res.message) {
tip.show(res.message);
... ... @@ -8614,6 +8627,10 @@ if ($('.cart-nav').length > 0) {
}, 3000);
}
$('.advance-buy').on('touchend', function() {
window.location.href = '/cart/index/advanceBuy?cartType=' + cartType;
});
$('.btn-balance').on('touchend', function() {
if (hasChecked) {
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
... ... @@ -8644,7 +8661,8 @@ var $ = require("jquery"),
lazyLoad = require("lazyload");
var dialog = require("js/me/dialog"),
tip = require("js/plugin/tip");
tip = require("js/plugin/tip"),
orderInfo = require("js/cart/order-info").orderInfo;
var $selectAllBtn = $('.balance .checkbox'),
cartType = $('#cartType').val(),
... ... @@ -8740,6 +8758,8 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
autoHide: true,
fast: true
});
orderInfo('couponCode', null);
orderInfo('couponName', null);
history.go(0);
} else {
tip.show(data.message);
... ... @@ -8858,7 +8878,51 @@ $('.down').on('touchend', function() {
chosePanel.show();
});
});
define("js/cart/order-info", ["jquery"], function(require, exports, module){
/**
* 订单信息读取
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var $ = require("jquery");
var info = window.cookie('order-info');
function init() {
info = {
uid: window.getUid(),
deliveryId: 1,
deliveryTimeId: 1,
paymentTypeId: 1,
yohoCoin: $('.coin').data('yoho-coin') || 0,
addressId: null,
couponCode: null,
couponName: null,
invoice: null,
invoiceText: null,
invoiceType: null,
msg: null,
cartType: 'ordinary'
};
window.setCookie('order-info', JSON.stringify(info));
}
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
init();
}
exports.init = init;
exports.orderInfo = function(key, value) {
if (value === undefined) {
return info[key];
}
info[key] = value;
window.setCookie('order-info', JSON.stringify(info));
};
});
define("js/cart/gift-advance", ["jquery","lazyload"], function(require, exports, module){
... ... @@ -8874,7 +8938,8 @@ var $ = require("jquery"),
loading = require("js/plugin/loading"),
chosePanel = require("js/cart/chose-panel");
var $page = $('.gift-advance-page');
var $page = $('.gift-advance-page'),
queryString = $.queryString();
lazyLoad($('.lazy'));
... ... @@ -8888,7 +8953,9 @@ function getProductInfo(skn, promotionId) {
tip.show('网络错误');
return;
}
chosePanel.show(html);
chosePanel.show(html, function() {
window.location.href = '/cart/index/index?cartType=' + queryString.cartType;
});
}, function() {
tip.show('网络错误');
}).always(function() {
... ... @@ -8936,11 +9003,13 @@ if (window.getUid() !== orderInfo('uid')) {
order.init();
}
if ($couponUse.data('value') !== orderInfo('couponValue')) {
if ($couponUse.data('name') !== orderInfo('couponName')) {
orderInfo('couponCode', null);
orderInfo('couponValue', null);
orderInfo('couponName', null);
}
orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary');
function dispacthTapEvt(e) {
var $cur = $(e.target).closest('li');
... ... @@ -8986,7 +9055,7 @@ function orderCompute() {
method: 'POST',
url: '/cart/index/orderCompute',
data: {
cartType: queryString.cartType || queryString.carttype || 'ordinary',
cartType: orderInfo('cartType') || 'ordinary',
deliveryId: orderInfo('deliveryId'),
paymentTypeId: orderInfo('paymentTypeId'),
couponCode: orderInfo('couponCode'),
... ... @@ -9047,11 +9116,12 @@ function submitOrder() {
url: '/cart/index/orderSub',
data: {
addressId: orderInfo('addressId'),
cartType: queryString.cartType || queryString.carttype || 'ordinary',
cartType: orderInfo('cartType') || 'ordinary',
deliveryId: orderInfo('deliveryId'),
deliveryTimeId: orderInfo('deliveryTimeId'),
invoiceText: invoiceText,
invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'),
invoiceText: orderInfo('invoice') ? invoiceText : null,
invoiceType: orderInfo('invoice') ? ($invoice.find('.invoice-type').val() ||
orderInfo('invoiceType')) : null,
msg: msg,
paymentTypeId: orderInfo('paymentTypeId'),
paymentType: orderInfo('paymentType'), //支付方式
... ... @@ -9139,51 +9209,6 @@ $('.pay-mode').on('click', 'li', function() {
});
});
define("js/cart/order-info", ["jquery"], function(require, exports, module){
/**
* 订单信息读取
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var $ = require("jquery");
var info = window.cookie('order-info');
function init() {
info = {
uid: window.getUid(),
deliveryId: 1,
deliveryTimeId: 1,
paymentTypeId: 1,
yohoCoin: $('.coin').data('yoho-coin') || 0,
addressId: null,
couponCode: null,
couponValue: null,
invoice: null,
invoiceText: null,
invoiceType: null,
msg: null
};
window.setCookie('order-info', JSON.stringify(info));
}
// info 必须是 JSON 字符串
try {
info = JSON.parse(info);
} catch (e) {
init();
}
exports.init = init;
exports.orderInfo = function(key, value) {
if (value === undefined) {
return info[key];
}
info[key] = value;
window.setCookie('order-info', JSON.stringify(info));
};
});
define("js/cart/select-coupon", ["jquery","handlebars","source-map","mlellipsis"], function(require, exports, module){
/**
* 优惠券选择
... ... @@ -9224,7 +9249,7 @@ $newCoupon.on('submit', function() {
if (res.code === 200) {
tip.show('优惠券可用');
orderInfo('couponCode', res.data.coupon_code);
orderInfo('couponValue', res.data.coupon_value);
orderInfo('couponName', res.data.coupon_title);
window.location.href = '/cart/index/orderEnsure';
} else {
tip.show(res.message || '网络错误');
... ... @@ -9239,12 +9264,12 @@ $('#coupon-list').on('touchend', '.employ-main', function() {
var $this = $(this);
orderInfo('couponCode', $this.data('coupon-code'));
orderInfo('couponValue', $this.data('coupon-value'));
orderInfo('couponName', $this.data('coupon-name'));
});
$('body').on('touchend', '.not-use', function() {
orderInfo('couponCode', null);
orderInfo('couponValue', null);
orderInfo('couponName', null);
});
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -2,7 +2,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>
Created by FontForge 20120731 at Sat Dec 5 16:26:44 2015
Created by FontForge 20120731 at Thu Dec 17 13:53:30 2015
By Ads
</metadata>
<defs>
... ... @@ -19,7 +19,7 @@ Created by FontForge 20120731 at Sat Dec 5 16:26:44 2015
bbox="-0.75 -224 3943 833"
underline-thickness="50"
underline-position="-100"
unicode-range="U+0078-E63F"
unicode-range="U+0078-E640"
/>
<missing-glyph horiz-adv-x="374"
d="M34 0v682h272v-682h-272zM68 34h204v614h-204v-614z" />
... ... @@ -257,5 +257,11 @@ d="M512 -66q-10 0 -24.5 -0.5t-25 -1t-24 0t-24.5 1.5l-222 -146q0 227 5 243q-164 1
q-91 0 -176.5 -31.5t-148.5 -83.5t-100.5 -124.5t-37.5 -150.5q0 -95 53 -179t142 -138v-170l146 97q16 -3 35.5 -4t49 0t37.5 1q41 0 81 6.5t77 18.5t72 29.5t65 39.5t56.5 47.5t47 55t35 61t22 66t7.5 69.5q0 104 -63.5 194.5t-170.5 143t-229 52.5zM768 300
q-27 0 -45.5 18.5t-18.5 45.5t18.5 45.5t45.5 18.5t45.5 -18.5t18.5 -45.5t-18.5 -45.5t-45.5 -18.5zM512 300q-27 0 -45.5 18.5t-18.5 45.5t18.5 45.5t45.5 18.5t45.5 -18.5t18.5 -45.5t-18.5 -45.5t-45.5 -18.5zM256 300q-27 0 -45.5 18.5t-18.5 45.5t18.5 45.5t45.5 18.5
t45.5 -18.5t18.5 -45.5t-18.5 -45.5t-45.5 -18.5z" />
<glyph glyph-name="uniE640" unicode="&#xe640;"
d="M957 510q-5 8 -14 13.5t-24 5.5h-598l-29 62l-4 7q-1 3 -4 7t-8 8q-4 3 -7 6l-2 1l-8 4h-2q-5 2 -9 2l-4 1h-5h-118q-23 0 -40 -16.5t-17 -40.5q0 -6 1.5 -12.5t4.5 -12.5t7 -10.5t8.5 -8.5t10.5 -7t12.5 -4.5t12.5 -1.5h81l33 -71q3 -10 8 -21t8 -17l3 -5l81 -181
q0 -2 2 -5l15 -32q9 -30 39 -38v-3h392l18 1v2q14 4 24.5 14t14.5 24l98 217q40 77 19 112zM909 413l-93 -207l-3 1l-4 -15q-5 -19 -25 -19l-19 1v-1h-340h-18q-8 0 -15 5t-9 14l-4 15l-3 -1l-93 208q-1 1 -3.5 5.5t-7 14.5t-7.5 20l-42 92h-102q-10 0 -17 7t-7 17
q0 7 3 12.5t9 9t12 3.5h119l3 -1h2q1 0 2 -1l4 -2q2 -1 4 -3q1 -1 2 -1.5t1 -1.5l4 -6l38 -83h619q8 0 10 -3q3 -6 1 -19t-7.5 -29.5t-13.5 -31.5zM470 107q-33 0 -56.5 -23t-23.5 -56q0 -22 10.5 -40.5t29 -29t40.5 -10.5q33 0 56.5 23.5t23.5 56.5t-23.5 56t-56.5 23z
M470 -23q-21 0 -36 15t-15 36t15 36t36 15q14 0 25.5 -7t18.5 -19t7 -25q0 -22 -15 -36.5t-36 -14.5zM747 107q-33 0 -56.5 -23t-23.5 -56q0 -22 10.5 -40.5t29 -29t40.5 -10.5q33 0 56.5 23.5t23.5 56.5t-23.5 56t-56.5 23zM747 -23q-14 0 -26 6.5t-18.5 18.5t-6.5 25.5
t6.5 25.5t18.5 19t26 7q21 0 36 -15t15 -36t-15 -36t-36 -15z" />
</font>
</defs></svg>
... ...