import{_ as I,r as g,x as O,o as v,c as p,a as e,b as o,w as i,t as n,F as P,g as S,y as k,z as T,d as f,f as d,e as m,q as B,A as M,B as q,C as A,E as $}from"./index-BjjMa8ds.js";import{r as C}from"./request-DB47Z7vM.js";const E={class:"home-page"},H={class:"header"},F={class:"user-info"},L={class:"info"},J={class:"wallet-value"},R={class:"banner"},j={class:"banner-content"},G={class:"section"},K={class:"section-header"},Q={class:"vehicle-list"},U=["onClick"],W={class:"vehicle-info"},X={class:"vehicle-desc"},Y={class:"vehicle-price"},Z={class:"price"},x={class:"quick-actions"},ss={key:0,class:"section"},es={class:"order-header"},ts={class:"order-id"},os={class:"order-body"},ls={class:"vehicle-mini"},ns={class:"model"},is={class:"order-detail"},rs={class:"amount"},as={class:"order-footer"},ds={__name:"Home",setup(us){const u=g(JSON.parse(localStorage.getItem("customer_info")||"{}")),_=g([]),r=g(null),w=t=>{const s=t.purchasePrice||3e3;return Math.round(s/100)},h=t=>t?new Date(t).toLocaleDateString("zh-CN"):"-",z=async()=>{try{const t=await C.get("/vehicles");t.success&&(_.value=t.data.filter(s=>s.status==="空闲").slice(0,3))}catch{_.value=[{_id:"1",model:"黑骑士",color:"黑色",batteryType:"锂电池",purchasePrice:3500,status:"空闲"},{_id:"2",model:"高端豪车",color:"红色",batteryType:"锂电池",purchasePrice:8e3,status:"空闲"},{_id:"3",model:"电动车",color:"蓝色",batteryType:"铅酸电池",purchasePrice:2800,status:"空闲"}]}},D=async()=>{try{const t=localStorage.getItem("customer_id");if(!t)return;const s=await C.get("/orders");if(s.success){const y=s.data.find(a=>a.customer?._id===t&&(a.status==="进行中"||a.status==="待支付"));r.value=y||null}}catch{console.log("获取订单失败")}},N=()=>{$.info("续租功能开发中")},V=()=>{$.info("还车功能开发中")};return O(()=>{z(),D()}),(t,s)=>{const y=f("el-avatar"),a=f("el-button"),b=f("el-tag"),c=f("el-icon");return v(),p("div",E,[e("div",H,[e("div",F,[o(y,{size:48,style:{background:"#fff",color:"#07c160","font-weight":"bold"}},{default:i(()=>[d(n(u.value.name?.charAt(0)||"租"),1)]),_:1}),e("div",L,[e("h3",null,n(u.value.name||"loading"),1),e("p",null,"信用分："+n(u.value.creditScore||100),1)])]),e("div",{class:"wallet",onClick:s[0]||(s[0]=l=>t.$router.push("/profile"))},[s[8]||(s[8]=e("span",{class:"wallet-label"},"余额",-1)),e("span",J,"¥"+n(u.value.balance||0),1)])]),e("div",R,[e("div",j,[s[10]||(s[10]=e("h2",null,"快捷租车",-1)),s[11]||(s[11]=e("p",null,"随时随地，租你想租",-1)),o(a,{type:"warning",round:"",onClick:s[1]||(s[1]=l=>t.$router.push("/vehicles"))},{default:i(()=>[...s[9]||(s[9]=[d(" 立即租车 ",-1)])]),_:1})]),s[12]||(s[12]=e("div",{class:"banner-icon"},"🛵",-1))]),e("div",G,[e("div",K,[s[14]||(s[14]=e("h3",null,"热门车型",-1)),o(a,{link:"",type:"primary",onClick:s[2]||(s[2]=l=>t.$router.push("/vehicles"))},{default:i(()=>[...s[13]||(s[13]=[d("查看更多",-1)])]),_:1})]),e("div",Q,[(v(!0),p(P,null,S(_.value,l=>(v(),p("div",{key:l._id,class:"vehicle-card",onClick:cs=>t.$router.push(`/vehicle/${l._id}`)},[s[16]||(s[16]=e("div",{class:"vehicle-img"},"🛵",-1)),e("div",W,[e("h4",null,n(l.model),1),e("p",X,n(l.color)+" · "+n(l.batteryType),1),e("div",Y,[e("span",Z,"¥"+n(w(l))+"/天",1),o(b,{size:"small",type:"success"},{default:i(()=>[...s[15]||(s[15]=[d("空闲",-1)])]),_:1})])])],8,U))),128))])]),e("div",x,[e("div",{class:"action-item",onClick:s[3]||(s[3]=l=>t.$router.push("/orders"))},[o(c,{size:28,style:{color:"#07c160"}},{default:i(()=>[o(m(B))]),_:1}),s[17]||(s[17]=e("span",null,"我的订单",-1))]),e("div",{class:"action-item",onClick:s[4]||(s[4]=l=>t.$router.push("/profile"))},[o(c,{size:28,style:{color:"#1890ff"}},{default:i(()=>[o(m(M))]),_:1}),s[18]||(s[18]=e("span",null,"钱包",-1))]),e("div",{class:"action-item",onClick:s[5]||(s[5]=l=>t.$router.push("/profile"))},[o(c,{size:28,style:{color:"#ff6b35"}},{default:i(()=>[o(m(q))]),_:1}),s[19]||(s[19]=e("span",null,"还车点",-1))]),e("div",{class:"action-item",onClick:s[6]||(s[6]=l=>t.$router.push("/profile"))},[o(c,{size:28,style:{color:"#722ed1"}},{default:i(()=>[o(m(A))]),_:1}),s[20]||(s[20]=e("span",null,"客服",-1))])]),r.value?(v(),p("div",ss,[s[24]||(s[24]=e("div",{class:"section-header"},[e("h3",null,"当前租赁")],-1)),e("div",{class:"order-card active",onClick:s[7]||(s[7]=l=>t.$router.push("/orders"))},[e("div",es,[e("span",ts,"订单号："+n(r.value.orderNumber),1),o(b,{type:"warning"},{default:i(()=>[d(n(r.value.status),1)]),_:1})]),e("div",os,[e("div",ls,[s[21]||(s[21]=e("span",{class:"icon"},"🛵",-1)),e("span",ns,n(r.value.vehicle?.model||"电动车"),1)]),e("div",is,[e("p",null,"租车时间："+n(h(r.value.startDate)),1),e("p",null,"预计还车："+n(h(r.value.endDate)),1),e("p",rs,"应付金额：¥"+n(r.value.totalAmount),1)])]),e("div",as,[o(a,{type:"primary",size:"small",onClick:k(N,["stop"])},{default:i(()=>[...s[22]||(s[22]=[d("续租",-1)])]),_:1}),o(a,{size:"small",onClick:k(V,["stop"])},{default:i(()=>[...s[23]||(s[23]=[d("还车",-1)])]),_:1})])])])):T("",!0)])}}},fs=I(ds,[["__scopeId","data-v-7557b155"]]);export{fs as default};
