Authored by 陈峰

使用yoho-cookie组件

@@ -5,6 +5,8 @@ @@ -5,6 +5,8 @@
5 */ 5 */
6 'use strict'; 6 'use strict';
7 7
  8 +let cookie = require('yoho-cookie');
  9 +
8 require('cart/index.page.css'); 10 require('cart/index.page.css');
9 require('../common'); 11 require('../common');
10 let $ = require('yoho-jquery'), 12 let $ = require('yoho-jquery'),
@@ -61,7 +63,7 @@ let indexObj = { @@ -61,7 +63,7 @@ let indexObj = {
61 self.refreshPage(); 63 self.refreshPage();
62 return; 64 return;
63 } 65 }
64 - let cartType = window.cookie('cartType') || 'ordinary'; 66 + let cartType = cookie.get('_cartType') || 'ordinary';
65 67
66 // 普通购物车空,则显示预售购物车 68 // 普通购物车空,则显示预售购物车
67 69
@@ -75,7 +77,7 @@ let indexObj = { @@ -75,7 +77,7 @@ let indexObj = {
75 data.cartNav = true; 77 data.cartNav = true;
76 data.cartType = cartType || 'ordinary'; 78 data.cartType = cartType || 'ordinary';
77 } 79 }
78 - window.setCookie('cartType', data.cartType); 80 + cookie.set('_cartType', data.cartType);
79 data.ordinaryCart = data.cartType === 'ordinary'; 81 data.ordinaryCart = data.cartType === 'ordinary';
80 data.advanceCart = !data.ordinaryCart; 82 data.advanceCart = !data.ordinaryCart;
81 if (data.isEmptyCart) { 83 if (data.isEmptyCart) {
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 'use strict'; 7 'use strict';
8 8
9 let $ = require('yoho-jquery'), 9 let $ = require('yoho-jquery'),
  10 + cookie = require('yoho-cookie'),
10 tip = require('../../plugin/tip'), 11 tip = require('../../plugin/tip'),
11 dialog = require('../../plugin/dialog'); 12 dialog = require('../../plugin/dialog');
12 13
@@ -14,7 +15,7 @@ let $ = require('yoho-jquery'), @@ -14,7 +15,7 @@ let $ = require('yoho-jquery'),
14 let actCkOpthn = { 15 let actCkOpthn = {
15 expires: 'Session', 16 expires: 'Session',
16 path: '/cart/index', 17 path: '/cart/index',
17 - domain: '.m.yohobuy.com' 18 + domain: 'm.yohobuy.com'
18 }; 19 };
19 20
20 let cartObj = { 21 let cartObj = {
@@ -47,17 +48,17 @@ let cartObj = { @@ -47,17 +48,17 @@ let cartObj = {
47 let self = this; 48 let self = this;
48 let type = $(e.currentTarget).data('type'); 49 let type = $(e.currentTarget).data('type');
49 50
50 - window.setCookie('cartType', type); 51 + cookie.set('_cartType', type);
51 self.handle.refreshPage(''); 52 self.handle.refreshPage('');
52 }, 53 },
53 initPresellTip() { 54 initPresellTip() {
54 - if (typeof window.cookie === 'function' && window.cookie('_hasShowCartPresellTip') === 'y') { 55 + if (cookie.enabled() && cookie.get('_hasShowCartPresellTip') === 'y') {
55 $('#presell-tip').removeClass('show').addClass('hide'); 56 $('#presell-tip').removeClass('show').addClass('hide');
56 } else { 57 } else {
57 $('#presell-tip').removeClass('hide').addClass('show'); 58 $('#presell-tip').removeClass('hide').addClass('show');
58 setTimeout(function() { 59 setTimeout(function() {
59 $('#presell-tip').removeClass('show').addClass('hide'); 60 $('#presell-tip').removeClass('show').addClass('hide');
60 - window.setCookie('_hasShowCartPresellTip', 'y'); 61 + cookie.set('_hasShowCartPresellTip', 'y');
61 }, 3000); 62 }, 3000);
62 } 63 }
63 }, 64 },
@@ -75,7 +76,7 @@ let cartObj = { @@ -75,7 +76,7 @@ let cartObj = {
75 }); 76 });
76 }, 77 },
77 toPromotionPage(opts) { 78 toPromotionPage(opts) {
78 - let cartType = window.cookie('cartType') || 'ordinary'; 79 + let cartType = cookie.get('_cartType') || 'ordinary';
79 let title = '促销商品'; 80 let title = '促销商品';
80 81
81 if (opts.promotionType === 'Gift') { 82 if (opts.promotionType === 'Gift') {
@@ -97,7 +98,7 @@ let cartObj = { @@ -97,7 +98,7 @@ let cartObj = {
97 } 98 }
98 }, 99 },
99 allGiftBoxClick(e) { 100 allGiftBoxClick(e) {
100 - let cartType = window.cookie('cartType') || 'ordinary'; 101 + let cartType = cookie.get('_cartType') || 'ordinary';
101 102
102 if ($(e.currentTarget).find('.no-storage').length) { 103 if ($(e.currentTarget).find('.no-storage').length) {
103 return; 104 return;
@@ -110,7 +111,7 @@ let cartObj = { @@ -110,7 +111,7 @@ let cartObj = {
110 }, 111 },
111 balanceClick() { 112 balanceClick() {
112 let self = this; 113 let self = this;
113 - let cartType = window.cookie('cartType') || 'ordinary'; 114 + let cartType = cookie.get('_cartType') || 'ordinary';
114 115
115 if (window._yas && window._yas.sendCustomInfo) { 116 if (window._yas && window._yas.sendCustomInfo) {
116 let productId = Array.from($('.good-item.is-checked').map((i, e) => $(e).data('id'))); 117 let productId = Array.from($('.good-item.is-checked').map((i, e) => $(e).data('id')));
@@ -154,7 +155,7 @@ let cartObj = { @@ -154,7 +155,7 @@ let cartObj = {
154 self.toOrderEnsure(cartType); 155 self.toOrderEnsure(cartType);
155 }, 156 },
156 toOrderEnsure(cartType) { 157 toOrderEnsure(cartType) {
157 - window.cookie('order-info') && window.setCookie('order-info', '', actCkOpthn); 158 + cookie.get('order-info') && cookie.remove('order-info');
158 window.location.href = '/cart/index/new/orderEnsure?cartType=' + cartType; 159 window.location.href = '/cart/index/new/orderEnsure?cartType=' + cartType;
159 }, 160 },
160 toGiftPromotion(cartType) { 161 toGiftPromotion(cartType) {