import{_ as y,o,g as n,b as a,a as s,u as t,w as r,i as m,F as u,D as g,f as p,t as l,n as k,h as v,M as P,N as C}from"./app-BYcXwl4U.js";import{i as b,c as x}from"./app-a6cKceqE.js";import{_ as $}from"./app-BTdips4W.js";import{T as w}from"./app-CrjU8lgK.js";import{_ as N,a as R}from"./app-DxbU-QrX.js";import{T as f}from"./app-BbPGXKj1.js";import{D as T}from"./app-7GBSHA5C.js";import"./app-DCd54JMo.js";import"./app-MrAtUXr3.js";import"./app-BWSI2Z1R.js";import"./app-DPDEogA0.js";import"./app-DxjODhok.js";import"./app-CabATHnR.js";import"./app-BhzV4gWo.js";import"./app-Cp3gmk2J.js";import"./app--MWyBMkA.js";import"./app-BG60hdvp.js";import"./app-CNARLpXE.js";import"./app-SxAW7vhf.js";import"./app-D5k1HLu9.js";import"./app-ysQ8KbGS.js";import"./app-BDgR0DSb.js";function V(){b(this),this.packageId=0,this.regionId=0,this.periodId=0,this.amount=-1,this.count=1,this.selectPackage=function(e){this.packageId=e,this.regionId=0,this.periodId=0,this.reloadPrice()},this.selectRegion=function(e){this.regionId=e,this.periodId=0,this.reloadPrice()},this.selectPeriod=function(e){this.periodId=e,this.reloadPrice()},this.changeCount=function(){this.reloadPrice()};var d=0;this.reloadPrice=function(){var e=++d;this.$post(".price").params({packageId:this.packageId,regionId:this.regionId,periodId:this.periodId,count:this.count}).success(function(c){e==d&&(this.amount=c.data.amount)})},this.hasRegionPrice=function(e){if(this.packageId<=0)return!1;for(let c in this.prices)if(c.startsWith(this.packageId+"@"+e+"@"))return!0;return!1},this.hasPeriodPrice=function(e){if(this.packageId<=0||this.regionId<=0)return!1;for(let c in this.prices)if(c==this.packageId+"@"+this.regionId+"@"+e)return!0;return!1},this.goNext=function(){this.packageId>0&&this.regionId>0&&this.periodId>0&&this.count>0&&(window.location="/servers/packages/confirm?packageId="+this.packageId+"&regionId="+this.regionId+"&periodId="+this.periodId+"&count="+this.count)}}const h=d=>(P("data-v-67e8ee19"),d=d(),C(),d),B=["value"],D=["value"],S=["value"],q=h(()=>s("td",{class:"title"},"选择流量包规格 *",-1)),z={key:0,class:"label-group"},F=["onClick"],M={key:1,class:"red"},U=h(()=>s("td",null,"选择区域 *",-1)),E={key:0,class:"label-group"},L=["onClick"],W={key:1,class:"red"},j=h(()=>s("td",null,"选择有效期 *",-1)),A={key:0,class:"label-group"},G=["onClick"],H={key:1,class:"red"},J=h(()=>s("td",null,"流量包数量 *",-1)),K={class:"ui input"},O=h(()=>s("td",null,"价格",-1)),Q={key:0,class:"disabled"},X={key:1},Y={__name:"buy",setup(d){const e=x(new V);return(c,_)=>(o(),n(u,null,[a($,{"active-tab":"buy"}),s("form",null,[s("input",{type:"hidden",name:"packageId",value:t(e).packageId},null,8,B),s("input",{type:"hidden",name:"regionId",value:t(e).regionId},null,8,D),s("input",{type:"hidden",name:"periodId",value:t(e).periodId},null,8,S),a(T,null,{default:r(()=>[s("tbody",null,[s("tr",null,[q,s("td",null,[t(e).packages.length>0?(o(),n("div",z,[(o(!0),n(u,null,g(t(e).packages,i=>(o(),n("a",{onClick:m(I=>t(e).selectPackage(i.id),["prevent"])},[a(f,{secondary:i.id!=t(e).packageId},{default:r(()=>[p(l(i.size)+l(i.unit.toUpperCase().replace(/(.)B/,"$1iB")),1)]),_:2},1032,["secondary"])],8,F))),256))])):(o(),n("span",M,"没有流量包可供选择"))])]),s("tr",null,[U,s("td",null,[t(e).regions.length>0?(o(),n("div",E,[(o(!0),n(u,null,g(t(e).regions,i=>(o(),n("a",{class:k({disabled:!t(e).hasRegionPrice(i.id)}),onClick:m(I=>t(e).selectRegion(i.id),["prevent"])},[a(f,{secondary:!(i.id==t(e).regionId&&t(e).hasRegionPrice(i.id))},{default:r(()=>[p(l(i.name),1)]),_:2},1032,["secondary"])],10,L))),256))])):(o(),n("span",W,"没有区域可供选择"))])]),s("tr",null,[j,s("td",null,[t(e).periods.length>0?(o(),n("div",A,[(o(!0),n(u,null,g(t(e).periods,i=>(o(),n("a",{class:k({disabled:!t(e).hasPeriodPrice(i.id)}),onClick:m(I=>t(e).selectPeriod(i.id),["prevent"])},[a(f,{secondary:!(i.id==t(e).periodId&&t(e).hasPeriodPrice(i.id))},{default:r(()=>[p(l(i.count)+l(i.unitName),1)]),_:2},1032,["secondary"])],10,G))),256))])):(o(),n("span",H,"没有有效期可供选择"))])]),s("tr",null,[J,s("td",null,[s("div",K,[a(N,{name:"count",modelValue:t(e).count,"onUpdate:modelValue":_[0]||(_[0]=i=>t(e).count=i),onChange:t(e).changeCount},{default:r(()=>[(o(),n(u,null,g(20,i=>a(R,{value:i},{default:r(()=>[p(l(i),1)]),_:2},1032,["value"])),64))]),_:1},8,["modelValue","onChange"])])])]),s("tr",null,[O,s("td",null,[t(e).amount==0?(o(),n("span",Q,"没有找到对应价格")):v("",!0),t(e).amount>0?(o(),n("span",X,l(t(e).amount)+"元",1)):v("",!0)])])])]),_:1}),a(w,{disabled:t(e).amount<=0,type:"button",onClick:_[1]||(_[1]=m(i=>t(e).goNext(),["prevent"]))},{default:r(()=>[p("下一步")]),_:1},8,["disabled"])])],64))}},ye=y(Y,[["__scopeId","data-v-67e8ee19"]]);export{ye as default};
