...
|
...
|
@@ -132,47 +132,85 @@ $('.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 (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);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 热门品牌滑动
|
|
|
if ($('.brands-swiper').find('li').length > 1) {
|
|
|
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) {
|
|
|
// 推荐搭配滑动
|
|
|
if ($('.recommend-swiper').find('li').length > 1) {
|
|
|
new Swiper('.recommend-swiper', {
|
|
|
grabCursor: true,
|
|
|
slidesPerView: 'auto',
|
|
|
wrapperClass: 'recommend-list',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 潮品话题轮播
|
|
|
if ($('.trend-topic-swiper').find('li').size() > 1) {
|
|
|
// 潮品话题轮播
|
|
|
if ($('.trend-topic-swiper').find('li').size() > 1) {
|
|
|
new Swiper('.trend-topic-swiper', {
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
...
|
...
|
@@ -181,10 +219,10 @@ if ($('.trend-topic-swiper').find('li').size() > 1) { |
|
|
slideElement: 'li',
|
|
|
pagination: '.trend-topic-content .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 新人专享轮播
|
|
|
if ($('.fresh-list-swiper').find('li').size() > 1) {
|
|
|
// 新人专享轮播
|
|
|
if ($('.fresh-list-swiper').find('li').size() > 1) {
|
|
|
new Swiper('.fresh-list-swiper', {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
...
|
...
|
@@ -193,10 +231,10 @@ if ($('.fresh-list-swiper').find('li').size() > 1) { |
|
|
slideElement: 'li',
|
|
|
watchSlidesVisibility: true
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 潮流上装/经典裤装等轮播
|
|
|
$('.category-swiper').each(function(i) {
|
|
|
// 潮流上装/经典裤装等轮播
|
|
|
$('.category-swiper').each(function(i) {
|
|
|
swiperClass = 'category-swiper' + i;
|
|
|
$(this).addClass(swiperClass);
|
|
|
if ($('.' + swiperClass).find('.swiper-slide').size() > 1) {
|
...
|
...
|
@@ -209,112 +247,29 @@ $('.category-swiper').each(function(i) { |
|
|
pagination: '.' + swiperClass + ' .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// logo动画
|
|
|
function tsAnimate() {
|
|
|
start = start + 10;
|
|
|
$logotrans.css({
|
|
|
transform: 'rotateX(' + start + 'deg)',
|
|
|
'-webkit-transform': 'rotateX(' + start + 'deg)',
|
|
|
'-moz-transform': 'rotateX(' + start + 'deg)'
|
|
|
});
|
|
|
if (start / 90 % 2 === 1) {
|
|
|
if (isen) {
|
|
|
$logotrans.addClass('animate');
|
|
|
isen = false;
|
|
|
} else {
|
|
|
$logotrans.removeClass('animate');
|
|
|
isen = true;
|
|
|
}
|
|
|
}
|
|
|
if (start / 90 % 2 === 0 && start % 360 !== 0) {
|
|
|
window.setTimeout(tsAnimate, 3000);
|
|
|
} else {
|
|
|
if (start % 360 === 0) {
|
|
|
window.setTimeout(tsAnimate, 60 * 1000);
|
|
|
} else {
|
|
|
window.requestAnimationFrame(tsAnimate);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
setTimeout(tsAnimate, 3000);
|
|
|
|
|
|
$('.home-header .iconfont').on('touchstart', function() {
|
|
|
$(this).addClass('highlight');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$(this).removeClass('highlight');
|
|
|
});
|
|
|
|
|
|
// 底部留出tab 的高度
|
|
|
window.reMarginFooter('.footer-tab');
|
|
|
|
|
|
// 原有项目 _Channel 写错位置,这里清理掉
|
|
|
window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
expires: -1,
|
|
|
domain: '.m.yohobuy.com'
|
|
|
});
|
|
|
|
|
|
// 记录当前 _Channel
|
|
|
window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
expires: 30,
|
|
|
domain: '.yohobuy.com'
|
|
|
});
|
|
|
|
|
|
// 店铺推荐滑动效果
|
|
|
if ($('.shop-recom-swiper-container').find('li').length > 1) {
|
|
|
// 店铺推荐滑动效果
|
|
|
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');
|
|
|
// 店铺收藏 || 取消收藏
|
|
|
var $collect = $('.fav-container');
|
|
|
|
|
|
$collect.on('touchstart', function() {
|
|
|
$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',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
|
|
|
data: {
|
|
|
id: self.parent().attr('shopId'),
|
|
|
opt: opt,
|
...
|
...
|
@@ -352,10 +307,10 @@ $collect.on('touchstart', function() { |
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// vip专属等级查询
|
|
|
$.ajax({
|
|
|
// vip专属等级查询
|
|
|
$.ajax({
|
|
|
method: 'POST',
|
|
|
url: location.protocol + '//m.yohobuy.com/channel/userVip',
|
|
|
data: {
|
...
|
...
|
@@ -372,43 +327,93 @@ $.ajax({ |
|
|
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;
|
|
|
checkShop();
|
|
|
|
|
|
if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
$(elem).find('.limit').hide();
|
|
|
}
|
|
|
var limitFloor = $('.sale-floor-time');
|
|
|
|
|
|
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));
|
|
|
limitFloor.each(function() {
|
|
|
var endTime = $(this).attr('data-time'),
|
|
|
|
|
|
if (offsetTime <= -1) { // 结束倒计时刷新状态
|
|
|
$(elem).find('.limit').hide();
|
|
|
// ~~两次取反位运算就是取整
|
|
|
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() {
|
|
|
start = start + 10;
|
|
|
$logotrans.css({
|
|
|
transform: 'rotateX(' + start + 'deg)',
|
|
|
'-webkit-transform': 'rotateX(' + start + 'deg)',
|
|
|
'-moz-transform': 'rotateX(' + start + 'deg)'
|
|
|
});
|
|
|
if (start / 90 % 2 === 1) {
|
|
|
if (isen) {
|
|
|
$logotrans.addClass('animate');
|
|
|
isen = false;
|
|
|
} else {
|
|
|
setTimeout(function() {
|
|
|
saleTime(elem, --offsetTime);
|
|
|
}, 1000);
|
|
|
$logotrans.removeClass('animate');
|
|
|
isen = true;
|
|
|
}
|
|
|
}
|
|
|
if (start / 90 % 2 === 0 && start % 360 !== 0) {
|
|
|
window.setTimeout(tsAnimate, 3000);
|
|
|
} else {
|
|
|
if (start % 360 === 0) {
|
|
|
window.setTimeout(tsAnimate, 60 * 1000);
|
|
|
} else {
|
|
|
window.requestAnimationFrame(tsAnimate);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
};
|
|
|
setTimeout(tsAnimate, 3000);
|
|
|
|
|
|
var limitFloor = $('.sale-floor-time');
|
|
|
$('.home-header .iconfont').on('touchstart', function() {
|
|
|
$(this).addClass('highlight');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$(this).removeClass('highlight');
|
|
|
});
|
|
|
|
|
|
limitFloor.each(function() {
|
|
|
var endTime = $(this).attr('data-time'),
|
|
|
// 底部留出tab 的高度
|
|
|
window.reMarginFooter('.footer-tab');
|
|
|
|
|
|
// ~~两次取反位运算就是取整
|
|
|
limit = ~~((endTime * 1000 - Date.now()) / 1000);
|
|
|
// 原有项目 _Channel 写错位置,这里清理掉
|
|
|
window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
expires: -1,
|
|
|
domain: '.m.yohobuy.com'
|
|
|
});
|
|
|
|
|
|
saleTime(this, limit);
|
|
|
// 记录当前 _Channel
|
|
|
window.setCookie('_Channel', $mobileWrap.data('channel'), {
|
|
|
expires: 30,
|
|
|
domain: '.yohobuy.com'
|
|
|
});
|
|
|
|
|
|
require('./maybe-like')();
|
...
|
...
|
|