|
@@ -132,84 +132,238 @@ $('.banner-center-swiper').each(function() { |
|
@@ -132,84 +132,238 @@ $('.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;
|
153
|
|
171
|
|
154
|
-// 热门品牌滑动
|
|
|
155
|
-if ($('.brands-swiper').find('li').length > 1) {
|
|
|
156
|
- new Swiper('.brands-swiper', {
|
|
|
157
|
- grabCursor: true,
|
|
|
158
|
- slidesPerView: 'auto',
|
|
|
159
|
- wrapperClass: 'brands-list',
|
|
|
160
|
- slideElement: 'li'
|
|
|
161
|
- });
|
|
|
162
|
-}
|
172
|
+ if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
173
|
+ $(elem).find('.limit').hide();
|
|
|
174
|
+ }
|
163
|
|
175
|
|
164
|
-// 推荐搭配滑动
|
|
|
165
|
-if ($('.recommend-swiper').find('li').length > 1) {
|
|
|
166
|
- new Swiper('.recommend-swiper', {
|
|
|
167
|
- grabCursor: true,
|
|
|
168
|
- slidesPerView: 'auto',
|
|
|
169
|
- wrapperClass: 'recommend-list',
|
|
|
170
|
- slideElement: 'li'
|
|
|
171
|
- });
|
|
|
172
|
-}
|
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));
|
173
|
|
180
|
|
174
|
-// 潮品话题轮播
|
|
|
175
|
-if ($('.trend-topic-swiper').find('li').size() > 1) {
|
|
|
176
|
- new Swiper('.trend-topic-swiper', {
|
|
|
177
|
- loop: true,
|
|
|
178
|
- autoplay: 3000,
|
|
|
179
|
- autoplayDisableOnInteraction: false,
|
|
|
180
|
- paginationClickable: true,
|
|
|
181
|
- slideElement: 'li',
|
|
|
182
|
- pagination: '.trend-topic-content .pagination-inner'
|
|
|
183
|
- });
|
|
|
184
|
-}
|
181
|
+ if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
182
|
+ $(elem).find('.limit').hide();
|
|
|
183
|
+ } else {
|
|
|
184
|
+ setTimeout(function() {
|
|
|
185
|
+ saleTime(elem, --offsetTime);
|
|
|
186
|
+ }, 1000);
|
|
|
187
|
+ }
|
|
|
188
|
+ }
|
|
|
189
|
+};
|
185
|
|
190
|
|
186
|
-// 新人专享轮播
|
|
|
187
|
-if ($('.fresh-list-swiper').find('li').size() > 1) {
|
|
|
188
|
- new Swiper('.fresh-list-swiper', {
|
|
|
189
|
- lazyLoading: true,
|
|
|
190
|
- lazyLoadingInPrevNext: true,
|
|
|
191
|
- grabCursor: true,
|
|
|
192
|
- slidesPerView: 'auto',
|
|
|
193
|
- slideElement: 'li',
|
|
|
194
|
- watchSlidesVisibility: true
|
|
|
195
|
- });
|
|
|
196
|
-}
|
191
|
+function ajaxResource() {
|
|
|
192
|
+ // 热门品牌滑动
|
|
|
193
|
+ if ($('.brands-swiper').find('li').length > 1) {
|
|
|
194
|
+ new Swiper('.brands-swiper', {
|
|
|
195
|
+ grabCursor: true,
|
|
|
196
|
+ slidesPerView: 'auto',
|
|
|
197
|
+ wrapperClass: 'brands-list',
|
|
|
198
|
+ slideElement: 'li'
|
|
|
199
|
+ });
|
|
|
200
|
+ }
|
|
|
201
|
+
|
|
|
202
|
+ // 推荐搭配滑动
|
|
|
203
|
+ if ($('.recommend-swiper').find('li').length > 1) {
|
|
|
204
|
+ new Swiper('.recommend-swiper', {
|
|
|
205
|
+ grabCursor: true,
|
|
|
206
|
+ slidesPerView: 'auto',
|
|
|
207
|
+ wrapperClass: 'recommend-list',
|
|
|
208
|
+ slideElement: 'li'
|
|
|
209
|
+ });
|
|
|
210
|
+ }
|
197
|
|
211
|
|
198
|
-// 潮流上装/经典裤装等轮播
|
|
|
199
|
-$('.category-swiper').each(function(i) {
|
|
|
200
|
- swiperClass = 'category-swiper' + i;
|
|
|
201
|
- $(this).addClass(swiperClass);
|
|
|
202
|
- if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
|
|
203
|
- new Swiper('.' + swiperClass, {
|
212
|
+ // 潮品话题轮播
|
|
|
213
|
+ if ($('.trend-topic-swiper').find('li').size() > 1) {
|
|
|
214
|
+ new Swiper('.trend-topic-swiper', {
|
204
|
loop: true,
|
215
|
loop: true,
|
205
|
autoplay: 3000,
|
216
|
autoplay: 3000,
|
206
|
autoplayDisableOnInteraction: false,
|
217
|
autoplayDisableOnInteraction: false,
|
207
|
paginationClickable: true,
|
218
|
paginationClickable: true,
|
208
|
slideElement: 'li',
|
219
|
slideElement: 'li',
|
209
|
- pagination: '.' + swiperClass + ' .pagination-inner'
|
220
|
+ pagination: '.trend-topic-content .pagination-inner'
|
|
|
221
|
+ });
|
|
|
222
|
+ }
|
|
|
223
|
+
|
|
|
224
|
+ // 新人专享轮播
|
|
|
225
|
+ if ($('.fresh-list-swiper').find('li').size() > 1) {
|
|
|
226
|
+ new Swiper('.fresh-list-swiper', {
|
|
|
227
|
+ lazyLoading: true,
|
|
|
228
|
+ lazyLoadingInPrevNext: true,
|
|
|
229
|
+ grabCursor: true,
|
|
|
230
|
+ slidesPerView: 'auto',
|
|
|
231
|
+ slideElement: 'li',
|
|
|
232
|
+ watchSlidesVisibility: true
|
210
|
});
|
233
|
});
|
211
|
}
|
234
|
}
|
212
|
-});
|
235
|
+
|
|
|
236
|
+ // 潮流上装/经典裤装等轮播
|
|
|
237
|
+ $('.category-swiper').each(function(i) {
|
|
|
238
|
+ swiperClass = 'category-swiper' + i;
|
|
|
239
|
+ $(this).addClass(swiperClass);
|
|
|
240
|
+ if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
|
|
241
|
+ new Swiper('.' + swiperClass, {
|
|
|
242
|
+ loop: true,
|
|
|
243
|
+ autoplay: 3000,
|
|
|
244
|
+ autoplayDisableOnInteraction: false,
|
|
|
245
|
+ paginationClickable: true,
|
|
|
246
|
+ slideElement: 'li',
|
|
|
247
|
+ pagination: '.' + swiperClass + ' .pagination-inner'
|
|
|
248
|
+ });
|
|
|
249
|
+ }
|
|
|
250
|
+ });
|
|
|
251
|
+
|
|
|
252
|
+ // 店铺推荐滑动效果
|
|
|
253
|
+ if ($('.shop-recom-swiper-container').find('li').length > 1) {
|
|
|
254
|
+ new Swiper('.shop-recom-swiper-container', {
|
|
|
255
|
+ centeredSlides: true,
|
|
|
256
|
+ slidesPerView: 'auto',
|
|
|
257
|
+ paginationClickable: true,
|
|
|
258
|
+ slideActiveClass: 'recom-active',
|
|
|
259
|
+ });
|
|
|
260
|
+ }
|
|
|
261
|
+
|
|
|
262
|
+ // 店铺收藏 || 取消收藏
|
|
|
263
|
+ var $collect = $('.fav-container');
|
|
|
264
|
+
|
|
|
265
|
+ $collect.on('touchstart', function() {
|
|
|
266
|
+ var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok';
|
|
|
267
|
+ var self = $(this);
|
|
|
268
|
+ var num = parseInt(self.parent().find('.faved-num').html());
|
|
|
269
|
+
|
|
|
270
|
+ $.ajax({
|
|
|
271
|
+ method: 'get',
|
|
|
272
|
+ url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
|
|
|
273
|
+ data: {
|
|
|
274
|
+ id: self.parent().attr('shopId'),
|
|
|
275
|
+ opt: opt,
|
|
|
276
|
+ type: 'shop',
|
|
|
277
|
+ },
|
|
|
278
|
+ xhrFields: {
|
|
|
279
|
+ withCredentials: true
|
|
|
280
|
+ },
|
|
|
281
|
+ success: function(data) {
|
|
|
282
|
+ var url = '';
|
|
|
283
|
+
|
|
|
284
|
+ if (data.code === 200) {
|
|
|
285
|
+ if (self.hasClass('fav-yes')) {
|
|
|
286
|
+ self.hide();
|
|
|
287
|
+ self.prev().show();
|
|
|
288
|
+ num--;
|
|
|
289
|
+ self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
290
|
+ tip.show('取消收藏成功!');
|
|
|
291
|
+ } else {
|
|
|
292
|
+ self.hide();
|
|
|
293
|
+ self.next().show();
|
|
|
294
|
+ num++;
|
|
|
295
|
+ self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
296
|
+ tip.show('收藏成功!');
|
|
|
297
|
+ }
|
|
|
298
|
+ }
|
|
|
299
|
+
|
|
|
300
|
+ if (data.code === 400) {
|
|
|
301
|
+ url = data.data;
|
|
|
302
|
+ location.href = url;
|
|
|
303
|
+ }
|
|
|
304
|
+
|
|
|
305
|
+ },
|
|
|
306
|
+ error: function() {
|
|
|
307
|
+ tip.show('网络断开连接了~');
|
|
|
308
|
+ }
|
|
|
309
|
+ });
|
|
|
310
|
+ });
|
|
|
311
|
+
|
|
|
312
|
+ // vip专属等级查询
|
|
|
313
|
+ $.ajax({
|
|
|
314
|
+ method: 'POST',
|
|
|
315
|
+ url: location.protocol + '//m.yohobuy.com/channel/userVip',
|
|
|
316
|
+ data: {
|
|
|
317
|
+ channel: 1,
|
|
|
318
|
+ },
|
|
|
319
|
+ success: function(data) {
|
|
|
320
|
+ var vip = $('.vip-only');
|
|
|
321
|
+
|
|
|
322
|
+ if (data.code === 200 && Number(data.current_vip_level) !== 0) {
|
|
|
323
|
+ vip.show();
|
|
|
324
|
+ vip.find('.vip' + data.current_vip_level).show();
|
|
|
325
|
+ }
|
|
|
326
|
+ },
|
|
|
327
|
+ error: function() {
|
|
|
328
|
+ tip.show('网络断开连接了~');
|
|
|
329
|
+ }
|
|
|
330
|
+ });
|
|
|
331
|
+
|
|
|
332
|
+ checkShop();
|
|
|
333
|
+
|
|
|
334
|
+ var limitFloor = $('.sale-floor-time');
|
|
|
335
|
+
|
|
|
336
|
+ limitFloor.each(function() {
|
|
|
337
|
+ var endTime = $(this).attr('data-time'),
|
|
|
338
|
+
|
|
|
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);
|
213
|
|
367
|
|
214
|
// logo动画
|
368
|
// logo动画
|
215
|
function tsAnimate() {
|
369
|
function tsAnimate() {
|
|
@@ -262,155 +416,6 @@ window.setCookie('_Channel', $mobileWrap.data('channel'), { |
|
@@ -262,155 +416,6 @@ window.setCookie('_Channel', $mobileWrap.data('channel'), { |
262
|
domain: '.yohobuy.com'
|
416
|
domain: '.yohobuy.com'
|
263
|
});
|
417
|
});
|
264
|
|
418
|
|
265
|
-// 店铺推荐滑动效果
|
|
|
266
|
-if ($('.shop-recom-swiper-container').find('li').length > 1) {
|
|
|
267
|
- new Swiper('.shop-recom-swiper-container', {
|
|
|
268
|
- centeredSlides: true,
|
|
|
269
|
- slidesPerView: 'auto',
|
|
|
270
|
- paginationClickable: true,
|
|
|
271
|
- slideActiveClass: 'recom-active',
|
|
|
272
|
- });
|
|
|
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
|
- }
|
|
|
301
|
- }
|
|
|
302
|
- });
|
|
|
303
|
-};
|
|
|
304
|
-
|
|
|
305
|
-checkShop();
|
|
|
306
|
-
|
|
|
307
|
-// 店铺收藏 || 取消收藏
|
|
|
308
|
-var $collect = $('.fav-container');
|
|
|
309
|
-
|
|
|
310
|
-$collect.on('touchstart', function() {
|
|
|
311
|
- var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok';
|
|
|
312
|
- var self = $(this);
|
|
|
313
|
- var num = parseInt(self.parent().find('.faved-num').html());
|
|
|
314
|
-
|
|
|
315
|
- $.ajax({
|
|
|
316
|
- method: 'get',
|
|
|
317
|
- url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
|
|
|
318
|
- data: {
|
|
|
319
|
- id: self.parent().attr('shopId'),
|
|
|
320
|
- opt: opt,
|
|
|
321
|
- type: 'shop',
|
|
|
322
|
- },
|
|
|
323
|
- xhrFields: {
|
|
|
324
|
- withCredentials: true
|
|
|
325
|
- },
|
|
|
326
|
- success: function(data) {
|
|
|
327
|
- var url = '';
|
|
|
328
|
-
|
|
|
329
|
- if (data.code === 200) {
|
|
|
330
|
- if (self.hasClass('fav-yes')) {
|
|
|
331
|
- self.hide();
|
|
|
332
|
- self.prev().show();
|
|
|
333
|
- num--;
|
|
|
334
|
- self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
335
|
- tip.show('取消收藏成功!');
|
|
|
336
|
- } else {
|
|
|
337
|
- self.hide();
|
|
|
338
|
- self.next().show();
|
|
|
339
|
- num++;
|
|
|
340
|
- self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
341
|
- tip.show('收藏成功!');
|
|
|
342
|
- }
|
|
|
343
|
- }
|
|
|
344
|
-
|
|
|
345
|
- if (data.code === 400) {
|
|
|
346
|
- url = data.data;
|
|
|
347
|
- location.href = url;
|
|
|
348
|
- }
|
|
|
349
|
-
|
|
|
350
|
- },
|
|
|
351
|
- error: function() {
|
|
|
352
|
- tip.show('网络断开连接了~');
|
|
|
353
|
- }
|
|
|
354
|
- });
|
|
|
355
|
-});
|
|
|
356
|
-
|
|
|
357
|
-// vip专属等级查询
|
|
|
358
|
-$.ajax({
|
|
|
359
|
- method: 'POST',
|
|
|
360
|
- url: location.protocol + '//m.yohobuy.com/channel/userVip',
|
|
|
361
|
- data: {
|
|
|
362
|
- channel: 1,
|
|
|
363
|
- },
|
|
|
364
|
- success: function(data) {
|
|
|
365
|
- var vip = $('.vip-only');
|
|
|
366
|
-
|
|
|
367
|
- if (data.code === 200 && Number(data.current_vip_level) !== 0) {
|
|
|
368
|
- vip.show();
|
|
|
369
|
- vip.find('.vip' + data.current_vip_level).show();
|
|
|
370
|
- }
|
|
|
371
|
- },
|
|
|
372
|
- error: function() {
|
|
|
373
|
- tip.show('网络断开连接了~');
|
|
|
374
|
- }
|
|
|
375
|
-});
|
|
|
376
|
-
|
|
|
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;
|
|
|
382
|
-
|
|
|
383
|
- if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
384
|
- $(elem).find('.limit').hide();
|
|
|
385
|
- }
|
|
|
386
|
-
|
|
|
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));
|
|
|
391
|
-
|
|
|
392
|
- if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
393
|
- $(elem).find('.limit').hide();
|
|
|
394
|
- } else {
|
|
|
395
|
- setTimeout(function() {
|
|
|
396
|
- saleTime(elem, --offsetTime);
|
|
|
397
|
- }, 1000);
|
|
|
398
|
- }
|
|
|
399
|
- }
|
|
|
400
|
-
|
|
|
401
|
-};
|
|
|
402
|
-
|
|
|
403
|
-var limitFloor = $('.sale-floor-time');
|
|
|
404
|
-
|
|
|
405
|
-limitFloor.each(function() {
|
|
|
406
|
- var endTime = $(this).attr('data-time'),
|
|
|
407
|
-
|
|
|
408
|
- // ~~两次取反位运算就是取整
|
|
|
409
|
- limit = ~~((endTime * 1000 - Date.now()) / 1000);
|
|
|
410
|
-
|
|
|
411
|
- saleTime(this, limit);
|
|
|
412
|
-});
|
|
|
413
|
-
|
|
|
414
|
require('./maybe-like')();
|
419
|
require('./maybe-like')();
|
415
|
|
420
|
|
416
|
C_ID = window._ChannelVary[window.cookie('_Channel')];
|
421
|
C_ID = window._ChannelVary[window.cookie('_Channel')];
|