import{C as e,E as t,M as n,O as r,T as i,_ as a,a as o,b as s,f as c,g as l,k as u,l as d,m as f,o as p,s as m,t as h,w as g,x as _,y as v}from"./index-vhvNh9F8.js";var y={class:`page`},b={key:0,style:{"text-align":`center`,padding:`40px`,color:`#999`}},x={key:1,style:{"text-align":`center`,padding:`40px`,color:`#999`,"font-size":`14px`}},S=[`onClick`],C={class:`card-body`,style:{display:`flex`,gap:`10px`}},w={style:{flex:`1`,"min-width":`0`}},T={style:{"font-size":`14px`,"font-weight":`600`}},E={style:{"font-size":`12px`,color:`#999`,"margin-top":`4px`}},D={style:{"margin-top":`4px`}},O={style:{display:`inline-block`,background:`#fef0f0`,color:`var(--danger)`,padding:`2px 8px`,"border-radius":`4px`,"font-size":`12px`}},k={style:{padding:`20px`}},A={key:0,style:{display:`flex`,gap:`12px`,"margin-bottom":`16px`}},j={style:{flex:`1`,"min-width":`0`}},M={style:{"font-size":`15px`,"font-weight":`600`}},N={style:{"font-size":`12px`,color:`#999`,"margin-top":`2px`}},P={style:{"margin-bottom":`12px`}},F={style:{display:`flex`,"justify-content":`space-between`,padding:`6px 0`,"font-size":`13px`}},I={style:{color:`var(--danger)`,"font-weight":`700`}},L={key:0,style:{display:`flex`,"justify-content":`space-between`,padding:`6px 0`,"font-size":`13px`}},R={style:{color:`#52c41a`,"font-weight":`700`}},z={key:1,style:{display:`flex`,"justify-content":`space-between`,padding:`6px 0`,"font-size":`13px`}},B={style:{color:`#999`}},V={style:{"margin-bottom":`12px`}},H=m({__name:`Presale`,setup(m){let H=d(),U=r(localStorage.getItem(`token`)||``),W=r([]),G=r(!1),K=r(!1),q=r(null),J=r(1),Y=r(!1);function X(e){q.value=e,J.value=1,K.value=!0}async function Z(){if(!U.value){H.push(`/login`);return}let e=q.value;if(e){Y.value=!0;try{let t=await o.post(`/presale/order`,{presale_id:e.id,product_id:e.product_id,quantity:J.value},{headers:{Authorization:`Bearer `+U.value}});t.code===0?(alert(`定金支付成功！`),K.value=!1):alert(t.message||`操作失败`)}catch{alert(`网络错误`)}Y.value=!1}}return _(async()=>{G.value=!0;try{let e=await o.get(`/presale/list`);e.code===0&&(W.value=e.data.list||[])}catch{}G.value=!1}),(r,o)=>{let d=i(`van-image`),m=i(`van-stepper`),_=i(`van-button`),Q=i(`van-action-sheet`);return e(),a(`div`,y,[s(p,{title:`预售活动`,onBack:o[0]||=e=>u(H).push(`/`)}),G.value?(e(),a(`div`,b,`加载中...`)):W.value.length===0?(e(),a(`div`,x,`暂无预售活动`)):l(``,!0),(e(!0),a(c,null,g(W.value,r=>(e(),a(`div`,{key:r.id,class:`card`,onClick:e=>X(r)},[f(`div`,C,[s(d,{src:r.product_image,style:{width:`80px`,height:`80px`,"border-radius":`6px`,"object-fit":`cover`,"flex-shrink":`0`},"lazy-load":``},{error:t(()=>[...o[3]||=[f(`div`,{class:`img-placeholder`,style:{width:`80px`,height:`80px`,"border-radius":`6px`,"font-size":`16px`}},`📷`,-1)]]),_:1},8,[`src`]),f(`div`,w,[f(`div`,T,n(r.name),1),f(`div`,E,n(r.product_name),1),f(`div`,D,[f(`span`,O,[v(` 定金 ¥`+n(u(h)(r.deposit))+` `,1),r.deposit_expand>0?(e(),a(c,{key:0},[v(`(膨胀抵 ¥`+n(u(h)(r.deposit_expand))+`)`,1)],64)):l(``,!0)])])])])],8,S))),128)),s(Q,{show:K.value,"onUpdate:show":o[2]||=e=>K.value=e,title:`预售详情`},{default:t(()=>[f(`div`,k,[q.value?(e(),a(`div`,A,[s(d,{src:q.value.product_image,style:{width:`72px`,height:`72px`,"border-radius":`6px`,"object-fit":`cover`,"flex-shrink":`0`},"lazy-load":``},{error:t(()=>[...o[4]||=[f(`div`,{class:`img-placeholder`,style:{width:`72px`,height:`72px`,"border-radius":`6px`,"font-size":`14px`}},`📷`,-1)]]),_:1},8,[`src`]),f(`div`,j,[f(`div`,M,n(q.value.name),1),f(`div`,N,n(q.value.product_name),1)])])):l(``,!0),f(`div`,P,[f(`div`,F,[o[5]||=f(`span`,{style:{color:`#666`}},`定金`,-1),f(`span`,I,`¥`+n(u(h)(q.value?q.value.deposit:0)),1)]),q.value&&q.value.deposit_expand>0?(e(),a(`div`,L,[o[6]||=f(`span`,{style:{color:`#666`}},`定金膨胀`,-1),f(`span`,R,`抵 ¥`+n(u(h)(q.value.deposit_expand)),1)])):l(``,!0),q.value?(e(),a(`div`,z,[o[7]||=f(`span`,{style:{color:`#666`}},`预计发货`,-1),f(`span`,B,n(q.value.delivery_time||`待定`),1)])):l(``,!0)]),f(`div`,V,[o[8]||=f(`div`,{style:{"font-size":`13px`,color:`#666`,"margin-bottom":`4px`}},`购买数量`,-1),s(m,{modelValue:J.value,"onUpdate:modelValue":o[1]||=e=>J.value=e,min:`1`,max:(q.value?.total_stock||99)>0?q.value.total_stock:99,size:`28`},null,8,[`modelValue`,`max`])]),s(_,{round:``,block:``,class:`primary-btn`,style:{height:`44px`},onClick:Z,loading:Y.value,disabled:!U.value},{default:t(()=>[v(` 支付定金 ¥`+n(u(h)((q.value?q.value.deposit:0)*J.value)),1)]),_:1},8,[`loading`,`disabled`])])]),_:1},8,[`show`])])}}},[[`__scopeId`,`data-v-3a65d720`]]);export{H as default};