var environment='production';+function(t){function a(a,e,i,n){t.ajax({url:"//kjapi."+c()+".com/metrics/v1/data/report",jsonp:"callback",dataType:"jsonp",data:{url:a,useTime:n,code:e,isSuccess:i},success:function(t){},error:function(){}})}function e(){var t=parseInt((new Date).getTime()) return t=""+t,t=t.substr(2,9),t=parseInt(t)}function i(t){var a,e=0,i=t.length,n="" for(e;i>e;++e)a=t.charCodeAt(e).toString(16),n+=a.length<2?"0"+a:a return n}var n=9999,s=!-[1]&&!window.XMLHttpRequest t.fn.ShopingCartPopUp=function(a){function e(a,e){e=e||"css" var i=c.width?c.width:a.width(),n=c.height?c.height:a.height() c.orignalSize||(a.height(n),a.width(i)) var s=t(window).height()/2-n/2,o=t(window).width()/2-i/2 c.top&&(s=c.top),a[e]({top:s+"px",left:o+"px"}),a.removeClass("hide")}var i={needScreen:!0,isFixed:!0,backgroundColor:"#666",opacity:"0.5",autoClose:!1,expires:1e3,wInsertCont:"",title:"",closeCallback:function(){}},c=t.extend(i,a) return this.each(function(){function a(){if(t(this).hide(),t(this).addClass("hide"),c.needScreen){var a=t(this).data("screen") a.remove()}c.closeCallback()}var i=t(this) if(""!=c.wInsertCont&&i.find(".wInsertCont").html(c.wInsertCont),""!=c.title&&i.find(".whd .title").html(c.title),s){t("html").css("background-image","url(about:blank)"),t("html").css("background-attachment","fixed") var o=t.trim(i.attr("style")) o+=";top:expression(documentElement.scrollTop + (documentElement.clientHeight/2 - this.clientHeight/2));",i.attr("style",o),i.css("display","block"),i.css("position","absolute"),i.css("bottom","auto"),i.css("margin-top",0),i.css("z-index",n+1)}else i.fadeIn(200),c.isFixed?i.css("position","fixed"):i.css("position","absolute"),i.css("z-index",n+1) e(i) var r={position:"absolute",top:0,left:0,width:"100%",height:t(document).height(),zIndex:n} if(c.needScreen){var d="signCoverWindow"+n,l=t("
") t("body").append(l),t("#"+d).css(r),t("#"+d).css("backgroundColor",c.backgroundColor),t("#"+d).css("opacity",c.opacity),t(this).data("screen",l)}var h=null t(window).unbind("resize").resize(t.proxy(function(){var a=t(this) h&&clearTimeout(h),h=setTimeout(function(){e(a,"animate"),t("div.screenBg").height(Math.max(t(document).height(),t(window).height()))},300)},i)),i.unbind("close").bind("close",a),i.on("click",".close",function(){i.trigger("close")}) var p=null c.autoClose&&(p&&clearTimeout(p),p=setTimeout(function(){i.trigger("close")},c.expires||1e3)),n+=2})},t.watchAjaxAction=function(n,s,c,o){var r=parseInt((new Date).getTime()),d=e(),l='{"_dm":[{"_t":"","_d":'+o+',"_c":"'+parseInt(s,10)+'","_s":"'+c+'","_u":"'+n+'"}],"ca":"pc","cb":"1.0"}',h="//metrics.yy.com/m?_id=3468&_pv=1.1.0&_seq="+d+"&_et=0&_ev=0&_ts="+r return"production"!=environment?!1:("n"==c&&a(n,s,c,o),void t.ajax({url:h,data:{hex:i(l)},type:"POST",dataType:"jsonp",jsonp:"jsonp",success:function(t){"n"==c&&a(t.s,t.c,"s",o)},error:function(t){a(n,501,"n",o)}}))} var c=function(){return"edu24ol"==window.location.host.split(".")[1]?"edu24ol":"hqwx"}}(jQuery),+function(t){var a=function(){return"edu24ol"==t.location.host.split(".")[1]?"edu24ol":"hqwx"},e={getUrls:function(e,i){var n=t.location.host !!i&&(n=i) var s=null return s=e?{cart:n?"//"+n+"/cart_v2/cart/index":"http://user."+a()+".com/cart/index",ajax_changeCart:"//"+n+"/addcart_v2/jsapi/cart/changeCart",ajax_addToPackage:"//"+n+"/addcart_v2/jsapi/cart/addToPackage",ajax_getCartList:"//"+n+"/addcart_v2/jsapi/cart/getCartList",ajax_removeToCart:"//"+n+"/addcart_v2/jsapi/cart/removeToCart"}:{cart:"http://user."+a()+".com/cart/index",ajax_changeCart:"//v2.hqwx.com/jsapi/cart/changeCart",ajax_addToPackage:"//v2.hqwx.com/jsapi/cart/addToPackage",ajax_getCartList:"//v2.hqwx.com/jsapi/cart/getCartList",ajax_removeToCart:"//v2.hqwx.com/jsapi/cart/removeToCart"}},PopUpMode_isInit:!1,FixedCartMode_isInit:!1},i=function(){var a={loadStyles:function(t){var a=document.createElement("link") a.rel="stylesheet",a.type="text/css",a.href=t,document.getElementsByTagName("head")[0].appendChild(a)},getJSONP:function(a){a.callbackName=a.callbackName+"_"+ +new Date||"callback_"+ +new Date,a.data=a.data||"",a.success=a.success||function(){},a.error=a.error||function(){},t[a.callbackName]=function(e){a.success(e),t[a.callbackName]=null} var e=document.createElement("script") e.type="text/javascript",e.async=!0,e.src=a.url+"?callback="+a.callbackName+"&"+a.data+"&_="+ +new Date,e.onload=function(){e.parentNode.removeChild(e)},e.onerror=function(){a.error()},document.getElementsByTagName("head")[0].appendChild(e)},getPopBox:function(t){var a=$("#"+t.id) if(0!=a.length)return a var e=t.id?" id="+t.id:"",i=t.className?" "+t.className:"",n=t.title?'
'+t.title+'
':"",s=$('
"+n+'
') return $("body").append(s.css({width:t.width,height:t.height})),s},getAjax:function(t){function a(t){--t.times&&setTimeout(function(){e(t)},t.ARQTime)}function e(t){return!t.times&&(t.times=2),!t.ARQTime&&(t.ARQTime=3e3),!t._id&&(t._id=+new Date+(1e6*Math.random()|0)),i[t._id]=$.ajax($.extend({},t,{jsonpCallback:t.callbackName+"_"+ +new Date,success:function(e){e?(delete i[t._id],t.success(e)):a(t)},error:function(e,n,s){console&&console.error("ajax:"+n+" "+s),t.times>0?a(t):(delete i[t._id],t.error(e,n,s))}})),t._id}var i={} return e}()} return{loadStyles:function(t){a.loadStyles(t)},getJSONP:function(t){a.getJSONP(t)},getPopBox:function(t){return a.getPopBox(t)},getJSONP1:function(t){a.getAjax(t)}}}(),n=function(){var t={init:function(){this.loadSource()},loadSource:function(){i.loadStyles("//s.hqwx.com/statics/home/css/cart/changeCart.css?v=20150924"),$.getScript("//v2.hqwx.com/statics/home/js/cart/json2.js").done(function(t,a){})},drawRadio:function(t,a){for(var e=t.length,i=null,n=[],s=0;e>s;s++)i=t[s],n.push('") return n.join("")},drawCheckbox:function(t){for(var a=t.length,e=null,i=[],n=0;a>n;n++)e=t[n],i.push('") return i.join("")},drawNotice:function(t,a){var e="" switch(t){case"success":e=' ' break case"error":e=' ' break case"loading":e=' ' break default:e=' '}return'
'+e+a+"
"},drawChoicePackage:function(t){for(var a,e,i,n,s,c,o=this,r=[],d=t||[],l=d.length,h=null,p=0;l>p;p++)h=d[p],h.id&&(a=h.id,e=h.name||"",i=h.price||0,n=h["package"]||[],s=h.pairs||[],c=h.gift||[],r.push('
  • '+(''+e+"")+('¥'+i+"")+"
    "),n.length>0&&r.push('
    相关配套课程'+o.drawRadio(n,a)+"
    "),s.length>0&&r.push('
    相关配件'+o.drawCheckbox(s)+"
    "),c.length>0,r.push("
  • ")) return'
    添加到购物车
    '}} return{init:function(){t.init()},drawNotice:function(a,e){return t.drawNotice(a,e)},drawChoicePackage:function(a){return t.drawChoicePackage(a)}}}(),s=function(){var t={init:function(t){var a=$.extend({transmit:!0,curHost:""},t) this.urls=e.getUrls(a.transmit,a.curHost),this.getNeededNodes()},drawNotice:function(t,a){var e="" switch(t){case"success":e=' ' break case"error":e=' ' break case"loading":e=' ' break default:e=' '}return'
    '+e+a+"
    "},drawRadio:function(t,a){for(var e=t.length,i=null,n=[],s=0;e>s;s++)i=t[s],n.push('") return n.join("")},drawCheckbox:function(t){for(var a=t.length,e=null,i=[],n=0;a>n;n++)e=t[n],i.push('") return i.join("")},drawGoToCart:function(t){return'
    '+t+'
    '+(' 去购物车查看')+"
    "},drawChoicePackage:function(t){for(var a,e,i,n,s,c,o=this,r=[],d=t||[],l=d.length,h=null,p=0;l>p;p++)h=d[p],h.id&&(a=h.id,e=h.name||"",i=h.price||0,n=h["package"]||[],s=h.pairs||[],c=h.gift||[],r.push('
  • '+(''+e+"")+('¥'+i+"")+"
    "),n.length>0&&r.push('
    相关配套课程'+o.drawRadio(n,a)+"
    "),s.length>0&&r.push('
    相关配件'+o.drawCheckbox(s)+"
    "),c.length>0,r.push("
  • ")) return'
    添加到购物车
    '},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?'立即支付':'立即支付',""+('"+('
    '+(' 共 '+i+" 件")+(' ¥ '+(t.price&&t.price.totalSalePrice||0)+"")+"
    "+d},renderFixedCart:function(){var t=$(this.drawFixedCart()).appendTo("body") this.$fixedCart=t,this.$fixedCart_bd=t.find(".edu24ShoppingCart_bd")},renderFixedCartCont:function(t){var a=this i.getJSONP({url:a.urls.ajax_getCartList,dataType:"jsonp",callbackName:"getCartListCartCallback",success:function(e){var i=e.status i&&(a.$fixedCart_bd.html(a.drawFixedCartCont(i.content)),"__init__"==t&&a.$fixedCart.fadeIn(300))}})},moveAnimate:function(t,a){var e=this,i=$("") i.appendTo($("body")),i.css({left:t.offset().left,top:t.offset().top}),i.animate({width:"30px",height:"30px",left:e.$fixedCart.offset().left+50,top:e.$fixedCart.offset().top+20},1e3,function(){i.hide("normal",function(){i.remove(),e.renderFixedCartCont(),a(e.urls.cart)})})},delTheGoods:function(t){var a=this i.getJSONP({url:a.urls.ajax_removeToCart,data:"goodsIds="+JSON.stringify(t),dataType:"jsonp",callbackName:"removeCartCallback",success:function(t){var e=t.status if(e){var i=e.code 0==i&&a.renderFixedCartCont()}}})},sendGoodsData:function(t,a){var e=this,s=0 !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),0==t.goods.length?t.emptyFn():(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 c=i.code 0==c?(e.fixedCartConfig.needAnimate&&t.animateElm&&t.animateElm.length>0?e.moveAnimate(t.animateElm,t.successFn):(e.renderFixedCartCont(),t.successFn(e.urls.cart)),$.watchAjaxAction(watchUrl,c,"y",(new Date).getTime()-s)):1==c?(e.$wChoicePackage.ShopingCartPopUp({wInsertCont:n.drawChoicePackage(i.content),closeCallback:function(){e.$wChoicePackage.find(".addToCart").removeClass("btn-blue-dis")}}),t.errorFn(i.msg),$.watchAjaxAction(watchUrl,c,"y",(new Date).getTime()-s)):$.watchAjaxAction(watchUrl,c,"n",(new Date).getTime()-s)}},error:function(a){t.failFn(),$.watchAjaxAction(watchUrl,500,"n",(new Date).getTime()-s)}}))},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)},getNeededNodes:function(){this.$notice=i.getPopBox({id:"wNotice",className:"wNotice win-popup-bd",width:200,height:64}),this.$wChoicePackage=i.getPopBox({id:"wChoicePackage",className:"wChoicePackage",title:"请选择",width:630,height:390}),this.bindAddPackageEvent()},bindFixedCartEvent:function(){var t=this this.$fixedCart_bd.on("click",".edu24olSC_del",function(a){var e=$(this),i=e.parent(),n=parseInt(i.attr("data-cartid")),s=parseInt(i.attr("data-goodsid")),c=i.attr("data-cartDetailStr"),o=[[n,s,c]] t.delTheGoods(o)})},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 n.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({needAnimate:!0,animateElm:t,goods:a})}var i=this,n=this.$wChoicePackage.children(".wInsertCont") n.on("click",".radio",t),n.on("click",".checkbox",a),n.on("click",".addToCart",function(){e($(this))})}} return{init:function(t){a.init(t)},addTheGoods:function(t){a.addTheGoods(t)}}}() !function(){n.init(),t.changeCartObj={getCartUrl:function(t){t=$.extend({transmit:!0},t) var a=e.getUrls(t.transmit) return a.cart}},t.changeCart=function(t){!e.PopUpMode_isInit&&s.init(t),e.PopUpMode_isInit=!0,s.addTheGoods(t)},t.changeCartInit=function(a){a.showFixedCart&&(c.init(a),t.changeCart=function(t){c.addTheGoods(t)})}}()}(window)