view={api:new ec.api("product"),cart:{alterAmount:function(el,mins){input=$(el).parents(".amount").find("input");var amount=parseInt(input.val());amount+=mins||0;amount=amount>=0?amount:0;input.val(amount)},getInfo:function(el){var res=[];var priceItem=$(el).parents(".price-box").find("tbody tr");priceItem.each(function(){var proItem={};var num=parseInt($(this).find("input").val());if(num>0&&num<=1e3){proItem.PriceRID=$(this).attr("data-id");proItem.Amount=num;res.push(proItem)}});return res},insert:function(el){var info=this.getInfo(el);var btnText=$(el).find("span");if(info.length<=0)ec.notifyQ(L.G("请输入1-1000之间的产品数量"));else{ec.btnLoading(btnText,L.G("添加中..."));new ec.api("cart").put("insert",info,function(r){ec.btnLoading(btnText,L.G("加入购物车"));ec.notify(L.G("成功添加至购物车中"));ec.hideWindow("cart_simple_layer");$(".cart-amount").html(r.length)},function(){ec.btnLoading(btnText,L.G("加入购物车"))})}}},price:{toggle:function(num){var v=$("#"+num+"_priceBox").is(":visible");if(!v)this.renderGetData(num);else this.render(false,num)},renderGetData:function(num){var self=this;new ec.api((L.route+"/product").replace("/","")).put("getprice/"+num,function(r){self.render(true,num,r)})},render:function(v,num,html){var product=$("#"+num+"_box");$("#"+num+"_priceBox").remove();var l=$("#product_data thead .title th").length;product.toggleClass("active",v);product.find(".buttons span").html(L.G(v?"收回":"价格库存"));product.find(".buttons i").toggleClass("ico16-cirlceup");html=''+html+"";if(v)product.after(html)}},filter:{show:function(){ke.mask();$("#filter_layer").animate({right:"0"},"fast")},hide:function(){ke.unMask();$("#filter_layer").animate({right:"-100%"},"fast")},clean:function(){var url=window.location.href;var res=url.split("?")[0];var wd=ke.parm("q");if(wd)res+="?q="+wd;window.location.href=res},showLayer:function(dom){var el=$(dom);view.filter.hideLayers();if(!el.find(".layers").is(":visible")){el.find(".layers").slideDown("false");el.find("i").removeClass("ico16-down").addClass("ico16-up")}if(!view.filter._hasInit){view.filter._hasInit=true;$(window.document).click(function(e){var sx=e.clientX;var sy=e.clientY;var el=$(".filter");var x=el.offset().left;var y=el.offset().top;var w=el._width();var h=el._height();if(sxx+w||syy+h){view.filter.hideLayers()}})}},hideLayers:function(){$(".filter .layers").slideUp("false");$(".filter i").removeClass("ico16-up").addClass("ico16-down")},toggleDesc:function(id,oico,ico){$("#"+id).find(".name i").toggleClass(oico).toggleClass(ico);$("#"+id).find(".desc").slideToggle("fast")},toggle:function(el,oico,ico){$(".filter").toggle();$(el).find("i").toggleClass(oico).toggleClass(ico)}}};L.push(["请输入1-1000之间的产品数量","Please enter the quantity of products between 1-1000","添加中...","Adding...","加入购物车","Add to cart","成功添加至购物车中","Successfully added to shopping cart","收回","Hide","价格库存","Price"]);