Authored by biao

商品详情页增加限购商品购买的相关逻辑

... ... @@ -38,12 +38,19 @@ var $chosePanel = $('#chose-panel'),
$soonSoldOut = $('.soonSoldOut-tag'),
$yohoPage = $('.yoho-page');
//购物车编辑标相关变量
// 购物车编辑标相关变量
var isEdit,
isSelected,
oldSknId;
//初始化购物车面板显示
// 限购商品的商品码。只有限购商品时才会设置。
var limitProductCode,
// 限购商品的skn。只有限购商品时才会设置。
skn;
// 初始化购物车面板显示
function init() {
hasChooseColor = false;
hasChooseSize = false;
... ... @@ -77,6 +84,21 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) {
isSelected = isThisGoodSelected;
}
/*
* 设置当前面板为限购商品模式
*
* @param {String} code 当前限购商品的商品码
*
* @param {String} sknId. 当前限购商品的sknId
*
* @return {undefined}
*/
function setLimitGoodModeWithSknId(code, sknId) {
$('#chose-btn-sure').html('结算');
limitProductCode = code;
skn = sknId;
}
//删除面板
function removePannel() {
var $pannel = $('.chose-panel'),
... ... @@ -149,6 +171,8 @@ function updateConformButtonClassAndText() {
$chosed = $allChoseItems.find('.chosed');
if (2 === $chosed.closest('.zero-stock').length) {
$('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
} else if (limitProductCode) {
$('#chose-btn-sure').css('background-color', '#eb0313').html('结算');
} else {
$('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车');
}
... ... @@ -446,7 +470,16 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
url = '/cart/index/modify';
} else {
} else if (limitProductCode) {
// 当前面板选择的是限购商品
url = 'http://m.yohobuy.com/cart/index/orderEnsure?code=' + limitProductCode + '&&sku=' + productSku + '&&skn=' + skn + '&&buy_num=' + buyNumber;
//打开结算页面,结束函数执行。
window.location.href = url;
return false;
}else {
cartGoodData = {
productSku: productSku,
buyNumber: buyNumber,
... ... @@ -508,4 +541,4 @@ exports.show = show;
exports.remove = removePannel;
exports.setEditModeWithSknId = setEditModeWithSknId;
exports.disableNumEdit = disableNumEdit;
exports.setLimitGoodModeWithSknId = setLimitGoodModeWithSknId;
... ...
... ... @@ -24,6 +24,7 @@ var appUrl = $('input[name="limitCodeUrl"]').val();
var dialog = require('../../me/dialog');
//add extra marign-bottom for footer to show the yoho copyright
function showFooter() {
var $cartBar = $('.cart-bar');
... ... @@ -84,7 +85,7 @@ if (goodsDiscountHammer && $discountFolder.children().length > 0) {
limitSaleHammer && limitSaleHammer.on('tap', function(e) {
e.srcEvent.stopPropagation();
dialog.showDialog({
dialogText: '进入有货APP尖货频道分享\n以获取限购码',
dialogText: '打开有货APP限定发售频道\n获取限购码',
hasFooter: {
rightBtnText: '打开Yoho!Buy有货APP'
}
... ...
... ... @@ -11,6 +11,9 @@ var $ = require('jquery'),
var productId = $('#productId').val();
var skn = $('#preferenceUrl').val().split('?')[1].split('&')[0].split('=')[1],
productCode = $('#productLimitCode').val() || '123';
$('#likeBtn').on('touchstart', function() {
var opt,
favorite;
... ... @@ -65,6 +68,7 @@ $('#likeBtn').on('touchstart', function() {
$('#addtoCart').on('touchstart', function() {
$('.cart-bar').hide();
chosePanel.setLimitGoodModeWithSknId(productCode, skn);
chosePanel.show();
//统计代码:用于统计用户加入购物车的动作
... ...