Authored by 陈峰

使用yoho-cookie组件

... ... @@ -5,6 +5,8 @@
*/
'use strict';
let cookie = require('yoho-cookie');
require('cart/index.page.css');
require('../common');
let $ = require('yoho-jquery'),
... ... @@ -61,7 +63,7 @@ let indexObj = {
self.refreshPage();
return;
}
let cartType = window.cookie('cartType') || 'ordinary';
let cartType = cookie.get('_cartType') || 'ordinary';
// 普通购物车空,则显示预售购物车
... ... @@ -75,7 +77,7 @@ let indexObj = {
data.cartNav = true;
data.cartType = cartType || 'ordinary';
}
window.setCookie('cartType', data.cartType);
cookie.set('_cartType', data.cartType);
data.ordinaryCart = data.cartType === 'ordinary';
data.advanceCart = !data.ordinaryCart;
if (data.isEmptyCart) {
... ...
... ... @@ -7,6 +7,7 @@
'use strict';
let $ = require('yoho-jquery'),
cookie = require('yoho-cookie'),
tip = require('../../plugin/tip'),
dialog = require('../../plugin/dialog');
... ... @@ -14,7 +15,7 @@ let $ = require('yoho-jquery'),
let actCkOpthn = {
expires: 'Session',
path: '/cart/index',
domain: '.m.yohobuy.com'
domain: 'm.yohobuy.com'
};
let cartObj = {
... ... @@ -47,17 +48,17 @@ let cartObj = {
let self = this;
let type = $(e.currentTarget).data('type');
window.setCookie('cartType', type);
cookie.set('_cartType', type);
self.handle.refreshPage('');
},
initPresellTip() {
if (typeof window.cookie === 'function' && window.cookie('_hasShowCartPresellTip') === 'y') {
if (cookie.enabled() && cookie.get('_hasShowCartPresellTip') === 'y') {
$('#presell-tip').removeClass('show').addClass('hide');
} else {
$('#presell-tip').removeClass('hide').addClass('show');
setTimeout(function() {
$('#presell-tip').removeClass('show').addClass('hide');
window.setCookie('_hasShowCartPresellTip', 'y');
cookie.set('_hasShowCartPresellTip', 'y');
}, 3000);
}
},
... ... @@ -75,7 +76,7 @@ let cartObj = {
});
},
toPromotionPage(opts) {
let cartType = window.cookie('cartType') || 'ordinary';
let cartType = cookie.get('_cartType') || 'ordinary';
let title = '促销商品';
if (opts.promotionType === 'Gift') {
... ... @@ -97,7 +98,7 @@ let cartObj = {
}
},
allGiftBoxClick(e) {
let cartType = window.cookie('cartType') || 'ordinary';
let cartType = cookie.get('_cartType') || 'ordinary';
if ($(e.currentTarget).find('.no-storage').length) {
return;
... ... @@ -110,7 +111,7 @@ let cartObj = {
},
balanceClick() {
let self = this;
let cartType = window.cookie('cartType') || 'ordinary';
let cartType = cookie.get('_cartType') || 'ordinary';
if (window._yas && window._yas.sendCustomInfo) {
let productId = Array.from($('.good-item.is-checked').map((i, e) => $(e).data('id')));
... ... @@ -154,7 +155,7 @@ let cartObj = {
self.toOrderEnsure(cartType);
},
toOrderEnsure(cartType) {
window.cookie('order-info') && window.setCookie('order-info', '', actCkOpthn);
cookie.get('order-info') && cookie.remove('order-info');
window.location.href = '/cart/index/new/orderEnsure?cartType=' + cartType;
},
toGiftPromotion(cartType) {
... ...