import{c as tt,b as h,t as f,n as I,d as U,r as O,e as v,o as G,aC as et,w,a5 as st,a,g as L,v as T,h as M,H as J,br as q,Y as z,z as at,bs as ot,p as x,a1 as it,bP as lt,bR as nt,k as ut,b0 as ct,A as N,W as dt,C as rt,a3 as mt}from"./index-869d77fb.js";import{u as ht}from"./student-register-store-a294a38a.js";import{C as V}from"./index-1c6c2ec0.js";import{I as $}from"./index-e76f2a88.js";import{R as ft,a as gt}from"./index-62365511.js";import{T as St}from"./index-70d6770d.js";const[bt,y]=tt("stepper"),kt=200,_=(t,s)=>String(t)===String(s),pt={min:h(1),max:h(1/0),name:h(""),step:h(1),theme:String,integer:Boolean,disabled:Boolean,showPlus:f,showMinus:f,showInput:f,longPress:f,autoFixed:f,allowEmpty:Boolean,modelValue:I,inputWidth:I,buttonSize:I,placeholder:String,disablePlus:Boolean,disableMinus:Boolean,disableInput:Boolean,beforeChange:Function,defaultValue:h(1),decimalLength:I};var It=U({name:bt,props:pt,emits:["plus","blur","minus","focus","change","overlimit","update:modelValue"],setup(t,{emit:s}){const i=(e,n=!0)=>{const{min:d,max:k,allowEmpty:r,decimalLength:p}=t;return r&&e===""||(e=q(String(e),!t.integer),e=e===""?0:+e,e=Number.isNaN(e)?+d:e,e=n?Math.max(Math.min(+k,e),+d):e,z(p)&&(e=e.toFixed(+p))),e},o=()=>{var e;const n=(e=t.modelValue)!=null?e:t.defaultValue,d=i(n);return _(d,t.modelValue)||s("update:modelValue",d),d};let u;const m=O(),l=O(o()),g=v(()=>t.disabled||t.disableMinus||+l.value<=+t.min),S=v(()=>t.disabled||t.disablePlus||+l.value>=+t.max),W=v(()=>({width:G(t.inputWidth),height:G(t.buttonSize)})),B=v(()=>et(t.buttonSize)),H=()=>{const e=i(l.value);_(e,l.value)||(l.value=e)},D=e=>{t.beforeChange?it(t.beforeChange,{args:[e],done(){l.value=e}}):l.value=e},C=()=>{if(u==="plus"&&S.value||u==="minus"&&g.value){s("overlimit",u);return}const e=u==="minus"?-t.step:+t.step,n=i(lt(+l.value,e));D(n),s(u)},K=e=>{const n=e.target,{value:d}=n,{decimalLength:k}=t;let r=q(String(d),!t.integer);if(z(k)&&r.includes(".")){const A=r.split(".");r=`${A[0]}.${A[1].slice(0,+k)}`}t.beforeChange?n.value=String(l.value):_(d,r)||(n.value=r);const p=r===String(+r);D(p?+r:r)},Y=e=>{var n;t.disableInput?(n=m.value)==null||n.blur():s("focus",e)},Q=e=>{const n=e.target,d=i(n.value,t.autoFixed);n.value=String(d),l.value=d,at(()=>{s("blur",e),ot()})};let P,b;const E=()=>{b=setTimeout(()=>{C(),E()},kt)},X=()=>{t.longPress&&(P=!1,clearTimeout(b),b=setTimeout(()=>{P=!0,C(),E()},nt))},F=e=>{t.longPress&&(clearTimeout(b),P&&x(e))},Z=e=>{t.disableInput&&x(e)},R=e=>({onClick:n=>{x(n),u=e,C()},onTouchstartPassive:()=>{u=e,X()},onTouchend:F,onTouchcancel:F});return w(()=>[t.max,t.min,t.integer,t.decimalLength],H),w(()=>t.modelValue,e=>{_(e,l.value)||(l.value=i(e))}),w(l,e=>{s("update:modelValue",e),s("change",e,{name:t.name})}),st(()=>t.modelValue),()=>a("div",{role:"group",class:y([t.theme])},[L(a("button",M({type:"button",style:B.value,class:[y("minus",{disabled:g.value}),{[J]:!g.value}],"aria-disabled":g.value||void 0},R("minus")),null),[[T,t.showMinus]]),L(a("input",{ref:m,type:t.integer?"tel":"text",role:"spinbutton",class:y("input"),value:l.value,style:W.value,disabled:t.disabled,readonly:t.disableInput,inputmode:t.integer?"numeric":"decimal",placeholder:t.placeholder,"aria-valuemax":t.max,"aria-valuemin":t.min,"aria-valuenow":l.value,onBlur:Q,onInput:K,onFocus:Y,onMousedown:Z},null),[[T,t.showInput]]),L(a("button",M({type:"button",style:B.value,class:[y("plus",{disabled:S.value}),{[J]:!S.value}],"aria-disabled":S.value||void 0},R("plus")),null),[[T,t.showPlus]])])}});const vt=ut(It),yt=""+new URL("icon-sell-out-437e8d6c.png",import.meta.url).href,_t="_addGoodsCart_16cde_1",Ct="_addCartBtn_16cde_25",Pt="_goodsSection_16cde_33",wt="_sellOut_16cde_40",Lt="_goodsImg_16cde_52",Tt="_goodsPrice_16cde_58",xt="_goodsStore_16cde_67",Nt="_title_16cde_72",Vt="_radio_16cde_77",c={addGoodsCart:_t,addCartBtn:Ct,goodsSection:Pt,sellOut:wt,goodsImg:Lt,goodsPrice:Tt,goodsStore:xt,title:Nt,"radio-group":"_radio-group_16cde_77",radio:Vt};function Bt(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!mt(t)}const j=ht(),Gt=U({name:"add-goods-cart",props:{show:{type:Boolean,default:!1},item:{type:Object,default:{}},defaultRadio:{type:Number,default:0},showType:{type:String,default:"cart"},onClose:{type:Function,default:()=>{}}},watch:{show(t){t&&(this.totalData={},this.total=1,this.radio="",this.setList())}},data(){return{radio:"",total:1,totalData:{},skuStockList:[]}},computed:{selectItem(){const t=this.radio,s=this.skuStockList.find(i=>i.id==t);if(s){let i=s.stock-s.lockStock;return{...s,stock:i}}return{stock:0}}},mounted(){this.setList()},methods:{setList(){let t=[];const s=JSON.parse(JSON.stringify(this.item));if(Array.isArray(s.skuStockList)&&(t=s.skuStockList.map(o=>{if(o.pic=o.pic||s.pic,o.cartNum=0,o.spData){const u=JSON.parse(o.spData);let m="";u.forEach(l=>{m+=`${l.value}`}),o.spDataJson=m}else o.spDataJson="默认";return o.lockStock=o.lockStock>0?o.lockStock:0,{...o}})),!t.length)return t;let i=0;if(this.defaultRadio){let o=t.findIndex(u=>u.id==this.defaultRadio);i=o>-1?o:0}this.radio=t[i].id,this.skuStockList=t},async onAddCart(){const t=this.selectItem,s=this.item,i={pic:s.pic,name:s.name,brandName:s.brandName,productSn:s.productSn,price:t.price,originalPrice:s.originalPrice,productSkuId:t.id,stock:t.stock,quantity:this.total,productId:s.id,spDataJson:t.spDataJson,hidden:this.showType==="cart"?0:1,promoterId:this.$route.query.promoterId?this.$route.query.promoterId:void 0};try{let o=!1;j.getGoods.forEach(u=>{u.productId===i.productId&&u.productSkuId===i.productSkuId&&(o=!0,u.quantity+=i.quantity)}),o||j.setGoods(i),ct("添加成功"),this.onClose()}catch(o){}},setProductStock(t){for(let s=0;sa("div",{class:c.goodsSection},[a($,{src:this.selectItem.pic,class:c.goodsImg,fit:"cover"},null),this.selectItem.stock<=0&&a("div",{class:c.sellOut},[a($,{src:yt,fit:"cover",class:c.sellOutImg},null)])]),title:()=>a("div",{class:c.goodsInfo},[a("p",{class:c.goodsPrice},[a("span",null,[N("¥")]),dt(this.selectItem.price)]),a("p",{class:c.goodsStore},[N("库存:"),this.selectItem.stock])])}),a(V,null,{title:()=>a("div",{class:c.title},[N("规格")]),label:()=>{let t;return a(ft,{class:c["radio-group"],modelValue:this.radio},Bt(t=this.skuStockList.map(s=>{const i=s.id===this.radio,o=i?"primary":"default";return a(gt,{class:c.radio,name:s.id,onClick:()=>{this.radio!=s.id&&(this.radio=s.id)}},{default:()=>[a(St,{size:"large",plain:i,type:o},{default:()=>[s.spDataJson]})]})}))?t:{default:()=>[t]})}}),a(V,{title:"购买数量",style:{margin:"12px 0"},border:!1,titleClass:c.title,center:!0},{default:()=>[a(vt,{modelValue:this.total,"onUpdate:modelValue":t=>this.total=t,max:this.selectItem.stock>200?200:this.selectItem.stock,min:1,disabled:this.selectItem.stock<=0,integer:!0},null)]}),a("div",{class:["btnGroup"],style:{marginBottom:"8px"}},[a(rt,{block:!0,type:"primary",text:"确定",class:c.addCartBtn,disabled:this.selectItem.stock<=0,onClick:()=>this.onAddCart()},null)])])}});export{Gt as A,yt as i};