...
|
...
|
@@ -2,16 +2,24 @@ var $ = require('yoho-jquery'), |
|
|
tip = require('../plugin/tip'),
|
|
|
Swiper = require('yoho-swiper'),
|
|
|
loading = require('../plugin/loading'),
|
|
|
debounce = require('lodash/debounce'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload');
|
|
|
|
|
|
var plusstar = {},
|
|
|
$footer = $('#yoho-footer');
|
|
|
|
|
|
var windowHeight = $(window).height();
|
|
|
var scrollFn,
|
|
|
scrollTop;
|
|
|
|
|
|
require('../common');
|
|
|
|
|
|
plusstar = {
|
|
|
common: {
|
|
|
codeDefault: ''
|
|
|
codeDefault: '',
|
|
|
page: 1,
|
|
|
pagesize: 20,
|
|
|
productSkns: []
|
|
|
},
|
|
|
init: function() {
|
|
|
var that = this,
|
...
|
...
|
@@ -60,6 +68,7 @@ plusstar = { |
|
|
var that = this;
|
|
|
|
|
|
this.common.codeDefault = code;// 记住最后一次的tab code
|
|
|
this.common.page = 1;// 商品列表从第一页开始
|
|
|
|
|
|
loading.showLoadingMask();
|
|
|
|
...
|
...
|
@@ -72,6 +81,8 @@ plusstar = { |
|
|
},
|
|
|
dataType: 'html',
|
|
|
success: function(data) {
|
|
|
var productSkns = '';
|
|
|
|
|
|
$('.plusstar-resources').html(data);
|
|
|
|
|
|
if (data === '') {
|
...
|
...
|
@@ -97,6 +108,13 @@ plusstar = { |
|
|
if (window.localStorage) {
|
|
|
$(document).scrollTop(localStorage.getItem(code) || 0);
|
|
|
}
|
|
|
|
|
|
productSkns = $(data).find('.product-skns').val();
|
|
|
|
|
|
if (productSkns) {
|
|
|
that.common.productSkns = productSkns.split(',');
|
|
|
}
|
|
|
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
...
|
...
|
@@ -118,11 +136,59 @@ plusstar = { |
|
|
pagination: '.banner-top .pagination-inner'
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
goodsList: function() {
|
|
|
var that = this,
|
|
|
skn = [],
|
|
|
len = 0;
|
|
|
|
|
|
len = (that.common.page - 1) * that.common.pagesize;
|
|
|
skn = that.common.productSkns.slice(len, len + that.common.pagesize);
|
|
|
|
|
|
if (skn.length < 1) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
loading.showLoadingMask();
|
|
|
that.common.page++;
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/plusstar/resources-goodsList',
|
|
|
data: {
|
|
|
productSkn: skn.join(','),
|
|
|
app_version: window.queryString.app_version || window.queryString.appVersion
|
|
|
},
|
|
|
dataType: 'html',
|
|
|
success: function(data) {
|
|
|
if (data === '') {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
$('.plusstar-resources .goods').append(data);
|
|
|
|
|
|
lazyLoad($('.plusstar-resources .goods').find('img.lazy:not([src])'));
|
|
|
|
|
|
loading.hideLoadingMask();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$(function() {
|
|
|
scrollFn = debounce(function() {
|
|
|
scrollTop = $(document).scrollTop();
|
|
|
|
|
|
// 当scroll到最后一列商品的高度后继续请求下一页数据
|
|
|
if (400 + scrollTop >= $(document).height() - windowHeight) {
|
|
|
plusstar.goodsList();
|
|
|
}
|
|
|
|
|
|
if (window.localStorage) {
|
|
|
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
|
|
|
}
|
|
|
|
|
|
}, 200);
|
|
|
|
|
|
$(function() {
|
|
|
if (!(window.queryString.app_version || window.queryString.appVersion)) {
|
|
|
$('.tab-nav').css({
|
|
|
position: 'relative'
|
...
|
...
|
@@ -137,9 +203,9 @@ $(function() { |
|
|
|
|
|
plusstar.init();
|
|
|
|
|
|
if (window.localStorage) {
|
|
|
$(document).scroll(function() {
|
|
|
localStorage.setItem(plusstar.common.codeDefault, $(this).scrollTop());
|
|
|
});
|
|
|
}
|
|
|
// 滚动翻页
|
|
|
$(window).scroll(function() {
|
|
|
scrollFn();
|
|
|
});
|
|
|
|
|
|
}); |
...
|
...
|
|