...
|
...
|
@@ -132,84 +132,238 @@ $('.banner-center-swiper').each(function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
// 异步获取首屏其余楼层
|
|
|
var getResourceContent = function() {
|
|
|
|
|
|
// 店铺推荐人数和收藏初始查询
|
|
|
var checkShop = function() {
|
|
|
var shopIds = [];
|
|
|
|
|
|
$('.recom-shop').each(function() {
|
|
|
shopIds.push($(this).attr('shopId'));
|
|
|
});
|
|
|
shopIds.length &&
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/channel/getResourceContent',
|
|
|
async: false, // 改为false,否则下面初始化会找不到元素对象
|
|
|
type: 'POST',
|
|
|
url: '/channel/shopRecom',
|
|
|
data: {
|
|
|
gender: $mobileWrap.data('channel')
|
|
|
shopIds: shopIds.join(','),
|
|
|
},
|
|
|
}).then(function(result) {
|
|
|
var resourceTemplate = channelContentHbs({content: result});
|
|
|
if (result.code === 200) {
|
|
|
for (var i = 0, elem;
|
|
|
(elem = result.data[i]) != null; i++) {
|
|
|
var a = $('.recom-shop[shopId = ' + elem.id + ']');
|
|
|
|
|
|
$resourceContent.append(resourceTemplate);
|
|
|
lazyLoad($resourceContent.find('img.lazy:not([src])'));
|
|
|
a.find('.faved-num').text(elem.collectionNum + '人已收藏');
|
|
|
if (elem.favorite) {
|
|
|
a.find('.fav-no').hide();
|
|
|
a.find('.fav-yes').show();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
getResourceContent();
|
|
|
// sale倒计时
|
|
|
var saleTime = function(elem, offsetTime) {
|
|
|
var hour = parseInt(offsetTime / (60 * 60), 10),
|
|
|
minute = parseInt(offsetTime % (60 * 60) / 60, 10),
|
|
|
second = offsetTime % 60;
|
|
|
|
|
|
// 热门品牌滑动
|
|
|
if ($('.brands-swiper').find('li').length > 1) {
|
|
|
new Swiper('.brands-swiper', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
wrapperClass: 'brands-list',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
}
|
|
|
if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
$(elem).find('.limit').hide();
|
|
|
}
|
|
|
|
|
|
// 推荐搭配滑动
|
|
|
if ($('.recommend-swiper').find('li').length > 1) {
|
|
|
new Swiper('.recommend-swiper', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
wrapperClass: 'recommend-list',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
}
|
|
|
if (offsetTime >= -1) {
|
|
|
$(elem).find('.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
|
|
|
$(elem).find('.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
|
|
|
$(elem).find('.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second));
|
|
|
|
|
|
// 潮品话题轮播
|
|
|
if ($('.trend-topic-swiper').find('li').size() > 1) {
|
|
|
new Swiper('.trend-topic-swiper', {
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.trend-topic-content .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
$(elem).find('.limit').hide();
|
|
|
} else {
|
|
|
setTimeout(function() {
|
|
|
saleTime(elem, --offsetTime);
|
|
|
}, 1000);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 新人专享轮播
|
|
|
if ($('.fresh-list-swiper').find('li').size() > 1) {
|
|
|
new Swiper('.fresh-list-swiper', {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li',
|
|
|
watchSlidesVisibility: true
|
|
|
});
|
|
|
}
|
|
|
function ajaxResource() {
|
|
|
// 热门品牌滑动
|
|
|
if ($('.brands-swiper').find('li').length > 1) {
|
|
|
new Swiper('.brands-swiper', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
wrapperClass: 'brands-list',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 推荐搭配滑动
|
|
|
if ($('.recommend-swiper').find('li').length > 1) {
|
|
|
new Swiper('.recommend-swiper', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
wrapperClass: 'recommend-list',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 潮流上装/经典裤装等轮播
|
|
|
$('.category-swiper').each(function(i) {
|
|
|
swiperClass = 'category-swiper' + i;
|
|
|
$(this).addClass(swiperClass);
|
|
|
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
|
|
new Swiper('.' + swiperClass, {
|
|
|
// 潮品话题轮播
|
|
|
if ($('.trend-topic-swiper').find('li').size() > 1) {
|
|
|
new Swiper('.trend-topic-swiper', {
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.' + swiperClass + ' .pagination-inner'
|
|
|
pagination: '.trend-topic-content .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 新人专享轮播
|
|
|
if ($('.fresh-list-swiper').find('li').size() > 1) {
|
|
|
new Swiper('.fresh-list-swiper', {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li',
|
|
|
watchSlidesVisibility: true
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 潮流上装/经典裤装等轮播
|
|
|
$('.category-swiper').each(function(i) {
|
|
|
swiperClass = 'category-swiper' + i;
|
|
|
$(this).addClass(swiperClass);
|
|
|
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
|
|
new Swiper('.' + swiperClass, {
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
autoplayDisableOnInteraction: false,
|
|
|
paginationClickable: true,
|
|
|
slideElement: 'li',
|
|
|
pagination: '.' + swiperClass + ' .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 店铺推荐滑动效果
|
|
|
if ($('.shop-recom-swiper-container').find('li').length > 1) {
|
|
|
new Swiper('.shop-recom-swiper-container', {
|
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
paginationClickable: true,
|
|
|
slideActiveClass: 'recom-active',
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 店铺收藏 || 取消收藏
|
|
|
var $collect = $('.fav-container');
|
|
|
|
|
|
$collect.on('touchstart', function() {
|
|
|
var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok';
|
|
|
var self = $(this);
|
|
|
var num = parseInt(self.parent().find('.faved-num').html());
|
|
|
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: self.parent().attr('shopId'),
|
|
|
opt: opt,
|
|
|
type: 'shop',
|
|
|
},
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var url = '';
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
if (self.hasClass('fav-yes')) {
|
|
|
self.hide();
|
|
|
self.prev().show();
|
|
|
num--;
|
|
|
self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
tip.show('取消收藏成功!');
|
|
|
} else {
|
|
|
self.hide();
|
|
|
self.next().show();
|
|
|
num++;
|
|
|
self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
tip.show('收藏成功!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (data.code === 400) {
|
|
|
url = data.data;
|
|
|
location.href = url;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// vip专属等级查询
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: location.protocol + '//m.yohobuy.com/channel/userVip',
|
|
|
data: {
|
|
|
channel: 1,
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var vip = $('.vip-only');
|
|
|
|
|
|
if (data.code === 200 && Number(data.current_vip_level) !== 0) {
|
|
|
vip.show();
|
|
|
vip.find('.vip' + data.current_vip_level).show();
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
checkShop();
|
|
|
|
|
|
var limitFloor = $('.sale-floor-time');
|
|
|
|
|
|
limitFloor.each(function() {
|
|
|
var endTime = $(this).attr('data-time'),
|
|
|
|
|
|
// ~~两次取反位运算就是取整
|
|
|
limit = ~~((endTime * 1000 - Date.now()) / 1000);
|
|
|
|
|
|
saleTime(this, limit);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 异步获取首屏其余楼层
|
|
|
var getResourceContent = function() {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/channel/getResourceContent',
|
|
|
data: {
|
|
|
gender: $mobileWrap.data('channel')
|
|
|
},
|
|
|
}).then(function(result) {
|
|
|
var resourceTemplate = channelContentHbs({content: result});
|
|
|
|
|
|
$resourceContent.append(resourceTemplate);
|
|
|
lazyLoad($resourceContent.find('img.lazy:not([src])'));
|
|
|
|
|
|
ajaxResource();
|
|
|
});
|
|
|
};
|
|
|
|
|
|
setTimeout(function() {
|
|
|
getResourceContent();
|
|
|
}, 50);
|
|
|
|
|
|
// logo动画
|
|
|
function tsAnimate() {
|
...
|
...
|
@@ -262,155 +416,6 @@ window.setCookie('_Channel', $mobileWrap.data('channel'), { |
|
|
domain: '.yohobuy.com'
|
|
|
});
|
|
|
|
|
|
// 店铺推荐滑动效果
|
|
|
if ($('.shop-recom-swiper-container').find('li').length > 1) {
|
|
|
new Swiper('.shop-recom-swiper-container', {
|
|
|
centeredSlides: true,
|
|
|
slidesPerView: 'auto',
|
|
|
paginationClickable: true,
|
|
|
slideActiveClass: 'recom-active',
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 店铺推荐人数和收藏初始查询
|
|
|
var checkShop = function() {
|
|
|
var shopIds = [];
|
|
|
|
|
|
$('.recom-shop').each(function() {
|
|
|
shopIds.push($(this).attr('shopId'));
|
|
|
});
|
|
|
shopIds.length &&
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/channel/shopRecom',
|
|
|
data: {
|
|
|
shopIds: shopIds.join(','),
|
|
|
},
|
|
|
}).then(function(result) {
|
|
|
if (result.code === 200) {
|
|
|
for (var i = 0, elem;
|
|
|
(elem = result.data[i]) != null; i++) {
|
|
|
var a = $('.recom-shop[shopId = ' + elem.id + ']');
|
|
|
|
|
|
a.find('.faved-num').text(elem.collectionNum + '人已收藏');
|
|
|
if (elem.favorite) {
|
|
|
a.find('.fav-no').hide();
|
|
|
a.find('.fav-yes').show();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
checkShop();
|
|
|
|
|
|
// 店铺收藏 || 取消收藏
|
|
|
var $collect = $('.fav-container');
|
|
|
|
|
|
$collect.on('touchstart', function() {
|
|
|
var opt = $(this).hasClass('fav-yes') ? 'cancel' : 'ok';
|
|
|
var self = $(this);
|
|
|
var num = parseInt(self.parent().find('.faved-num').html());
|
|
|
|
|
|
$.ajax({
|
|
|
method: 'get',
|
|
|
url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: self.parent().attr('shopId'),
|
|
|
opt: opt,
|
|
|
type: 'shop',
|
|
|
},
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var url = '';
|
|
|
|
|
|
if (data.code === 200) {
|
|
|
if (self.hasClass('fav-yes')) {
|
|
|
self.hide();
|
|
|
self.prev().show();
|
|
|
num--;
|
|
|
self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
tip.show('取消收藏成功!');
|
|
|
} else {
|
|
|
self.hide();
|
|
|
self.next().show();
|
|
|
num++;
|
|
|
self.parent().find('.faved-num').html(num + '人已收藏');
|
|
|
tip.show('收藏成功!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (data.code === 400) {
|
|
|
url = data.data;
|
|
|
location.href = url;
|
|
|
}
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// vip专属等级查询
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: location.protocol + '//m.yohobuy.com/channel/userVip',
|
|
|
data: {
|
|
|
channel: 1,
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var vip = $('.vip-only');
|
|
|
|
|
|
if (data.code === 200 && Number(data.current_vip_level) !== 0) {
|
|
|
vip.show();
|
|
|
vip.find('.vip' + data.current_vip_level).show();
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// sale倒计时
|
|
|
var saleTime = function(elem, offsetTime) {
|
|
|
var hour = parseInt(offsetTime / (60 * 60), 10),
|
|
|
minute = parseInt(offsetTime % (60 * 60) / 60, 10),
|
|
|
second = offsetTime % 60;
|
|
|
|
|
|
if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
$(elem).find('.limit').hide();
|
|
|
}
|
|
|
|
|
|
if (offsetTime >= -1) {
|
|
|
$(elem).find('.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
|
|
|
$(elem).find('.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
|
|
|
$(elem).find('.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second));
|
|
|
|
|
|
if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
$(elem).find('.limit').hide();
|
|
|
} else {
|
|
|
setTimeout(function() {
|
|
|
saleTime(elem, --offsetTime);
|
|
|
}, 1000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
var limitFloor = $('.sale-floor-time');
|
|
|
|
|
|
limitFloor.each(function() {
|
|
|
var endTime = $(this).attr('data-time'),
|
|
|
|
|
|
// ~~两次取反位运算就是取整
|
|
|
limit = ~~((endTime * 1000 - Date.now()) / 1000);
|
|
|
|
|
|
saleTime(this, limit);
|
|
|
});
|
|
|
|
|
|
require('./maybe-like')();
|
|
|
|
|
|
C_ID = window._ChannelVary[window.cookie('_Channel')];
|
...
|
...
|
|