You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
92
hyhproject/wechat2/view/default/js/goods_list.js
Executable file
92
hyhproject/wechat2/view/default/js/goods_list.js
Executable file
@ -0,0 +1,92 @@
|
||||
//排序条件
|
||||
function orderCondition(obj,condition){
|
||||
var classContent = $(obj).attr('class');
|
||||
var status = $(obj).attr('status');
|
||||
var theSiblings = $(obj).siblings('.sorts');
|
||||
theSiblings.removeClass('active').attr('status','down');
|
||||
$(obj).addClass('active');
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('down');
|
||||
theSiblings.children('i').addClass('down').removeClass('down2');
|
||||
}
|
||||
if(status.indexOf('down')>-1){
|
||||
if(classContent.indexOf('active')==-1){
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$('#desc').val('0');
|
||||
}else{
|
||||
$(obj).children('i').addClass('up2').removeClass('down2');
|
||||
$(obj).attr('status','up');
|
||||
$('#desc').val('1');
|
||||
}
|
||||
}else{
|
||||
$(obj).children('i').addClass('down2').removeClass('up2');
|
||||
$(obj).attr('status','down');
|
||||
$('#desc').val('0');
|
||||
}
|
||||
$('#condition').val(condition);//排序条件
|
||||
$('#currPage').val('0');//当前页归零
|
||||
$('#goods-list').html('');
|
||||
goodsList();
|
||||
}
|
||||
//获取商品列表
|
||||
function goodsList(){
|
||||
$('#Load').show();
|
||||
loading = true;
|
||||
var param = {};
|
||||
param.catId = $('#catId').val();
|
||||
param.brandId = $('#brandId').val();
|
||||
param.condition = $('#condition').val();
|
||||
param.desc = $('#desc').val();
|
||||
param.keyword = $('#keyword').val();
|
||||
param.pagesize = 10;
|
||||
param.page = Number( $('#currPage').val() ) + 1;
|
||||
$.post(WST.U('wechat/goods/pageQuery'), param,function(data){
|
||||
var json = WST.toJson(data);
|
||||
$('#currPage').val(json.CurrentPage);
|
||||
$('#totalPage').val(json.TotalPage);
|
||||
var gettpl = document.getElementById('list').innerHTML;
|
||||
laytpl(gettpl).render(json.Rows, function(html){
|
||||
$('#goods-list').append(html);
|
||||
});
|
||||
WST.imgAdapt('j-imgAdapt');
|
||||
loading = false;
|
||||
$('#Load').hide();
|
||||
echo.init();//图片懒加载
|
||||
});
|
||||
}
|
||||
//切换
|
||||
function switchList(obj){
|
||||
if($('#goods-list').hasClass('wst-go-switch')){
|
||||
$(obj).removeClass('wst-se-icon2');
|
||||
$('#goods-list').removeClass('wst-go-switch');
|
||||
}else{
|
||||
$(obj).addClass('wst-se-icon2');
|
||||
$('#goods-list').addClass('wst-go-switch');
|
||||
}
|
||||
$('.j-imgAdapt').removeAttr('style');
|
||||
$('.j-imgAdapt a').removeAttr('style');
|
||||
$('.j-imgAdapt a img').removeAttr('style');
|
||||
$('#currPage').val('0');
|
||||
$('#goods-list').html('');
|
||||
goodsList();
|
||||
}
|
||||
var currPage = totalPage = 0;
|
||||
var loading = false;
|
||||
$(document).ready(function(){
|
||||
WST.initFooter('home');
|
||||
$('.wst-se-search').on('submit', '.input-form', function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
goodsList();
|
||||
$('.wst-gol-adsb').css('height',$('.j-imgRec').width()+20);
|
||||
$(window).scroll(function(){
|
||||
if (loading) return;
|
||||
if ((5 + $(window).scrollTop()) >= ($(document).height() - screen.height)) {
|
||||
currPage = Number( $('#currPage').val() );
|
||||
totalPage = Number( $('#totalPage').val() );
|
||||
if( totalPage > 0 && currPage < totalPage ){
|
||||
goodsList();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user