Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
7 changed files
with
66 additions
and
27 deletions
@@ -22,14 +22,21 @@ var navHammer, | @@ -22,14 +22,21 @@ var navHammer, | ||
22 | freebieHammer, | 22 | freebieHammer, |
23 | switchChose = false; | 23 | switchChose = false; |
24 | 24 | ||
25 | -require('./good'); | ||
26 | 25 | ||
27 | -if ($('.cart-zero').length > 0) { | 26 | +function needLoadRecommandForYou() { |
27 | + return window.isCookiesEnabled() ? | ||
28 | + $('.cart-goods').length <= 0 && window.cookie('_yoho-cart-refreshByDelete') !== 'true' : | ||
29 | + $('.cart-goods').length <= 0; | ||
30 | +} | ||
31 | + | ||
32 | +if (needLoadRecommandForYou()) { | ||
28 | require('../product/recommend-for-you'); | 33 | require('../product/recommend-for-you'); |
29 | } else { | 34 | } else { |
30 | require('./good'); | 35 | require('./good'); |
31 | } | 36 | } |
32 | 37 | ||
38 | +window.setCookie('_yoho-cart-refreshByDelete', false); | ||
39 | + | ||
33 | ellipsis.init(); | 40 | ellipsis.init(); |
34 | 41 | ||
35 | function cartContentShow() { | 42 | function cartContentShow() { |
@@ -108,6 +108,7 @@ $('.icon-del').on('touchstart', function(e) { | @@ -108,6 +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.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); | 112 | window.location.href = '/cart/index/index?cartType=' + $('#cartType').val(); |
112 | } else { | 113 | } else { |
113 | 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; |
@@ -119,7 +119,11 @@ $submit.on('touchend', function() { | @@ -119,7 +119,11 @@ $submit.on('touchend', function() { | ||
119 | }); | 119 | }); |
120 | 120 | ||
121 | // 省市区列表异步加载 | 121 | // 省市区列表异步加载 |
122 | -$.get('/home/locationList').then(function(html) { | 122 | +$.ajax({ |
123 | + method: 'GET', | ||
124 | + url: '/home/locationList', | ||
125 | + timeout: 60000 | ||
126 | +}).then(function(html) { | ||
123 | $addressListPage.html(html); | 127 | $addressListPage.html(html); |
124 | 128 | ||
125 | // 省市区 | 129 | // 省市区 |
@@ -141,7 +145,7 @@ $.get('/home/locationList').then(function(html) { | @@ -141,7 +145,7 @@ $.get('/home/locationList').then(function(html) { | ||
141 | if (e.target.tagName.toLowerCase() !== 'li') { | 145 | if (e.target.tagName.toLowerCase() !== 'li') { |
142 | $this = $this.parent('li'); | 146 | $this = $this.parent('li'); |
143 | } | 147 | } |
144 | - newArea.push($this.children('.caption').text()); | 148 | + newArea.push($this.children('.caption').text().trim()); |
145 | $this.siblings().hide(); | 149 | $this.siblings().hide(); |
146 | $this.children('ul').show().children('li').show(); | 150 | $this.children('ul').show().children('li').show(); |
147 | 151 | ||
@@ -157,7 +161,7 @@ $.get('/home/locationList').then(function(html) { | @@ -157,7 +161,7 @@ $.get('/home/locationList').then(function(html) { | ||
157 | var $this = $(e.target); | 161 | var $this = $(e.target); |
158 | 162 | ||
159 | // 填结果到 html | 163 | // 填结果到 html |
160 | - newArea.push($this.children('.caption').text()); | 164 | + newArea.push($this.text().trim()); |
161 | $('[name="area"]').val(newArea.join(' ')); | 165 | $('[name="area"]').val(newArea.join(' ')); |
162 | $('[name="area_code"]').val($this.data('id')); | 166 | $('[name="area_code"]').val($this.data('id')); |
163 | 167 |
@@ -12,30 +12,35 @@ var $dialogWrapper, | @@ -12,30 +12,35 @@ var $dialogWrapper, | ||
12 | dialogTpl, | 12 | dialogTpl, |
13 | dialogTemplate; | 13 | dialogTemplate; |
14 | 14 | ||
15 | - | ||
16 | -dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + | ||
17 | - '<div class="dialog-box">' + | ||
18 | - '{{# hasHeader}}' + | ||
19 | - '{{/ hasHeader}}' + | ||
20 | - '<div class="dialog-content">{{dialogText}}</div>' + | ||
21 | - '{{# hasFooter}}' + | ||
22 | - '<div class="dialog-footer">' + | ||
23 | - '{{# leftBtnText}}' + | ||
24 | - '<span class="dialog-left-btn">{{.}}</span>' + | ||
25 | - '{{/ leftBtnText}}' + | ||
26 | - '{{# rightBtnText}}' + | ||
27 | - '<span class="dialog-right-btn">{{.}}</span>' + | ||
28 | - '{{/ rightBtnText}}' + | ||
29 | - '</div>' + | ||
30 | - '{{/ hasFooter}}' + | ||
31 | - '</div>' + | 15 | +function getInstance() { |
16 | + if (dialogTpl === undefined) { | ||
17 | + dialogTpl = '<div id="dialog-wrapper" class="dialog-wrapper">' + | ||
18 | + '<div class="dialog-box">' + | ||
19 | + '{{# hasHeader}}' + | ||
20 | + '{{/ hasHeader}}' + | ||
21 | + '<div class="dialog-content">{{dialogText}}</div>' + | ||
22 | + '{{# hasFooter}}' + | ||
23 | + '<div class="dialog-footer">' + | ||
24 | + '{{# leftBtnText}}' + | ||
25 | + '<span class="dialog-left-btn">{{.}}</span>' + | ||
26 | + '{{/ leftBtnText}}' + | ||
27 | + '{{# rightBtnText}}' + | ||
28 | + '<span class="dialog-right-btn">{{.}}</span>' + | ||
29 | + '{{/ rightBtnText}}' + | ||
30 | + '</div>' + | ||
31 | + '{{/ hasFooter}}' + | ||
32 | + '</div>' + | ||
32 | '</div>'; | 33 | '</div>'; |
33 | 34 | ||
34 | -dialogTemplate = Handlebars.compile(dialogTpl); | 35 | + dialogTemplate = Handlebars.compile(dialogTpl); |
36 | + } | ||
37 | + return dialogTemplate; | ||
38 | +} | ||
35 | 39 | ||
36 | exports.showDialog = function(data, callback, callbackForLeft) { | 40 | exports.showDialog = function(data, callback, callbackForLeft) { |
37 | 41 | ||
38 | - var dialogStr = dialogTemplate(data), | 42 | + var dialogTemplate = getInstance(), |
43 | + dialogStr = dialogTemplate(data), | ||
39 | $dialogBox, | 44 | $dialogBox, |
40 | defaultHideDuraton, | 45 | defaultHideDuraton, |
41 | dialogWrapperHammer; | 46 | dialogWrapperHammer; |
@@ -73,6 +78,11 @@ exports.showDialog = function(data, callback, callbackForLeft) { | @@ -73,6 +78,11 @@ exports.showDialog = function(data, callback, callbackForLeft) { | ||
73 | }, defaultHideDuraton); | 78 | }, defaultHideDuraton); |
74 | } | 79 | } |
75 | 80 | ||
81 | + //禁止在dialog上可以上下滚动 | ||
82 | + $dialogWrapper.on('touchmove', function() { | ||
83 | + return false; | ||
84 | + }); | ||
85 | + | ||
76 | dialogWrapperHammer.on('tap', function(event) { | 86 | dialogWrapperHammer.on('tap', function(event) { |
77 | 87 | ||
78 | if ($(event.target).hasClass('dialog-left-btn')) { | 88 | if ($(event.target).hasClass('dialog-left-btn')) { |
@@ -83,5 +93,9 @@ exports.showDialog = function(data, callback, callbackForLeft) { | @@ -83,5 +93,9 @@ exports.showDialog = function(data, callback, callbackForLeft) { | ||
83 | } else if ($(event.target).hasClass('dialog-right-btn')) { | 93 | } else if ($(event.target).hasClass('dialog-right-btn')) { |
84 | callback(); | 94 | callback(); |
85 | } | 95 | } |
96 | + | ||
97 | + // 防止出现点透问题 | ||
98 | + event.preventDefault(); | ||
99 | + event.srcEvent.stopPropagation(); | ||
86 | }); | 100 | }); |
87 | }; | 101 | }; |
@@ -123,10 +123,10 @@ | @@ -123,10 +123,10 @@ | ||
123 | } | 123 | } |
124 | 124 | ||
125 | .count { | 125 | .count { |
126 | - font-size: 28rem / $pxConvertRem; | 126 | + font-size: 20rem / $pxConvertRem; |
127 | color: #999; | 127 | color: #999; |
128 | display: inline-block; | 128 | display: inline-block; |
129 | - width: 19%; | 129 | + width: 22%; |
130 | position: absolute; | 130 | position: absolute; |
131 | text-align: center; | 131 | text-align: center; |
132 | } | 132 | } |
@@ -77,7 +77,7 @@ | @@ -77,7 +77,7 @@ | ||
77 | padding: 10px; | 77 | padding: 10px; |
78 | background: #000; | 78 | background: #000; |
79 | color: #fff; | 79 | color: #fff; |
80 | - font-size: 20px; | 80 | + font-size: 12px; |
81 | @include border-radius(5px); | 81 | @include border-radius(5px); |
82 | text-align: center; | 82 | text-align: center; |
83 | width: 7rem; | 83 | width: 7rem; |
-
Please register or login to post a comment