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,l as f,m as p,o as m,s 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`,overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}},E={style:{"font-size":`12px`,color:`#999`,"margin-top":`2px`}},D={key:0,style:{display:`flex`,gap:`8px`,"justify-content":`flex-end`,"margin-top":`8px`}},O=h({__name:`ExchangeOrders`,setup(h){let O=f(),k=r(localStorage.getItem(`token`)||``),A=r([]);function j(e){return{pending:`待处理`,shipped:`已发货`,received:`已收货`,cancelled:`已取消`}[e]||e}async function M(){if(k.value)try{let e=await o.get(`/exchange/orders`,{headers:{Authorization:`Bearer `+k.value}});e.code===0&&(A.value=e.data||[])}catch{}}async function N(e){try{let t=await o.post(`/exchange/orders/`+e.id+`/cancel`,{},{headers:{Authorization:`Bearer `+k.value}});t.code===0?(alert(`已取消`),await M()):alert(t.message||`取消失败`)}catch{alert(`操作失败`)}}return _(()=>{M()}),(r,o)=>{let f=i(`van-image`),h=i(`van-button`);return e(),a(`div`,y,[s(m,{title:`兑换记录`,onBack:o[0]||=e=>d(O).push(`/exchange`)}),A.value.length===0?(e(),a(`div`,b,`暂无兑换记录`)):l(``,!0),(e(!0),a(c,null,g(A.value,r=>(e(),a(`div`,{class:`card`,key:r.id},[p(`div`,x,[p(`div`,S,[p(`span`,null,n(r.created_at),1),p(`span`,{style:u({color:r.status===`cancelled`?`#999`:r.status===`pending`?`#e6a23c`:`#52c41a`})},n(j(r.status)),5)]),p(`div`,C,[s(f,{src:r.product_image,style:{width:`50px`,height:`50px`,"border-radius":`6px`,"object-fit":`cover`,"flex-shrink":`0`},"lazy-load":``},{error:t(()=>[...o[1]||=[p(`div`,{class:`img-placeholder`,style:{width:`50px`,height:`50px`,"border-radius":`6px`,"font-size":`12px`}},`📷`,-1)]]),_:1},8,[`src`]),p(`div`,w,[p(`div`,T,n(r.product_name),1),p(`div`,E,`消耗 `+n(r.points*r.quantity)+` 积分 x`+n(r.quantity),1)])]),r.status===`pending`?(e(),a(`div`,D,[s(h,{plain:``,size:`mini`,round:``,type:`danger`,onClick:e=>N(r)},{default:t(()=>[...o[2]||=[v(`取消兑换`,-1)]]),_:1},8,[`onClick`])])):l(``,!0)])]))),128))])}}},[[`__scopeId`,`data-v-2ee06bbe`]]);export{O as default};