var e=(e,l,a)=>new Promise((o,t)=>{var d=e=>{try{u(a.next(e))}catch(l){t(l)}},n=e=>{try{u(a.throw(e))}catch(l){t(l)}},u=e=>e.done?o(e.value):Promise.resolve(e.value).then(d,n);u((a=a.apply(e,l)).next())});import{s as l,a7 as a,S as o,A as t,e as d,U as n,E as u}from"./vendor-element-B74pkaZM.js";import{g as s}from"./common-BaxseTTS.js";import{s as r,b as i}from"./order-BI4-hkQ2.js";import{C as c}from"./index-C27pG-JD.js";import{t as m,r as v,a2 as p,U as f,E as _,F as b,x as y,O as h,u as g,B as V,K as x}from"./vendor-core-k7kcNcJz.js";const w={class:"flex gap-2 w-full"},k=m({__name:"ReceiptConfirmDialog",props:{modelValue:{type:Boolean},order:{}},emits:["update:modelValue","success"],setup(m,{emit:k}){const j=m,U=k,C=v(!1),S=v(!1),A=v(!1),q=v(0),B=v(""),E=v(!1),O=p({trade_no:"",mobile:"",code:""}),P=e=>{if(!e)return"";if("object"==typeof e){const l=(null==e?void 0:e.phone)||(null==e?void 0:e.mobile)||(null==e?void 0:e.tel)||(null==e?void 0:e.contact_phone);return l?String(l):""}const l=String(e).trim();if(!l)return"";try{const e=JSON.parse(l),a=P(e);if(a)return a}catch(o){const e=l.match(/1(?:3\d|4[5-9]|5\d|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}/);if(e)return e[0]}const a=l.match(/1(?:3\d|4[5-9]|5\d|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}/);return a?a[0]:l},D=()=>{B.value="",E.value=!1,q.value+=1},F=()=>{const e=j.order;O.trade_no=(null==e?void 0:e.trade_no)||"",O.mobile=(null==e?void 0:e.receipt_mobile_masked)||P(null==e?void 0:e.contact),O.code="",D()},J=e=>{B.value=(null==e?void 0:e.key)||(null==e?void 0:e.captcha_key)||e||"",E.value=!!B.value},K=()=>e(null,null,function*(){if(O.trade_no)if(B.value){S.value=!0;try{const e=yield r({trade_no:O.trade_no,captcha_key:B.value});O.mobile=(null==e?void 0:e.mobile)||O.mobile,u.success("验证码已发送"),D()}catch(e){u.error(e.message||"验证码发送失败")}finally{S.value=!1}}else u.warning("请先完成滑块验证");else u.warning("订单号不能为空")}),N=()=>e(null,null,function*(){if(O.trade_no)if(O.code){A.value=!0;try{yield i({trade_no:O.trade_no,code:O.code}),u.success("签收成功"),C.value=!1,U("success")}catch(e){u.error(e.message||"签收失败")}finally{A.value=!1}}else u.warning("请输入短信验证码");else u.warning("订单号不能为空")});return f(()=>j.modelValue,e=>{C.value=e,e&&F()},{immediate:!0}),f(C,e=>{U("update:modelValue",e)}),f(()=>j.order,()=>{C.value&&F()}),(e,u)=>{const r=a,i=t,m=o,v=d,p=n,f=l;return y(),_(f,{modelValue:C.value,"onUpdate:modelValue":u[4]||(u[4]=e=>C.value=e),title:"确认签收",width:"420px","destroy-on-close":"","append-to-body":""},{footer:b(()=>[h(v,{onClick:u[3]||(u[3]=e=>C.value=!1)},{default:b(()=>[...u[6]||(u[6]=[x("取消",-1)])]),_:1}),h(v,{type:"success",onClick:N,loading:A.value},{default:b(()=>[...u[7]||(u[7]=[x("确认签收",-1)])]),_:1},8,["loading"])]),default:b(()=>[h(r,{title:"确认签收后订单将完成，商家冻结收入会转为可用余额。请确认已收到商品或服务后再操作。",type:"warning",closable:!1,class:"mb-4"}),h(p,{model:O,"label-width":"90px"},{default:b(()=>[h(m,{label:"订单号"},{default:b(()=>[h(i,{modelValue:O.trade_no,"onUpdate:modelValue":u[0]||(u[0]=e=>O.trade_no=e),disabled:""},null,8,["modelValue"])]),_:1}),h(m,{label:"收货手机"},{default:b(()=>[h(i,{modelValue:O.mobile,"onUpdate:modelValue":u[1]||(u[1]=e=>O.mobile=e),disabled:""},null,8,["modelValue"])]),_:1}),h(m,{label:"滑块验证",required:""},{default:b(()=>[(y(),_(c,{key:q.value,captchaApi:g(s),text:"请按住滑块拖动完成验证",successText:"验证通过",onSuccess:J},null,8,["captchaApi"]))]),_:1}),h(m,{label:"短信验证码",required:""},{default:b(()=>[V("div",w,[h(i,{modelValue:O.code,"onUpdate:modelValue":u[2]||(u[2]=e=>O.code=e),placeholder:"请输入验证码",maxlength:"6"},null,8,["modelValue"]),h(v,{loading:S.value,disabled:!E.value,onClick:K},{default:b(()=>[...u[5]||(u[5]=[x(" 获取验证码 ",-1)])]),_:1},8,["loading","disabled"])])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])}}});export{k as _};
