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,j as u,k 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`,"font-size":`14px`}},x={class:`card-body`},S={style:{display:`flex`,"justify-content":`space-between`,"font-size":`12px`,color:`#999`}},C={style:{display:`flex`,gap:`10px`,"align-items":`center`,"margin-top":`8px`}},w={style:{flex:`1`,"min-width":`0`}},T={style:{"font-size":`13px`,"font-weight":`500`}},E={style:{"font-size":`12px`,color:`#666`,"margin-top":`2px`}},D={style:{"text-align":`right`}},O={style:{color:`var(--danger)`,"font-weight":`700`,"font-size":`14px`}},k={key:0,style:{"margin-top":`8px`}},A=m({__name:`MyPresale`,setup(m){let A=r(localStorage.getItem(`token`)||``),j=r([]);async function M(e){if(!e._paying){e._paying=!0;try{let t=await o.post(`/presale/order/`+e.order_no+`/pay-final`,{},{headers:{Authorization:`Bearer `+A.value}});t.code===0?(alert(`尾款支付成功`),e.status=`final_paid`):alert(t.message||`支付失败`)}catch{alert(`网络错误`)}e._paying=!1}}return _(async()=>{if(A.value)try{let e=await o.get(`/presale/orders`,{headers:{Authorization:`Bearer `+A.value}});e.code===0&&(j.value=e.data.list||[])}catch{}}),(r,o)=>{let m=i(`van-image`),_=i(`van-button`);return e(),a(`div`,y,[s(p,{title:`我的预售`,onBack:o[0]||=e=>r.router.push(`/user`)}),j.value.length===0?(e(),a(`div`,b,`暂无预售订单`)):l(``,!0),(e(!0),a(c,null,g(j.value,r=>(e(),a(`div`,{key:r.order_no,class:`card`},[f(`div`,x,[f(`div`,S,[f(`span`,null,n(r.created_at),1),f(`span`,{style:u({color:r.status===`final_paid`?`#52c41a`:r.status===`deposit_paid`?`#e6a23c`:`#999`})},n(r.status===`final_paid`?`已付尾款`:r.status===`deposit_paid`?`已付定金`:`已取消`),5)]),f(`div`,C,[s(m,{src:r.product_image,style:{width:`50px`,height:`50px`,"border-radius":`4px`,"object-fit":`cover`,"flex-shrink":`0`},"lazy-load":``},{error:t(()=>[...o[1]||=[f(`div`,{class:`img-placeholder`,style:{width:`50px`,height:`50px`,"border-radius":`4px`,"font-size":`12px`}},`📷`,-1)]]),_:1},8,[`src`]),f(`div`,w,[f(`div`,T,n(r.product_name),1),f(`div`,E,[v(`定金¥`+n(d(h)(r.deposit))+` `,1),r.deposit_expand>0?(e(),a(c,{key:0},[v(`(膨胀后¥`+n(d(h)(r.deposit_expand))+`)`,1)],64)):l(``,!0)])]),f(`div`,D,[f(`div`,O,`¥`+n(d(h)(r.total_amount)),1)])]),r.status===`deposit_paid`?(e(),a(`div`,k,[s(_,{round:``,size:`small`,class:`primary-btn`,onClick:e=>M(r),loading:r._paying},{default:t(()=>[v(`支付尾款 ¥`+n(d(h)(r.final_amount)),1)]),_:2},1032,[`onClick`,`loading`])])):l(``,!0)])]))),128))])}}},[[`__scopeId`,`data-v-9b3a0b73`]]);export{A as default};