Authored by 梁志锋

购物车功能开发

/**
* 购物车信息读取
* @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));
};
... ...
... ... @@ -8,9 +8,13 @@ var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var chosePanel = require('./chose-panel'),
cartInfo = require('./cart-info').cartInfo;
var $cartContent = $('.cart-content');
var navHammer;
var navHammer,
cartType = 'ordinary';
require('./good');
... ... @@ -32,4 +36,30 @@ navHammer.on('tap', function(e) {
//trigger lazyload
$(window).trigger('scroll');
});
\ No newline at end of file
});
$('.btn-balance').on('touchend', function() {
window.location.href = '/shoppingCart/orderEnsure?cartType=' + cartType;
});
$('.advance-buy').on('touchend', function() {
var $advanceBuy = $('#advanceBuy'),
$mainCart = $('#mainCart');
if ($advanceBuy.hasClass('hide')) {
$mainCart.removeClass('show').addClass('hide');
$advanceBuy.removeClass('hide').addClass('show');
} else {
$advanceBuy.removeClass('show').addClass('hide');
$mainCart.removeClass('hide').addClass('show');
}
});
$('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel.show();
});
... ...
... ... @@ -9,14 +9,10 @@ var $ = require('jquery'),
lazyLoad = require('yoho.lazyload');
var dialog = require('../me/dialog'),
tip = require('../plugin/tip'),
chosePanel = require('./chose-panel');
tip = require('../plugin/tip');
var $names;
//chosePanel = require('./chose-panel');
var cartType = 'ordinary';
var $names;
//var $curDelPanel;
... ... @@ -153,27 +149,3 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
//})
$('.btn-balance').on('touchend', function() {
window.location.href = '/shoppingCart/orderEnsure?cartType=' + cartType;
});
$('.advance-buy').on('touchend', function() {
var $advanceBuy = $('#advanceBuy'),
$mainCart = $('#mainCart');
if ($advanceBuy.hasClass('hide')) {
$mainCart.removeClass('show').addClass('hide');
$advanceBuy.removeClass('hide').addClass('show');
} else {
$advanceBuy.removeClass('show').addClass('hide');
$mainCart.removeClass('hide').addClass('show');
}
});
$('.chose').on('touchend', function() {
//var id = $(this).closest('.gift-advance-good').data('id');
chosePanel.show();
});
... ...
... ... @@ -70,4 +70,5 @@
{{> product/recommend-for-you}}
</div>
{{> shopping-cart/chose-panel}}
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -31,4 +31,6 @@
</p>
<button class="chose">选择</button>
</div>
</div>
\ No newline at end of file
... ...