$(function(){ $('.goodsImg2').lazyload({ effect: "fadeIn",failurelimit : 10,skip_invisible : false,threshold: 100,placeholder:window.conf.IMGURL+'/'+window.conf.GOODS_LOGO});//商品默认图片 WST.dropDownLayer(".item",".dorp-down-layer"); $('.item-more').click(function(){ if($(this).attr('v')==1){ $('.hideItem').show(300,'swing',function(){ showMoreBtn(); }); $(this).find("span").html("收起"); $(this).find("i").attr({"class":"drop-up"}); $(this).attr('v',0); }else{ $('.hideItem').hide(300); $(this).find("span").html("更多选项"); $(this).find("i").attr({"class":"drop-down-icon"}); $(this).attr('v',1); } }); $(".item-more").hover(function(){ if($(this).find("i").hasClass("drop-down-icon")){ $(this).find("i").attr({"class":"down-hover"}); }else{ $(this).find("i").attr({"class":"up-hover"}); } },function(){ if($(this).find("i").hasClass("down-hover")){ $(this).find("i").attr({"class":"drop-down"}); }else{ $(this).find("i").attr({"class":"drop-up"}); } }); $('.img_list li img').mouseover(function(){ // 商品列表小图切换 $(this).parent().siblings().removeClass('curr'); $(this).parent().addClass('curr'); var oldImgDom = $(this).parent().parent().parent().children('.img').children().children(); oldImgDom.attr('src',this.src.replace('_thumb','')); }) }); function goodsFilter(obj,vtype){ if(vtype==1){ $('#brand').val($(obj).attr('v')); }else if(vtype==2){ var price = $(obj).attr('v'); price = price.split('_'); $('#sprice').val(price[0]); $('#eprice').val(price[1]); }else if(vtype==3){ $('#v_'+$(obj).attr('d')).val($(obj).attr('v')); var vs = $('#vs').val(); vs = (vs!='')?vs.split(','):[]; vs.push($(obj).attr('d')); $('#vs').val(vs.join(',')); } var ipts = WST.getParams('.sipt'); if(vtype==4)ipts['order']='1'; var params = []; for(var key in ipts){ if(ipts[key]!='')params.push(key+"="+ipts[key]); } location.href=WST.U('home/goods/lists',params.join('&'),true); } function goodsOrder(orderby){ if($('#orderBy').val()!=orderby){ $('#order').val(1); } $('#orderBy').val(orderby); goodsFilter(null,0); } function removeFilter(id){ if(id!='price'){ $('#'+id).val(''); if(id.indexOf('v_')>-1){ id = id.replace('v_',''); var vs = $('#vs').val(); vs = (vs!='')?vs.split(','):[]; var nvs = []; for(var i=0;i请选择'); // 获取下级地区信息 $.post(WST.U('home/areas/listQuery'),{parentId:pid},function(data){ // 判断搜索页面 var search = $(t).attr('search'); if(search==1){search = 'search="1"';} var json = WST.toJson(data); if(json.status==1){ var html = ''; $(json.data).each(function(k,v){ html +='
  • '+v.areaName+'
  • '; }); $(nextid+"_pl").html(html); } }); // 隐藏当前地区,显示下级地区 var preid = ids[0]+"_"+ids[1]; $("ul[id^="+preid+"_]").hide(); $(nextid+"_pl").show(); } } /*************************************** 筛选 ******************************************/ function showMoreBtn(){ // 判断是否需要显示【更多】 $('.item .content').each(function() { if (this.scrollHeight > 34) { $(this).parent().find('.extra .extra_more').css({visibility:'visible'}); } }); } $(function(){ showMoreBtn(); }) function extra_show(obj){ $(obj).addClass('extra_more_on'); $(obj).parent().parent().find('ul').css({height:'auto'}); $(obj).html('收起'); $(obj).attr('onClick','extra_hide(this)'); } function extra_hide(obj){ // 修改点击事件 $(obj).removeClass('extra_more_on'); $(obj).parent().parent().find('ul').css({height:'30px'}); $(obj).attr('onClick','extra_show(this)'); $(obj).html('更多'); } var _preObj; function multibox_show(obj,type){ var _topParent = $(obj).parent().parent(); // 显示被隐藏的选项 _topParent.find('ul').css({height:'auto'}); // 给每个li绑定事件 _topParent.find('ul li').each(function(){ $(this).attr('_onclick',$(this).attr('onclick')); $(this).removeAttr('onclick'); $(this).click(function(){ $(this).toggleClass('selected'); ($('li.selected').length>0)?_topParent.find('a.confirm_btn').css({visibility:'visible'}):_topParent.find('a.confirm_btn').css({visibility:'hidden'}); }) }) // 隐藏右侧按钮 $(obj).parent().hide(); // 显示多选盒子 _topParent.addClass('multi_on'); _topParent.append('
    确定取消
    ') // 隐藏上一个多选盒子 if($('.multi_on').length>1){multibox_hide(_preObj)} _preObj = obj; } // 完成多选 function multi_done(obj,type){ var ids = [],attrId=0; // 获取选中的值 $(obj).parent().parent().find('ul li.selected').each(function(){ ids.push($(this).attr('v')); if(type=='attr')attrId = $(this).attr('d'); }) if(ids.length==0){ WST.msg('请选择要筛选的选项'); return false; } if(type=='brand'){ $('#brand').val(ids.join(',')); }else if(type=='attr'){ $('#v_'+attrId).val(ids.join('、'));// 属性名称 -> 双卡双4G_电信4G_移动4G var vs = $('#vs').val();// 属性id【不需要再拼凑】 vs = (vs!='')?vs.split(','):[]; vs.push(attrId); $('#vs').val(vs.join(',')); } var ipts = WST.getParams('.sipt'); var params = []; for(var key in ipts){ if(ipts[key]!='')params.push(key+"="+ipts[key]); } location.href=WST.U('home/goods/lists',params.join('&'),true); } // 多选隐藏 function multibox_hide(obj){ var _topParent = $(obj).parent().parent(); // 显示被隐藏的选项 _topParent.find('ul').css({height:'30px'}); // 给每个li绑定事件 _topParent.find('ul li').each(function(){ $(this).unbind('click'); $(this).attr('onclick',$(this).attr('_onclick')); $(this).removeAttr('_onclick'); $(this).removeClass('selected'); }) // 显示右侧按钮 _topParent.find('div.extra').show(); // 隐藏多选盒子 _topParent.removeClass('multi_on'); _topParent.find('div.multi_btns').remove(); // 设置【更多】按钮 var _moreBtn = _topParent.find('a.extra_more'); _moreBtn.removeClass('extra_more_on'); _moreBtn.attr('onClick','extra_show(this)'); _moreBtn.html('更多'); } //对比商品 function contrastGoods(show,id,type){ if(show==1){ $.post(WST.U('home/goods/contrastGoods'),{id:id},function(data,textStatus){ var json = WST.toJson(data); if(json.status==1){ if(type==2 && json.data)$("#j-cont-frame").addClass('show'); var gettpl = document.getElementById('colist').innerHTML; laytpl(gettpl).render(json, function(html){ $('#contrastList').html(html); }); $('.contImg').lazyload({ effect: "fadeIn",failurelimit : 10,skip_invisible : false,threshold: 200,placeholder:window.conf.IMGURL+'/'+window.conf.GOODS_LOGO});//商品默认图片 }else{ WST.msg(json.msg,{icon:2}); } if(type==1)$("#j-cont-frame").addClass('show'); }); }else{ $("#j-cont-frame").removeClass('show'); } } //删除 function contrastDels(id){ $.post(WST.U('home/goods/contrastDel'),{id:id},function(data,textStatus){ var json = WST.toJson(data); if(json.status==1){ contrastGoods(1,0,1); } }); } //对比商品列表 //滑动 function fixedGoods(){ var offsetTop = $("#goodsTabs").offset().top; $(window).scroll(function() { var scrollTop = $(document).scrollTop(); if (scrollTop > offsetTop){ $("#goodsTabs").addClass('goods-fixed'); $("#goodsTabs2").show(); }else{ $("#goodsTabs").removeClass('goods-fixed'); $("#goodsTabs2").hide(); } }); } //删除 function contrastDel(id){ $.post(WST.U('home/goods/contrastDel'),{id:id},function(data,textStatus){ var json = WST.toJson(data); if(json.status==1){ location.href=WST.U('home/goods/contrast'); } }); } //筛选条件 function screenContrast(obj,id){ if ($(obj).is(':checked')) { $(".identical_"+id).addClass('active'); }else{ $(".identical_"+id).removeClass('active'); } } //筛选规格 function choiceContrast(obj,itemId,catId,goodsId){ $(obj).addClass('active').siblings('.list-box li').removeClass('active'); $("#defaultSpec_"+goodsId+"_"+catId).val(itemId); var specIds = []; $(".defaultSpec_"+goodsId).each(function(){ specIds.push(parseInt($(this).val(),10)); }); specIds.sort(function(a,b){return a-b;}); if(saleSpec.sku[goodsId][specIds.join(':')]){ stock = saleSpec.sku[goodsId][specIds.join(':')].specStock; marketPrice = saleSpec.sku[goodsId][specIds.join(':')].marketPrice; goodsPrice = saleSpec.sku[goodsId][specIds.join(':')].specPrice; } $('#goods-price-'+goodsId).html('¥ '+goodsPrice+''); }