Merge branch 'fix/issue' into 'develop'
购物车删除商品的代码优化 See merge request !74
Showing
3 changed files
with
17 additions
and
17 deletions
@@ -22,23 +22,10 @@ var navHammer, | @@ -22,23 +22,10 @@ var navHammer, | ||
22 | freebieHammer, | 22 | freebieHammer, |
23 | switchChose = false; | 23 | switchChose = false; |
24 | 24 | ||
25 | -//require('./good'); | ||
26 | - | ||
27 | -function isCookiesEnabled() { | ||
28 | - var cookieEnabled = (navigator.cookieEnabled) ? true : false; | ||
29 | - | ||
30 | - if (typeof navigator.cookieEnabled === 'undefined' && !cookieEnabled) { | ||
31 | - document.cookie = 'testcookie'; | ||
32 | - cookieEnabled = (document.cookie.indexOf('testcookie') !== -1) ? true : false; | ||
33 | - } | ||
34 | - | ||
35 | - return (cookieEnabled); | ||
36 | -} | ||
37 | - | ||
38 | 25 | ||
39 | function needLoadRecommandForYou() { | 26 | function needLoadRecommandForYou() { |
40 | - return isCookiesEnabled() ? | ||
41 | - $('.shopping-cart-good').length <= 0 && window.cookie('yoho-cart-refreshByDelete') !== 'true' : | 27 | + return window.isCookiesEnabled() ? |
28 | + $('.shopping-cart-good').length <= 0 && window.cookie('_yoho-cart-refreshByDelete') !== 'true' : | ||
42 | $('.shopping-cart-good').length <= 0; | 29 | $('.shopping-cart-good').length <= 0; |
43 | } | 30 | } |
44 | 31 | ||
@@ -48,7 +35,7 @@ if (needLoadRecommandForYou()) { | @@ -48,7 +35,7 @@ if (needLoadRecommandForYou()) { | ||
48 | require('./good'); | 35 | require('./good'); |
49 | } | 36 | } |
50 | 37 | ||
51 | -window.setCookie('yoho-cart-refreshByDelete', false); | 38 | +window.setCookie('_yoho-cart-refreshByDelete', false); |
52 | 39 | ||
53 | ellipsis.init(); | 40 | ellipsis.init(); |
54 | 41 |
@@ -108,7 +108,7 @@ $('.icon-del').on('touchstart', function(e) { | @@ -108,7 +108,7 @@ $('.icon-del').on('touchstart', function(e) { | ||
108 | }); | 108 | }); |
109 | orderInfo('couponCode', null); | 109 | orderInfo('couponCode', null); |
110 | orderInfo('couponName', null); | 110 | orderInfo('couponName', null); |
111 | - window.setCookie('yoho-cart-refreshByDelete', true); | 111 | + window.setCookie('_yoho-cart-refreshByDelete', true); |
112 | window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); | 112 | window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); |
113 | } else { | 113 | } else { |
114 | tip.show(data.message); | 114 | tip.show(data.message); |
@@ -58,6 +58,17 @@ function setCookie(name, value, options) { | @@ -58,6 +58,17 @@ function setCookie(name, value, options) { | ||
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | +function isCookiesEnabled() { | ||
62 | + var cookieEnabled = (navigator.cookieEnabled) ? true : false; | ||
63 | + | ||
64 | + if (typeof navigator.cookieEnabled === 'undefined' && !cookieEnabled) { | ||
65 | + document.cookie = 'testcookie'; | ||
66 | + cookieEnabled = (document.cookie.indexOf('testcookie') !== -1) ? true : false; | ||
67 | + } | ||
68 | + | ||
69 | + return (cookieEnabled); | ||
70 | +} | ||
71 | + | ||
61 | function getUser() { | 72 | function getUser() { |
62 | var c = cookie('_UID'), | 73 | var c = cookie('_UID'), |
63 | user; | 74 | user; |
@@ -276,6 +287,8 @@ window.cookie = cookie; | @@ -276,6 +287,8 @@ window.cookie = cookie; | ||
276 | 287 | ||
277 | window.setCookie = setCookie; | 288 | window.setCookie = setCookie; |
278 | 289 | ||
290 | +window.isCookiesEnabled = isCookiesEnabled; | ||
291 | + | ||
279 | window.getUser = getUser; | 292 | window.getUser = getUser; |
280 | 293 | ||
281 | window.getUid = getUid; | 294 | window.getUid = getUid; |
-
Please register or login to post a comment