2 行
3.6 KiB
JavaScript
可执行文件
2 行
3.6 KiB
JavaScript
可执行文件
import{_ as e,H as t,r as a,a as s,I as o,o as r,a9 as l,a5 as i,Z as n,a6 as c,ao as d,b as u,c as p,d as f,w as g,y as _,f as m,i as v,j as h,m as y,n as w,q as x,x as b,ap as I,L as O,K as j,N as k,A as S}from"./index-fL1SRM2N.js";import{O as $}from"./OrderHeader.epSxwAjc.js";import{G as z}from"./GoodsList.BAEnO5er.js";const C=e({__name:"arrive-store",setup(e){const{proxy:C}=_(),D=t(),G=a(""),H=s({}),L=a(!1),N=a(!1);o(()=>D.getters["order/getOrderStatusText"]);const T=o(()=>{const e=+H.order_status;return 7!==e&&8!==e});r(()=>{const e=l(),t=e[e.length-1].options||{};G.value=t.orderId,A()});const q=e=>D.dispatch("order/updateOrderStatus",e),A=async()=>{try{i({title:"加载中..."});const e=await C.$api.order.getOrderDetail({order_id:G.value});1===e.code&&(Object.assign(H,e.data),1===+H.order_status&&await K())}catch(e){console.error("获取订单详情失败:",e),n({title:"获取订单信息失败",icon:"none"})}finally{c()}},K=async()=>{try{console.log("自动更新订单状态:已接单 -> 前往商家");const e=await Z().catch(()=>({latitude:0,longitude:0})),t=await q({orderId:G.value,status:"to_merchant",lat:e.latitude,lng:e.longitude});1===t.code?(H.order_status=2,H.status_text="前往商家",console.log("订单状态已自动更新为:前往商家")):console.warn("自动更新订单状态失败:",t.msg)}catch(e){console.error("自动更新订单状态失败:",e)}},M=async()=>{if(T.value)try{L.value=!0;const e=await Z();1===(await q({orderId:G.value,status:"arrived",params:{arrive_time:(new Date).toISOString(),arrive_latitude:e.latitude,arrive_longitude:e.longitude}})).code&&(n({title:"到店确认成功",icon:"success"}),setTimeout(()=>{I({url:`/pages/order/pickup?orderId=${G.value}`})},1500))}catch(e){console.error("确认到店失败:",e),n({title:"操作失败,请重试",icon:"none"})}finally{L.value=!1}else n({title:"当前订单状态不允许确认到店",icon:"none"})},P=()=>{O({url:`/pages/order/report-slow?orderId=${G.value}`})},R=()=>{H.merchant_phone?j({title:"联系商家",content:`是否拨打商家电话:${H.merchant_phone}?`,success:e=>{e.confirm&&k({phoneNumber:H.merchant_phone})}}):n({title:"商家电话不可用",icon:"none"})},Z=()=>new Promise((e,t)=>{d({type:"gcj02",success:e,fail:t})});return(e,t)=>{const a=u(p("u-icon"),m),s=S,o=v,r=u(p("u-button"),h);return y(),f(o,{class:"arrive-store-container"},{default:g(()=>[w($,{"order-info":H,"show-contact":!0,onCallMerchant:R},null,8,["order-info"]),w(z,{"goods-list":H.goods_list||[],"order-info":H,title:"商品清单",checkable:!1},null,8,["goods-list","order-info"]),w(o,{class:"tips-card"},{default:g(()=>[w(o,{class:"tips-header"},{default:g(()=>[w(a,{name:"info-circle",size:"16",color:"#909399"}),w(s,{class:"tips-title"},{default:g(()=>[x("操作提示")]),_:1})]),_:1}),w(o,{class:"tips-content"},{default:g(()=>[w(s,{class:"tips-text"},{default:g(()=>[x('1. 到达商家后,请点击"确认到店"按钮')]),_:1}),w(s,{class:"tips-text"},{default:g(()=>[x('2. 如商家出餐较慢,可直接点击"上报出餐慢"(无需先确认到店)')]),_:1}),w(s,{class:"tips-text"},{default:g(()=>[x("3. 取餐时请核对商品清单和备注信息")]),_:1})]),_:1})]),_:1}),w(o,{class:"bottom-actions"},{default:g(()=>[w(r,{type:"warning",size:"large",onClick:P,loading:N.value,"custom-style":{flex:1,marginRight:"10px"}},{default:g(()=>[x(" 上报出餐慢 ")]),_:1},8,["loading"]),w(r,{type:T.value?"primary":"error",size:"large",onClick:M,loading:L.value,disabled:!T.value,"custom-style":{flex:2}},{default:g(()=>[x(b(T.value?"确认到店":"订单异常"),1)]),_:1},8,["type","loading","disabled"])]),_:1})]),_:1})}}},[["__scopeId","data-v-95f53185"]]);export{C as default};
|