'},getNeededNodes:function(){this.$notice=i.getPopBox({id:"wNotice",className:"wNotice win-popup-bd",width:200,height:64}),this.$wGotoCart=i.getPopBox({id:"wGotoCart",className:"wGotoCart",title:"添加到购物车",width:460,height:240}),this.$wChoicePackage=i.getPopBox({id:"wChoicePackage",className:"wChoicePackage",title:"请选择",width:630,height:390}),this.bindAddPackageEvent()},sendGoodsData:function(t,a){var e=this,s=0
t=$.extend({needToCartPop:!1},t),!t.emptyFn&&(t.emptyFn=$.noop),!t.beforeFn&&(t.beforeFn=$.noop),!t.successFn&&(t.successFn=$.noop),!t.errorFn&&(t.errorFn=$.noop),!t.failFn&&(t.failFn=$.noop)
var c=t.noNotices?$.noop:function(t,a){e.$notice.find(".wInsertCont").html(n.drawNotice(t,a)),setTimeout(function(){e.$notice.trigger("close")},1e3)}
0==t.goods.length?(!t.noNotices&&e.$notice.ShopingCartPopUp({needScreen:!1,autoClose:!0,wInsertCont:n.drawNotice("warn","您还没有选择套餐"),closeCallback:function(){}}),t.emptyFn()):(e.$wChoicePackage.is(":visible")&&e.$wChoicePackage.trigger("close"),!t.noNotices&&e.$notice.ShopingCartPopUp({wInsertCont:n.drawNotice("loading","请稍后"),closeCallback:function(){}}),t.beforeFn(),s=(new Date).getTime(),watchUrl="cart/changeCart",i.getJSONP({url:a,data:"goods="+JSON.stringify(t.goods),dataType:"jsonp",callbackName:"changeCartCallback",success:function(a){var i=a.status
if(i){var o=i.code
0==o?($.watchAjaxAction(watchUrl,o,"y",(new Date).getTime()-s),t.needToCartPop?(!t.noNotices&&e.$notice.trigger("close"),e.$wGotoCart.ShopingCartPopUp({wInsertCont:e.drawGoToCart("成功添加到购物车"),closeCallback:function(){}})):c("success","添加成功"),t.successFn(e.urls.cart)):1==o?($.watchAjaxAction(watchUrl,o,"y",(new Date).getTime()-s),!t.noNotices&&e.$notice.trigger("close"),e.$wChoicePackage.ShopingCartPopUp({wInsertCont:n.drawChoicePackage(i.content),closeCallback:function(){}})):($.watchAjaxAction(watchUrl,o,"n",(new Date).getTime()-s),c("error",i.msg),t.errorFn(i.msg))}},error:function(a){c("error","服务器出错"),t.failFn(),$.watchAjaxAction(watchUrl,500,"n",(new Date).getTime()-s)}}))},bindAddPackageEvent:function(){function t(t){t.preventDefault()
var a=$(this),e=a.attr("data-group")
n.find(".radio[data-group="+e+"]").removeClass("checked"),a.addClass("checked")}function a(t){t.preventDefault()
var a=$(this),e=1e3*parseFloat(a.data("price")),i=a.parent().siblings(".cp-hd").find(".c-price em"),n=1e3*parseFloat(i.html())
a.hasClass("checked")?(a.removeClass("checked"),i.html((n-e)/1e3)):(a.addClass("checked"),i.html((n+e)/1e3))}function e(t){var a=[],e=!0
$(t.delegateTarget).find(".chooseParts").each(function(){var t=$(this),i=t.find(".c-title"),n=i.data("tid")
a.push([parseInt(n),1,0,9])
var s,c=t.children(".cp-package")
c.length>0&&(s=c.children(".checked").data("gid"),s?a.push([parseInt(s),1,parseInt(n),0]):e=!1)
var o=t.children(".cp-pairs")
o.length>0&&o.children(".checked").each(function(){var t=$(this).data("gid")
!!t&&a.push([parseInt(t),1,parseInt(n),1])})
var r=t.children(".cp-gift")
r.length>0&&r.children(".checked").each(function(){var t=$(this).data("gid")
!!t&&a.push([parseInt(t),1,parseInt(n),2])})}),!e&&(a=[]),i.addThePackages({goods:a})}var i=this,n=this.$wChoicePackage.children(".wInsertCont")
n.on("click",".radio",t),n.on("click",".checkbox",a),n.on("click",".addToCart",e)},addThePackages:function(t){var a=this,e=$.extend({},a.options,t)
this.sendGoodsData(e,this.urls.ajax_addToPackage)},addTheGoods:function(t){this.options=t,this.sendGoodsData(t,this.urls.ajax_changeCart)}}
return{init:function(a){t.init(a)},addTheGoods:function(a){t.addTheGoods(a)}}}(),c=function(){var a={init:function(a){var i={transmit:!0,curHost:"",fcWidth:192,fixedType:"right",contWidth:1e3,offsetTop:($(t).height()-542)/2,offsetHrz:520}
this.fixedCartConfig=$.extend(i,a),this.urls=e.getUrls(this.fixedCartConfig.transmit,this.fixedCartConfig.curHost),this.renderFixedCart(),this.renderFixedCartCont("__init__"),this.bindFixedCartEvent(),this.getNeededNodes()},setVal:function(t,a){this[t]=a},drawFixedCart:function(){var t=this.fixedCartConfig,a=t.fixedType,e=t.offsetTop+"px",i="-"+(t.contWidth/2+t.fcWidth+t.offsetHrz)+"px",n="display:none; top:"+e+"; "+a+": 50%; margin-"+a+":"+i
return'
购物车
'},drawFixedCartCont:function(t){t=t||{}
var a=6,e=t.list||[],i=e.length,n=null,s=Math.max(i-1,0),c=0,o=[]
if(0!==i)for(var r=s;r>=c;r--)n=e[r],o.push(""+('
')+('
'+(n.name||"")+"
")+' 删除'+(' ¥ '+(n.salePrice||0)+"")+"
")
o=o.join("")
var d=""
return d=0!=i?'立即支付':'立即支付',""+('