...
|
...
|
@@ -43,7 +43,7 @@ var defaultOpt = require('../../common/query-param'); |
|
|
|
|
|
var $listNav = $('#list-nav'),
|
|
|
|
|
|
//导航数据信息
|
|
|
// 导航数据信息
|
|
|
navInfo = {
|
|
|
new: {
|
|
|
order: 1,
|
...
|
...
|
@@ -76,7 +76,7 @@ var $listNav = $('#list-nav'), |
|
|
end: false
|
|
|
}
|
|
|
},
|
|
|
$pre = $listNav.find('.active'), //纪录进入筛选前的active项,初始为选中项
|
|
|
$pre = $listNav.find('.active'), // 纪录进入筛选前的active项,初始为选中项
|
|
|
searching;
|
|
|
|
|
|
var viewType = 1, // 1-首页,2-上新,3-人气
|
...
|
...
|
@@ -90,7 +90,7 @@ $('.main-wrap').css({ |
|
|
position: 'static'
|
|
|
});
|
|
|
|
|
|
//焦点效果
|
|
|
// 焦点效果
|
|
|
if ($('.banner-swiper').find('li').size() > 1) {
|
|
|
bannerSwiper = new Swiper('.banner-swiper', {
|
|
|
lazyLoading: true,
|
...
|
...
|
@@ -116,7 +116,7 @@ if ($('.multi-browse').find('li').size() > 1) { |
|
|
});
|
|
|
}
|
|
|
|
|
|
//根据热门品类的个数来改变样式展示
|
|
|
// 根据热门品类的个数来改变样式展示
|
|
|
//
|
|
|
if ($('.category-list li').length % 4 !== 0) {
|
|
|
$('.category-list li:last-child').addClass('category-list-last-li');
|
...
|
...
|
@@ -143,7 +143,7 @@ function getPageGoods(info) { |
|
|
navType = info.data.type;
|
|
|
nav = navInfo[navType];
|
|
|
|
|
|
//不需要重新加载并且数据请求结束
|
|
|
// 不需要重新加载并且数据请求结束
|
|
|
if (nav.end) {
|
|
|
|
|
|
return;
|
...
|
...
|
@@ -154,14 +154,14 @@ function getPageGoods(info) { |
|
|
type: 'GET',
|
|
|
url: info.url,
|
|
|
data: info.data,
|
|
|
success: function (data) {
|
|
|
success: function(data) {
|
|
|
if (data === ' ') {
|
|
|
nav.end = true;
|
|
|
}
|
|
|
|
|
|
info.callBack(data);
|
|
|
},
|
|
|
error: function () {
|
|
|
error: function() {
|
|
|
alert('网络断开连接了~');
|
|
|
searching = false;
|
|
|
}
|
...
|
...
|
@@ -191,7 +191,7 @@ function newData(callback) { |
|
|
|
|
|
getParam(req);
|
|
|
|
|
|
req.callBack = function (data) {
|
|
|
req.callBack = function(data) {
|
|
|
$('#new-arrival').append(data);
|
|
|
navInfo.new.page++;
|
|
|
myScroll.refresh();
|
...
|
...
|
@@ -216,7 +216,7 @@ function hotData(callback) { |
|
|
|
|
|
getParam(req);
|
|
|
|
|
|
req.callBack = function (data) {
|
|
|
req.callBack = function(data) {
|
|
|
$('#popularity').append(data);
|
|
|
navInfo.hot.page++;
|
|
|
myScroll.refresh();
|
...
|
...
|
@@ -242,10 +242,10 @@ myScroll = new IScroll('#wrapper', { |
|
|
click: true
|
|
|
});
|
|
|
|
|
|
//首页导航
|
|
|
(function (nav, posNav, main) {
|
|
|
// 首页导航
|
|
|
(function(nav, posNav, main) {
|
|
|
|
|
|
$(nav + ' li, ' + posNav + ' li').not('li.all-goods').on('touchstart', function () {
|
|
|
$(nav + ' li, ' + posNav + ' li').not('li.all-goods').on('touchstart', function() {
|
|
|
|
|
|
var index = $(this).index(),
|
|
|
activeTab = $(this).attr('tab');
|
...
|
...
|
@@ -323,7 +323,7 @@ function reNav1Pos() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
myScroll.on('scroll', function () {
|
|
|
myScroll.on('scroll', function() {
|
|
|
var scrollCall,
|
|
|
sTop = -this.y;
|
|
|
|
...
|
...
|
@@ -344,7 +344,7 @@ myScroll.on('scroll', function () { |
|
|
}
|
|
|
|
|
|
if (sTop + winH * 2 > scH) {
|
|
|
scrollCall = function () {
|
|
|
scrollCall = function() {
|
|
|
var translate = 'translate3d(0, ' + (-scH) + 'px, 0)';
|
|
|
$nav1.css({
|
|
|
transform: translate,
|
...
|
...
|
@@ -369,14 +369,14 @@ myScroll.on('scroll', function () { |
|
|
}
|
|
|
if (!$nav2.hasClass('hide')) {
|
|
|
$nav2.addClass('hide');
|
|
|
} //滑动距离不到导航1
|
|
|
} // 滑动距离不到导航1
|
|
|
} else if (sTop < imgH + main1oH + nav1H) {
|
|
|
if ($nav1.hasClass('hide')) {
|
|
|
$nav1.removeClass('hide');
|
|
|
}
|
|
|
if (!$nav2.hasClass('hide')) {
|
|
|
$nav2.addClass('hide');
|
|
|
} //滑动距离不到导航2
|
|
|
} // 滑动距离不到导航2
|
|
|
|
|
|
if (sTop < imgH + main1H) {
|
|
|
if (!$nav1.hasClass('fixed-top')) {
|
...
|
...
|
@@ -434,7 +434,7 @@ myScroll.on('scroll', function () { |
|
|
}
|
|
|
});
|
|
|
|
|
|
myScroll.on('scrollStart', function () {
|
|
|
myScroll.on('scrollStart', function() {
|
|
|
|
|
|
// stop auto play when scroll
|
|
|
bannerSwiper && bannerSwiper.stopAutoplay();
|
...
|
...
|
@@ -442,7 +442,7 @@ myScroll.on('scrollStart', function () { |
|
|
multiSwiper && multiSwiper.stopAutoplay();
|
|
|
});
|
|
|
|
|
|
myScroll.on('scrollEnd', function () {
|
|
|
myScroll.on('scrollEnd', function() {
|
|
|
|
|
|
// start auto play when scroll end
|
|
|
bannerSwiper && bannerSwiper.startAutoplay();
|
...
|
...
|
@@ -453,20 +453,20 @@ myScroll.on('scrollEnd', function () { |
|
|
});
|
|
|
|
|
|
|
|
|
document.addEventListener('touchmove', function (e) {
|
|
|
document.addEventListener('touchmove', function(e) {
|
|
|
// sub classify不阻止默认事件
|
|
|
if ($(e.target).closest('.sub-classify').length === 0) {
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
}, false);
|
|
|
|
|
|
/*if (!isIphone) {
|
|
|
/* if (!isIphone) {
|
|
|
return;
|
|
|
}*/
|
|
|
|
|
|
|
|
|
//window onload 后重新refresh iscroll
|
|
|
$(window).load(function () {
|
|
|
// window onload 后重新refresh iscroll
|
|
|
$(window).load(function() {
|
|
|
myScroll && myScroll.refresh();
|
|
|
imgH = $('#nav-top').outerHeight();
|
|
|
nav1H = $('#nav').outerHeight();
|
...
|
...
|
@@ -474,7 +474,7 @@ $(window).load(function () { |
|
|
main1oH = $('#nav-main').outerHeight();
|
|
|
nav2H = $('#list-nav').outerHeight();
|
|
|
main2oH = $('#goods-container').outerHeight();
|
|
|
setTimeout(function () {
|
|
|
setTimeout(function() {
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
}, 1000);
|
|
|
});
|
...
|
...
|
@@ -500,7 +500,7 @@ function search(opt) { |
|
|
|
|
|
if (!opt.nextPage) {
|
|
|
|
|
|
//筛选项变更则重置reload为true
|
|
|
// 筛选项变更则重置reload为true
|
|
|
for (att in navInfo) {
|
|
|
if (navInfo.hasOwnProperty(att)) {
|
|
|
navInfo[att].reload = true;
|
...
|
...
|
@@ -559,11 +559,11 @@ function search(opt) { |
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
$.extend(defaultOpt, ext); //扩展筛选项
|
|
|
$.extend(defaultOpt, ext); // 扩展筛选项
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//导航类别
|
|
|
// 导航类别
|
|
|
if ($pre.hasClass('new')) {
|
|
|
navType = 'newest';
|
|
|
} else if ($pre.hasClass('price')) {
|
...
|
...
|
@@ -578,7 +578,7 @@ function search(opt) { |
|
|
page = 1;
|
|
|
} else if (nav.end) {
|
|
|
|
|
|
//不需要重新加载并且数据请求结束
|
|
|
// 不需要重新加载并且数据请求结束
|
|
|
return;
|
|
|
}
|
|
|
$.extend(setting, defaultOpt, {
|
...
|
...
|
@@ -601,7 +601,7 @@ function search(opt) { |
|
|
type: 'GET',
|
|
|
url: opt.url ? opt.url : '',
|
|
|
data: setting,
|
|
|
success: function (data) {
|
|
|
success: function(data) {
|
|
|
var $container,
|
|
|
num;
|
|
|
|
...
|
...
|
@@ -651,7 +651,7 @@ function search(opt) { |
|
|
|
|
|
bindGoodThumbClick();
|
|
|
},
|
|
|
error: function () {
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
searching = false;
|
|
|
loading.hideLoadingMask();
|
...
|
...
|
@@ -660,11 +660,11 @@ function search(opt) { |
|
|
}
|
|
|
|
|
|
|
|
|
$listNav.bind('contextmenu', function (e) {
|
|
|
$listNav.bind('contextmenu', function(e) {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$subNav.on('touchend touchcancel', function (e) {
|
|
|
$subNav.on('touchend touchcancel', function(e) {
|
|
|
var $this = $(e.target).closest('li'),
|
|
|
cname,
|
|
|
nav,
|
...
|
...
|
@@ -681,11 +681,11 @@ $subNav.on('touchend touchcancel', function (e) { |
|
|
|
|
|
if ($this.hasClass('filter')) {
|
|
|
|
|
|
//筛选面板切换状态
|
|
|
// 筛选面板切换状态
|
|
|
if ($this.hasClass('active')) {
|
|
|
filter.hideFilter();
|
|
|
|
|
|
//点击筛选钱的active项回复active
|
|
|
// 点击筛选钱的active项回复active
|
|
|
$pre.addClass('active');
|
|
|
$this.removeClass('active');
|
|
|
|
...
|
...
|
@@ -730,7 +730,7 @@ $subNav.on('touchend touchcancel', function (e) { |
|
|
|
|
|
if ($this.hasClass('active')) {
|
|
|
|
|
|
//最新无排序切换
|
|
|
// 最新无排序切换
|
|
|
if ($this.hasClass('new')) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
@@ -740,9 +740,9 @@ $subNav.on('touchend touchcancel', function (e) { |
|
|
|
|
|
// 价格/折扣切换排序状态
|
|
|
$this.find('.icon > .iconfont').toggleClass('cur');
|
|
|
$pre = $this; //更新pre为当前项
|
|
|
nav.reload = true; //重置reload,HTML会被替换为逆序的HTML
|
|
|
nav.order = nav.order === 0 ? 1 : 0; //切换排序
|
|
|
$pre = $this; // 更新pre为当前项
|
|
|
nav.reload = true; // 重置reload,HTML会被替换为逆序的HTML
|
|
|
nav.order = nav.order === 0 ? 1 : 0; // 切换排序
|
|
|
|
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
|
...
|
...
|
@@ -766,15 +766,15 @@ $subNav.on('touchend touchcancel', function (e) { |
|
|
} else {
|
|
|
$active = $subNav.find('.active');
|
|
|
|
|
|
$pre = $this; //$pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
|
|
|
$pre = $this; // $pre为除筛选导航的其他导航项,若当前active的为筛选,则把$pre置为当前点击项
|
|
|
|
|
|
if ($active.hasClass('filter')) {
|
|
|
|
|
|
//若之前active项为筛选,则隐藏筛选面板
|
|
|
// 若之前active项为筛选,则隐藏筛选面板
|
|
|
filter.hideFilter();
|
|
|
} else {
|
|
|
|
|
|
//切换container显示
|
|
|
// 切换container显示
|
|
|
$goodsContainer.children('.container:not(.hide)').addClass('hide');
|
|
|
|
|
|
switch (navType) {
|
...
|
...
|
@@ -812,13 +812,13 @@ $subNav.on('touchend touchcancel', function (e) { |
|
|
});
|
|
|
|
|
|
filter.initFilter({
|
|
|
fCbFn: function (option) {
|
|
|
fCbFn: function(option) {
|
|
|
search(option);
|
|
|
myScroll.enable();
|
|
|
},
|
|
|
hCbFn: function () {
|
|
|
hCbFn: function() {
|
|
|
|
|
|
//切换active状态到$pre上
|
|
|
// 切换active状态到$pre上
|
|
|
$pre.addClass('active');
|
|
|
$pre.siblings('.filter').removeClass('active');
|
|
|
|
...
|
...
|
@@ -827,23 +827,23 @@ filter.initFilter({ |
|
|
missStatus: true
|
|
|
});
|
|
|
|
|
|
$listNav.on('touchstart', 'li', function (e) {
|
|
|
$listNav.on('touchstart', 'li', function(e) {
|
|
|
$(this).addClass('bytouch');
|
|
|
}).on('touchend touchcancel', function () {
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$listNav.find('li').removeClass('bytouch');
|
|
|
myScroll.refresh();
|
|
|
});
|
|
|
|
|
|
$nav2.on('touchstart', 'li', function (e) {
|
|
|
$nav2.on('touchstart', 'li', function(e) {
|
|
|
$(this).addClass('bytouch');
|
|
|
}).on('touchend touchcancel', function () {
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$nav2.find('li').removeClass('bytouch');
|
|
|
myScroll.refresh();
|
|
|
});
|
|
|
|
|
|
//底部导航点击
|
|
|
// 底部导航点击
|
|
|
function fotterClick(group) {
|
|
|
$(group + ' li').on('touchstart', function () {
|
|
|
$(group + ' li').on('touchstart', function() {
|
|
|
$('.sub-group').addClass('hide');
|
|
|
$(this).find('.sub-group').removeClass('hide');
|
|
|
});
|
...
|
...
|
@@ -859,15 +859,16 @@ function stopPropagation(e) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
$(document).bind('touchstart', function (e) {
|
|
|
$(document).bind('touchstart', function(e) {
|
|
|
$('.sub-group').addClass('hide');
|
|
|
});
|
|
|
|
|
|
$('.shop-foot-wrapper').bind('touchstart', function (e) {
|
|
|
$('.shop-foot-wrapper').bind('touchstart', function(e) {
|
|
|
stopPropagation(e);
|
|
|
});
|
|
|
|
|
|
// 店铺收藏 || 取消收藏
|
|
|
$collect.on('touchstart', function () {
|
|
|
$collect.on('touchstart', function() {
|
|
|
var opt;
|
|
|
|
|
|
if (searching) {
|
...
|
...
|
@@ -890,7 +891,7 @@ $collect.on('touchstart', function () { |
|
|
opt: opt,
|
|
|
type: 'shop'
|
|
|
},
|
|
|
success: function (data) {
|
|
|
success: function(data) {
|
|
|
var url = '';
|
|
|
|
|
|
if (data.code === 200) {
|
...
|
...
|
@@ -903,11 +904,11 @@ $collect.on('touchstart', function () { |
|
|
|
|
|
if (data.code === 401) {
|
|
|
url = 'http://m.yohobuy.com/signin.html?refer=' + encodeURIComponent(location.href) + '&openby:yohobuy=';
|
|
|
url += JSON.stringify({"action": "go.weblogin",
|
|
|
"params": {
|
|
|
"jumpurl": {"url": 'http://m.yohobuy.com' + location.pathname, "param": info.data},
|
|
|
"requesturl": {"param": {}, "url": ""},
|
|
|
"priority": "N"
|
|
|
url += JSON.stringify({'action': 'go.weblogin',
|
|
|
'params': {
|
|
|
'jumpurl': {'url': 'http://m.yohobuy.com' + location.pathname, 'param': info.data},
|
|
|
'requesturl': {'param': {}, 'url': ''},
|
|
|
'priority': 'N'
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -916,13 +917,13 @@ $collect.on('touchstart', function () { |
|
|
$('.jump-login').click();
|
|
|
}
|
|
|
|
|
|
setTimeout(function () {
|
|
|
setTimeout(function() {
|
|
|
myScroll.refresh();
|
|
|
scH = $('#scroller').outerHeight();
|
|
|
}, 1000);
|
|
|
searching = false;
|
|
|
},
|
|
|
error: function () {
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
searching = false;
|
|
|
}
|
...
|
...
|
|