import{C as e,D as t,E as n,M as r,O as i,T as a,_ as o,a as s,b as c,c as l,f as u,g as d,h as f,k as p,l as m,m as h,o as g,s as _,w as v,x as y,y as b}from"./index-vhvNh9F8.js";var x={class:`page`},S={class:`card`,style:{"margin-top":`0`,"border-radius":`0`}},C={class:`card-body`},w={key:0,style:{"font-size":`14px`,"font-weight":`600`,"margin-bottom":`8px`}},T={style:{flex:`1`,"font-size":`13px`,overflow:`hidden`,"text-overflow":`ellipsis`,"white-space":`nowrap`}},E={style:{padding:`16px`}},D={style:{display:`flex`,"align-items":`center`,gap:`8px`,"margin-bottom":`12px`}},O=_({__name:`ReviewList`,setup(_){let O=l(),k=m(),A=i(localStorage.getItem(`token`)||``),j=i(null),M=i(!1),N=t({rating:5,content:``}),P=i(null),F=i(!1);function I(e){P.value=e,N.rating=5,N.content=``,M.value=!0}async function L(){if(!N.content.trim()){alert(`请填写评价内容`);return}F.value=!0;try{let e=await s.post(`/order/review`,{order_no:j.value?.order_no,product_id:P.value?.product_id||P.value?.id,rating:N.rating,content:N.content},{headers:{Authorization:`Bearer `+A.value}});e.code===0?(alert(`评价成功`),M.value=!1,P.value._reviewed=!0):alert(e.message||`评价提交失败`)}catch{alert(`网络错误`)}F.value=!1}return y(async()=>{let e=O.query.order_no;if(!(!e||!A.value))try{let t=await s.get(`/order/list`,{params:{order_no:e},headers:{Authorization:`Bearer `+A.value}});if(t.code===0){let e=t.data.list||[];e.length>0&&(j.value=e[0])}}catch{}}),(t,i)=>{let s=a(`van-image`),l=a(`van-button`),m=a(`van-empty`),_=a(`van-rate`),y=a(`van-field`),O=a(`van-popup`);return e(),o(`div`,x,[c(g,{title:`商品评价`,onBack:i[0]||=e=>p(k).push(`/orders`)}),h(`div`,S,[h(`div`,C,[j.value?(e(),o(`div`,w,`评价订单: `+r(j.value.order_no),1)):d(``,!0),t.i._reviewed?d(``,!0):(e(!0),o(u,{key:1},v(j.value?.items,t=>(e(),o(`div`,{key:t.id,style:{display:`flex`,gap:`10px`,"align-items":`center`,"margin-bottom":`8px`,"padding-bottom":`8px`,"border-bottom":`1px solid #f0f0f0`}},[c(s,{src:t.image,style:{width:`50px`,height:`50px`,"border-radius":`4px`,"flex-shrink":`0`},"lazy-load":``},{error:n(()=>[...i[4]||=[h(`div`,{class:`img-placeholder`,style:{width:`50px`,height:`50px`,"border-radius":`4px`,"font-size":`12px`}},`📷`,-1)]]),_:1},8,[`src`]),h(`div`,T,r(t.product_name),1),c(l,{size:`mini`,round:``,class:`primary-btn`,onClick:e=>I(t)},{default:n(()=>[...i[5]||=[b(`评价`,-1)]]),_:1},8,[`onClick`])]))),128))])]),j.value&&j.value.items.every(e=>e._reviewed)?(e(),f(m,{key:0,description:`该订单商品已评价完毕`})):d(``,!0),c(O,{show:M.value,"onUpdate:show":i[3]||=e=>M.value=e,position:`bottom`,round:``,style:{maxHeight:`70vh`}},{default:n(()=>[i[8]||=h(`div`,{style:{padding:`16px 16px 8px`,"font-size":`16px`,"font-weight":`600`,"border-bottom":`1px solid #eee`}},`评价商品`,-1),h(`div`,E,[h(`div`,D,[i[6]||=h(`span`,{style:{"font-size":`13px`,color:`#666`}},`评分:`,-1),c(_,{modelValue:N.rating,"onUpdate:modelValue":i[1]||=e=>N.rating=e,size:22,color:`#fa0`,"void-color":`#eee`},null,8,[`modelValue`])]),c(y,{modelValue:N.content,"onUpdate:modelValue":i[2]||=e=>N.content=e,type:`textarea`,rows:`4`,placeholder:`分享您的使用体验...`},null,8,[`modelValue`]),c(l,{round:``,block:``,class:`primary-btn`,style:{"margin-top":`16px`},onClick:L,loading:F.value},{default:n(()=>[...i[7]||=[b(`提交评价`,-1)]]),_:1},8,[`loading`])])]),_:1},8,[`show`])])}}},[[`__scopeId`,`data-v-e82c9320`]]);export{O as default};