view={api:new ec.api("product"),init:function(ts){this.cover.init();var tab=$(".tabs");if(tab.length&&!ts){view._top=tab.offset().top;$(window).scroll(function(){view.scrollEvent()})}},scrollEvent:function(){var cs=$(document).scrollTop();var ce=cs+$(window).height();var h=$(".tabs").height()+40;$(".tabs").toggleClass("tabs-fixed",cs>view._top);var items=$(".tabs a");for(var i=0;itop&&top-cs>h){items.removeClass("active").eq(i).addClass("active");return}}},scrollTo:function(el){var tab=$(".tabs");var h=240;if(tab.hasClass("tabs-fixed"))h=tab.height()+40;var top=$(el).offset().top-h;$("body,html").animate({scrollTop:top||0},300)},selectPackSize:function(i,priceRid){$(".product-price .buttons div").removeClass("active").eq(i).addClass("active");$(".product-price .items").hide().eq(i).show();view.priceRid=priceRid},selectSection:function(id,el){$(".product-tabs .item").removeClass("active");$(el).addClass("active");$("#productitem .section").hide();$(id).show()},toggleSection:function(el){var i=$(el).find("i");if(!i.is(":hidden")){$(el).next().slideToggle();if(!ec.iswap)i.toggleClass("ico20-plus").toggleClass("ico20-minus");else i.toggleClass("ico16-plus").toggleClass("ico16-minus")}},share:function(){var url=window.location.href;var tempInput=document.createElement("input");tempInput.style="position: absolute; left: -1000px; top: -1000px";tempInput.value=url;document.body.appendChild(tempInput);tempInput.select();try{document.execCommand("copy");ec.notify(L.G("已经复制到剪切板"))}catch(err){ec.notifyE(L.G("复制失败,您的浏览器不支持,请手动复制"))}document.body.removeChild(tempInput)},favorite:function(rid,type,id,c){var el=$(id||".btnfav");var ico=el.find("i");var label=el.find("label");var h=ico.hasClass(c);new ec.api("userinfo").put("favorite/"+rid+"/"+type,function(r){ec.notify(L.G(h?"取消收藏成功":"收藏成功"));ico.toggleClass(c);label.html(L.G(h?"加入收藏":"取消收藏"))})},coaDownload:function(num){var lot=COA.get();if(lot)window.open("/search/coa?productNum="+num+"&lotno="+lot);else ec.notifyQ(L.G("请选择批次"))},cart:{alter:function(id,mins){var input=null;if(!id)input=$(document.getElementsByName("amount")[0]);else input=$("#amount_"+id);var amount=parseInt(input.val())+(mins||0);if(amount<0||isNaN(amount))amount=0;input.val(amount)},add:function(dom){var res=[];var el=$(dom);var items=document.getElementsByName("amount");for(var i=0;i0&&temp.Amount<=1e3)res.push(temp)}if(res.length<=0)ec.notifyQ(L.G("请输入1-1000之间的产品数量"));else{ec.btnLoading(el,L.G("添加中..."));new ec.api("cart").put("insert",res,function(r){view.cart.success(r,el)})}},success:function(r,el){var pic=$(".cover img").attr("src");ec.btnLoading(el,L.G("加入购物车"));ec.notify(L.G("成功添加至购物车中"));master.cart.reset();$(".cart-amount").html(r.length);var offset=$("#support_cart").offset(),flyer=$('');flyer.fly({start:{left:el.offset().left+62,top:el.offset().top-$(window).scrollTop()-36},end:{left:offset.left,top:offset.top-$(window).scrollTop(),width:20,height:20}})}},cover:{index:0,vertical:true,init:function(){this.pic=$(".cover .pic");this.wrap=$(".cover .thumbs .items");this.item=this.wrap.find(".item");this.width=this.item.outerWidth(true);this.height=this.item.outerHeight(true);this.select(this.item.eq(0))},select:function(el,src){$(el).siblings().removeClass("active");$(el).addClass("active");if(!src)var src=$(el).find("img").attr("src");this.pic.find("img").attr("src",src)},view:function(){var url=this.pic.find("img").attr("src");ec.viewImage(0,url)},next:function(){this.fix(this.index+1)},pre:function(){this.fix(this.index-1)},fix:function(i){if(i>=this.item.length||i<0)return;this.index=i;if(this.vertical)this.wrap.stop().animate({left:-this.index*this.width},600);else this.wrap.stop().animate({top:-this.index*this.height},600)}}};L.push(["已经复制到剪切板","Already copied to clipboard","复制失败,您的浏览器不支持,请手动复制.","Copy failed, your browser does not support it, please manually copy","取消收藏成功","Unsubscribed successfully","收藏成功","Added to Favorites","加入收藏","Add to Favorites","取消收藏","Cancel collection","请输入1-1000之间的产品数量","Please enter the quantity of products between 1-1000","添加中...","Adding...","加入购物车","Add to cart","成功添加至购物车中","Successfully added to shopping cart"]);