|
@@ -132,47 +132,85 @@ $('.banner-center-swiper').each(function() { |
|
@@ -132,47 +132,85 @@ $('.banner-center-swiper').each(function() { |
132
|
}
|
132
|
}
|
133
|
});
|
133
|
});
|
134
|
|
134
|
|
135
|
-// 异步获取首屏其余楼层
|
|
|
136
|
-var getResourceContent = function() {
|
135
|
+
|
|
|
136
|
+// 店铺推荐人数和收藏初始查询
|
|
|
137
|
+var checkShop = function() {
|
|
|
138
|
+ var shopIds = [];
|
|
|
139
|
+
|
|
|
140
|
+ $('.recom-shop').each(function() {
|
|
|
141
|
+ shopIds.push($(this).attr('shopId'));
|
|
|
142
|
+ });
|
|
|
143
|
+ shopIds.length &&
|
137
|
$.ajax({
|
144
|
$.ajax({
|
138
|
- type: 'GET',
|
|
|
139
|
- url: '/channel/getResourceContent',
|
|
|
140
|
- async: false, // 改为false,否则下面初始化会找不到元素对象
|
145
|
+ type: 'POST',
|
|
|
146
|
+ url: '/channel/shopRecom',
|
141
|
data: {
|
147
|
data: {
|
142
|
- gender: $mobileWrap.data('channel')
|
148
|
+ shopIds: shopIds.join(','),
|
143
|
},
|
149
|
},
|
144
|
}).then(function(result) {
|
150
|
}).then(function(result) {
|
145
|
- var resourceTemplate = channelContentHbs({content: result});
|
151
|
+ if (result.code === 200) {
|
|
|
152
|
+ for (var i = 0, elem;
|
|
|
153
|
+ (elem = result.data[i]) != null; i++) {
|
|
|
154
|
+ var a = $('.recom-shop[shopId = ' + elem.id + ']');
|
146
|
|
155
|
|
147
|
- $resourceContent.append(resourceTemplate);
|
|
|
148
|
- lazyLoad($resourceContent.find('img.lazy:not([src])'));
|
156
|
+ a.find('.faved-num').text(elem.collectionNum + '人已收藏');
|
|
|
157
|
+ if (elem.favorite) {
|
|
|
158
|
+ a.find('.fav-no').hide();
|
|
|
159
|
+ a.find('.fav-yes').show();
|
|
|
160
|
+ }
|
|
|
161
|
+ }
|
|
|
162
|
+ }
|
149
|
});
|
163
|
});
|
150
|
};
|
164
|
};
|
151
|
|
165
|
|
152
|
-getResourceContent();
|
166
|
+// sale倒计时
|
|
|
167
|
+var saleTime = function(elem, offsetTime) {
|
|
|
168
|
+ var hour = parseInt(offsetTime / (60 * 60), 10),
|
|
|
169
|
+ minute = parseInt(offsetTime % (60 * 60) / 60, 10),
|
|
|
170
|
+ second = offsetTime % 60;
|
|
|
171
|
+
|
|
|
172
|
+ if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
173
|
+ $(elem).find('.limit').hide();
|
|
|
174
|
+ }
|
|
|
175
|
+
|
|
|
176
|
+ if (offsetTime >= -1) {
|
|
|
177
|
+ $(elem).find('.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
|
|
|
178
|
+ $(elem).find('.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
|
|
|
179
|
+ $(elem).find('.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second));
|
|
|
180
|
+
|
|
|
181
|
+ if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
182
|
+ $(elem).find('.limit').hide();
|
|
|
183
|
+ } else {
|
|
|
184
|
+ setTimeout(function() {
|
|
|
185
|
+ saleTime(elem, --offsetTime);
|
|
|
186
|
+ }, 1000);
|
|
|
187
|
+ }
|
|
|
188
|
+ }
|
|
|
189
|
+};
|
153
|
|
190
|
|
154
|
-// 热门品牌滑动
|
|
|
155
|
-if ($('.brands-swiper').find('li').length > 1) {
|
191
|
+function ajaxResource() {
|
|
|
192
|
+ // 热门品牌滑动
|
|
|
193
|
+ if ($('.brands-swiper').find('li').length > 1) {
|
156
|
new Swiper('.brands-swiper', {
|
194
|
new Swiper('.brands-swiper', {
|
157
|
grabCursor: true,
|
195
|
grabCursor: true,
|
158
|
slidesPerView: 'auto',
|
196
|
slidesPerView: 'auto',
|
159
|
wrapperClass: 'brands-list',
|
197
|
wrapperClass: 'brands-list',
|
160
|
slideElement: 'li'
|
198
|
slideElement: 'li'
|
161
|
});
|
199
|
});
|
162
|
-}
|
200
|
+ }
|
163
|
|
201
|
|
164
|
-// 推荐搭配滑动
|
|
|
165
|
-if ($('.recommend-swiper').find('li').length > 1) {
|
202
|
+ // 推荐搭配滑动
|
|
|
203
|
+ if ($('.recommend-swiper').find('li').length > 1) {
|
166
|
new Swiper('.recommend-swiper', {
|
204
|
new Swiper('.recommend-swiper', {
|
167
|
grabCursor: true,
|
205
|
grabCursor: true,
|
168
|
slidesPerView: 'auto',
|
206
|
slidesPerView: 'auto',
|
169
|
wrapperClass: 'recommend-list',
|
207
|
wrapperClass: 'recommend-list',
|
170
|
slideElement: 'li'
|
208
|
slideElement: 'li'
|
171
|
});
|
209
|
});
|
172
|
-}
|
210
|
+ }
|
173
|
|
211
|
|
174
|
-// 潮品话题轮播
|
|
|
175
|
-if ($('.trend-topic-swiper').find('li').size() > 1) {
|
212
|
+ // 潮品话题轮播
|
|
|
213
|
+ if ($('.trend-topic-swiper').find('li').size() > 1) {
|
176
|
new Swiper('.trend-topic-swiper', {
|
214
|
new Swiper('.trend-topic-swiper', {
|
177
|
loop: true,
|
215
|
loop: true,
|
178
|
autoplay: 3000,
|
216
|
autoplay: 3000,
|
|
@@ -181,10 +219,10 @@ if ($('.trend-topic-swiper').find('li').size() > 1) { |
|
@@ -181,10 +219,10 @@ if ($('.trend-topic-swiper').find('li').size() > 1) { |
181
|
slideElement: 'li',
|
219
|
slideElement: 'li',
|
182
|
pagination: '.trend-topic-content .pagination-inner'
|
220
|
pagination: '.trend-topic-content .pagination-inner'
|
183
|
});
|
221
|
});
|
184
|
-}
|
222
|
+ }
|
185
|
|
223
|
|
186
|
-// 新人专享轮播
|
|
|
187
|
-if ($('.fresh-list-swiper').find('li').size() > 1) {
|
224
|
+ // 新人专享轮播
|
|
|
225
|
+ if ($('.fresh-list-swiper').find('li').size() > 1) {
|
188
|
new Swiper('.fresh-list-swiper', {
|
226
|
new Swiper('.fresh-list-swiper', {
|
189
|
lazyLoading: true,
|
227
|
lazyLoading: true,
|
190
|
lazyLoadingInPrevNext: true,
|
228
|
lazyLoadingInPrevNext: true,
|
|
@@ -193,10 +231,10 @@ if ($('.fresh-list-swiper').find('li').size() > 1) { |
|
@@ -193,10 +231,10 @@ if ($('.fresh-list-swiper').find('li').size() > 1) { |
193
|
slideElement: 'li',
|
231
|
slideElement: 'li',
|
194
|
watchSlidesVisibility: true
|
232
|
watchSlidesVisibility: true
|
195
|
});
|
233
|
});
|
196
|
-}
|
234
|
+ }
|
197
|
|
235
|
|
198
|
-// 潮流上装/经典裤装等轮播
|
|
|
199
|
-$('.category-swiper').each(function(i) {
|
236
|
+ // 潮流上装/经典裤装等轮播
|
|
|
237
|
+ $('.category-swiper').each(function(i) {
|
200
|
swiperClass = 'category-swiper' + i;
|
238
|
swiperClass = 'category-swiper' + i;
|
201
|
$(this).addClass(swiperClass);
|
239
|
$(this).addClass(swiperClass);
|
202
|
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
240
|
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
|
@@ -209,112 +247,29 @@ $('.category-swiper').each(function(i) { |
|
@@ -209,112 +247,29 @@ $('.category-swiper').each(function(i) { |
209
|
pagination: '.' + swiperClass + ' .pagination-inner'
|
247
|
pagination: '.' + swiperClass + ' .pagination-inner'
|
210
|
});
|
248
|
});
|
211
|
}
|
249
|
}
|
212
|
-});
|
|
|
213
|
-
|
|
|
214
|
-// logo动画
|
|
|
215
|
-function tsAnimate() {
|
|
|
216
|
- start = start + 10;
|
|
|
217
|
- $logotrans.css({
|
|
|
218
|
- transform: 'rotateX(' + start + 'deg)',
|
|
|
219
|
- '-webkit-transform': 'rotateX(' + start + 'deg)',
|
|
|
220
|
- '-moz-transform': 'rotateX(' + start + 'deg)'
|
|
|
221
|
});
|
250
|
});
|
222
|
- if (start / 90 % 2 === 1) {
|
|
|
223
|
- if (isen) {
|
|
|
224
|
- $logotrans.addClass('animate');
|
|
|
225
|
- isen = false;
|
|
|
226
|
- } else {
|
|
|
227
|
- $logotrans.removeClass('animate');
|
|
|
228
|
- isen = true;
|
|
|
229
|
- }
|
|
|
230
|
- }
|
|
|
231
|
- if (start / 90 % 2 === 0 && start % 360 !== 0) {
|
|
|
232
|
- window.setTimeout(tsAnimate, 3000);
|
|
|
233
|
- } else {
|
|
|
234
|
- if (start % 360 === 0) {
|
|
|
235
|
- window.setTimeout(tsAnimate, 60 * 1000);
|
|
|
236
|
- } else {
|
|
|
237
|
- window.requestAnimationFrame(tsAnimate);
|
|
|
238
|
- }
|
|
|
239
|
- }
|
|
|
240
|
-}
|
|
|
241
|
-
|
|
|
242
|
-setTimeout(tsAnimate, 3000);
|
|
|
243
|
-
|
|
|
244
|
-$('.home-header .iconfont').on('touchstart', function() {
|
|
|
245
|
- $(this).addClass('highlight');
|
|
|
246
|
-}).on('touchend touchcancel', function() {
|
|
|
247
|
- $(this).removeClass('highlight');
|
|
|
248
|
-});
|
|
|
249
|
-
|
|
|
250
|
-// 底部留出tab 的高度
|
|
|
251
|
-window.reMarginFooter('.footer-tab');
|
|
|
252
|
-
|
|
|
253
|
-// 原有项目 _Channel 写错位置,这里清理掉
|
|
|
254
|
-window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
255
|
- expires: -1,
|
|
|
256
|
- domain: '.m.yohobuy.com'
|
|
|
257
|
-});
|
|
|
258
|
|
251
|
|
259
|
-// 记录当前 _Channel
|
|
|
260
|
-window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
261
|
- expires: 30,
|
|
|
262
|
- domain: '.yohobuy.com'
|
|
|
263
|
-});
|
|
|
264
|
-
|
|
|
265
|
-// 店铺推荐滑动效果
|
|
|
266
|
-if ($('.shop-recom-swiper-container').find('li').length > 1) {
|
252
|
+ // 店铺推荐滑动效果
|
|
|
253
|
+ if ($('.shop-recom-swiper-container').find('li').length > 1) {
|
267
|
new Swiper('.shop-recom-swiper-container', {
|
254
|
new Swiper('.shop-recom-swiper-container', {
|
268
|
centeredSlides: true,
|
255
|
centeredSlides: true,
|
269
|
slidesPerView: 'auto',
|
256
|
slidesPerView: 'auto',
|
270
|
paginationClickable: true,
|
257
|
paginationClickable: true,
|
271
|
slideActiveClass: 'recom-active',
|
258
|
slideActiveClass: 'recom-active',
|
272
|
});
|
259
|
});
|
273
|
-}
|
|
|
274
|
-
|
|
|
275
|
-// 店铺推荐人数和收藏初始查询
|
|
|
276
|
-var checkShop = function() {
|
|
|
277
|
- var shopIds = [];
|
|
|
278
|
-
|
|
|
279
|
- $('.recom-shop').each(function() {
|
|
|
280
|
- shopIds.push($(this).attr('shopId'));
|
|
|
281
|
- });
|
|
|
282
|
- shopIds.length &&
|
|
|
283
|
- $.ajax({
|
|
|
284
|
- type: 'POST',
|
|
|
285
|
- url: '/channel/shopRecom',
|
|
|
286
|
- data: {
|
|
|
287
|
- shopIds: shopIds.join(','),
|
|
|
288
|
- },
|
|
|
289
|
- }).then(function(result) {
|
|
|
290
|
- if (result.code === 200) {
|
|
|
291
|
- for (var i = 0, elem;
|
|
|
292
|
- (elem = result.data[i]) != null; i++) {
|
|
|
293
|
- var a = $('.recom-shop[shopId = ' + elem.id + ']');
|
|
|
294
|
-
|
|
|
295
|
- a.find('.faved-num').text(elem.collectionNum + '人已收藏');
|
|
|
296
|
- if (elem.favorite) {
|
|
|
297
|
- a.find('.fav-no').hide();
|
|
|
298
|
- a.find('.fav-yes').show();
|
|
|
299
|
- }
|
|
|
300
|
}
|
260
|
}
|
301
|
- }
|
|
|
302
|
- });
|
|
|
303
|
-};
|
|
|
304
|
-
|
|
|
305
|
-checkShop();
|
|
|
306
|
|
261
|
|
307
|
-// 店铺收藏 || 取消收藏
|
|
|
308
|
-var $collect = $('.fav-container');
|
262
|
+ // 店铺收藏 || 取消收藏
|
|
|
263
|
+ var $collect = $('.fav-container');
|
309
|
|
264
|
|
310
|
-$collect.on('touchstart', function() {
|
265
|
+ $collect.on('touchstart', function() {
|
311
|
var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok';
|
266
|
var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok';
|
312
|
var self = $(this);
|
267
|
var self = $(this);
|
313
|
var num = parseInt(self.parent().find('.faved-num').html());
|
268
|
var num = parseInt(self.parent().find('.faved-num').html());
|
314
|
|
269
|
|
315
|
$.ajax({
|
270
|
$.ajax({
|
316
|
method: 'get',
|
271
|
method: 'get',
|
317
|
- url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
|
272
|
+ url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
|
318
|
data: {
|
273
|
data: {
|
319
|
id: self.parent().attr('shopId'),
|
274
|
id: self.parent().attr('shopId'),
|
320
|
opt: opt,
|
275
|
opt: opt,
|
|
@@ -352,10 +307,10 @@ $collect.on('touchstart', function() { |
|
@@ -352,10 +307,10 @@ $collect.on('touchstart', function() { |
352
|
tip.show('网络断开连接了~');
|
307
|
tip.show('网络断开连接了~');
|
353
|
}
|
308
|
}
|
354
|
});
|
309
|
});
|
355
|
-});
|
310
|
+ });
|
356
|
|
311
|
|
357
|
-// vip专属等级查询
|
|
|
358
|
-$.ajax({
|
312
|
+ // vip专属等级查询
|
|
|
313
|
+ $.ajax({
|
359
|
method: 'POST',
|
314
|
method: 'POST',
|
360
|
url: location.protocol + '//m.yohobuy.com/channel/userVip',
|
315
|
url: location.protocol + '//m.yohobuy.com/channel/userVip',
|
361
|
data: {
|
316
|
data: {
|
|
@@ -372,43 +327,93 @@ $.ajax({ |
|
@@ -372,43 +327,93 @@ $.ajax({ |
372
|
error: function() {
|
327
|
error: function() {
|
373
|
tip.show('网络断开连接了~');
|
328
|
tip.show('网络断开连接了~');
|
374
|
}
|
329
|
}
|
375
|
-});
|
330
|
+ });
|
376
|
|
331
|
|
377
|
-// sale倒计时
|
|
|
378
|
-var saleTime = function(elem, offsetTime) {
|
|
|
379
|
- var hour = parseInt(offsetTime / (60 * 60), 10),
|
|
|
380
|
- minute = parseInt(offsetTime % (60 * 60) / 60, 10),
|
|
|
381
|
- second = offsetTime % 60;
|
332
|
+ checkShop();
|
382
|
|
333
|
|
383
|
- if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
384
|
- $(elem).find('.limit').hide();
|
|
|
385
|
- }
|
334
|
+ var limitFloor = $('.sale-floor-time');
|
386
|
|
335
|
|
387
|
- if (offsetTime >= -1) {
|
|
|
388
|
- $(elem).find('.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
|
|
|
389
|
- $(elem).find('.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
|
|
|
390
|
- $(elem).find('.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second));
|
336
|
+ limitFloor.each(function() {
|
|
|
337
|
+ var endTime = $(this).attr('data-time'),
|
391
|
|
338
|
|
392
|
- if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
393
|
- $(elem).find('.limit').hide();
|
339
|
+ // ~~两次取反位运算就是取整
|
|
|
340
|
+ limit = ~~((endTime * 1000 - Date.now()) / 1000);
|
|
|
341
|
+
|
|
|
342
|
+ saleTime(this, limit);
|
|
|
343
|
+ });
|
|
|
344
|
+}
|
|
|
345
|
+
|
|
|
346
|
+// 异步获取首屏其余楼层
|
|
|
347
|
+var getResourceContent = function() {
|
|
|
348
|
+ $.ajax({
|
|
|
349
|
+ type: 'GET',
|
|
|
350
|
+ url: '/channel/getResourceContent',
|
|
|
351
|
+ data: {
|
|
|
352
|
+ gender: $mobileWrap.data('channel')
|
|
|
353
|
+ },
|
|
|
354
|
+ }).then(function(result) {
|
|
|
355
|
+ var resourceTemplate = channelContentHbs({content: result});
|
|
|
356
|
+
|
|
|
357
|
+ $resourceContent.append(resourceTemplate);
|
|
|
358
|
+ lazyLoad($resourceContent.find('img.lazy:not([src])'));
|
|
|
359
|
+
|
|
|
360
|
+ ajaxResource();
|
|
|
361
|
+ });
|
|
|
362
|
+};
|
|
|
363
|
+
|
|
|
364
|
+setTimeout(function() {
|
|
|
365
|
+ getResourceContent();
|
|
|
366
|
+}, 50);
|
|
|
367
|
+
|
|
|
368
|
+// logo动画
|
|
|
369
|
+function tsAnimate() {
|
|
|
370
|
+ start = start + 10;
|
|
|
371
|
+ $logotrans.css({
|
|
|
372
|
+ transform: 'rotateX(' + start + 'deg)',
|
|
|
373
|
+ '-webkit-transform': 'rotateX(' + start + 'deg)',
|
|
|
374
|
+ '-moz-transform': 'rotateX(' + start + 'deg)'
|
|
|
375
|
+ });
|
|
|
376
|
+ if (start / 90 % 2 === 1) {
|
|
|
377
|
+ if (isen) {
|
|
|
378
|
+ $logotrans.addClass('animate');
|
|
|
379
|
+ isen = false;
|
394
|
} else {
|
380
|
} else {
|
395
|
- setTimeout(function() {
|
|
|
396
|
- saleTime(elem, --offsetTime);
|
|
|
397
|
- }, 1000);
|
381
|
+ $logotrans.removeClass('animate');
|
|
|
382
|
+ isen = true;
|
398
|
}
|
383
|
}
|
399
|
}
|
384
|
}
|
|
|
385
|
+ if (start / 90 % 2 === 0 && start % 360 !== 0) {
|
|
|
386
|
+ window.setTimeout(tsAnimate, 3000);
|
|
|
387
|
+ } else {
|
|
|
388
|
+ if (start % 360 === 0) {
|
|
|
389
|
+ window.setTimeout(tsAnimate, 60 * 1000);
|
|
|
390
|
+ } else {
|
|
|
391
|
+ window.requestAnimationFrame(tsAnimate);
|
|
|
392
|
+ }
|
|
|
393
|
+ }
|
|
|
394
|
+}
|
400
|
|
395
|
|
401
|
-};
|
396
|
+setTimeout(tsAnimate, 3000);
|
402
|
|
397
|
|
403
|
-var limitFloor = $('.sale-floor-time');
|
398
|
+$('.home-header .iconfont').on('touchstart', function() {
|
|
|
399
|
+ $(this).addClass('highlight');
|
|
|
400
|
+}).on('touchend touchcancel', function() {
|
|
|
401
|
+ $(this).removeClass('highlight');
|
|
|
402
|
+});
|
404
|
|
403
|
|
405
|
-limitFloor.each(function() {
|
|
|
406
|
- var endTime = $(this).attr('data-time'),
|
404
|
+// 底部留出tab 的高度
|
|
|
405
|
+window.reMarginFooter('.footer-tab');
|
407
|
|
406
|
|
408
|
- // ~~两次取反位运算就是取整
|
|
|
409
|
- limit = ~~((endTime * 1000 - Date.now()) / 1000);
|
407
|
+// 原有项目 _Channel 写错位置,这里清理掉
|
|
|
408
|
+window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
409
|
+ expires: -1,
|
|
|
410
|
+ domain: '.m.yohobuy.com'
|
|
|
411
|
+});
|
410
|
|
412
|
|
411
|
- saleTime(this, limit);
|
413
|
+// 记录当前 _Channel
|
|
|
414
|
+window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
415
|
+ expires: 30,
|
|
|
416
|
+ domain: '.yohobuy.com'
|
412
|
});
|
417
|
});
|
413
|
|
418
|
|
414
|
require('./maybe-like')();
|
419
|
require('./maybe-like')();
|