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{X as l,y as a,B as o,C as t,e as d,A as n,E as u}from"./vendor-element-DupX9wXy.js";import{g as r}from"./common-CeP9vaNw.js";import{s,c as i}from"./order-CaZ0nNV2.js";import{C as c}from"./index-Di6bCNmb.js";import{q as m,r as v,a2 as p,S as f,D as _,E as b,v as y,M as h,u as g,A as V,J as w}from"./vendor-core-Di0OO4oJ.js";const x={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,C=k,S=v(!1),A=v(!1),U=v(!1),q=v(0),B=v(""),D=v(!1),E=p({trade_no:"",mobile:"",code:""}),J=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=J(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},P=()=>{B.value="",D.value=!1,q.value+=1},M=()=>{const e=j.order;E.trade_no=(null==e?void 0:e.trade_no)||"",E.mobile=(null==e?void 0:e.receipt_mobile_masked)||J(null==e?void 0:e.contact),E.code="",P()},N=e=>{B.value=(null==e?void 0:e.key)||(null==e?void 0:e.captcha_key)||e||"",D.value=!!B.value},O=()=>e(null,null,function*(){if(E.trade_no)if(B.value){A.value=!0;try{const e=yield s({trade_no:E.trade_no,captcha_key:B.value});E.mobile=(null==e?void 0:e.mobile)||E.mobile,u.success("验证码已发送"),P()}catch(e){u.error(e.message||"验证码发送失败")}finally{A.value=!1}}else u.warning("请先完成滑块验证");else u.warning("订单号不能为空")}),R=()=>e(null,null,function*(){if(E.trade_no)if(E.code){U.value=!0;try{yield i({trade_no:E.trade_no,code:E.code}),u.success("签收成功"),S.value=!1,C("success")}catch(e){u.error(e.message||"签收失败")}finally{U.value=!1}}else u.warning("请输入短信验证码");else u.warning("订单号不能为空")});return f(()=>j.modelValue,e=>{S.value=e,e&&M()},{immediate:!0}),f(S,e=>{C("update:modelValue",e)}),f(()=>j.order,()=>{S.value&&M()}),(e,u)=>{const s=a,i=t,m=o,v=d,p=n,f=l;return y(),_(f,{modelValue:S.value,"onUpdate:modelValue":u[4]||(u[4]=e=>S.value=e),title:"确认签收",width:"420px","destroy-on-close":"","append-to-body":""},{footer:b(()=>[h(v,{onClick:u[3]||(u[3]=e=>S.value=!1)},{default:b(()=>[...u[6]||(u[6]=[w("取消",-1)])]),_:1}),h(v,{type:"success",onClick:R,loading:U.value},{default:b(()=>[...u[7]||(u[7]=[w("确认签收",-1)])]),_:1},8,["loading"])]),default:b(()=>[h(s,{title:"确认签收后订单将完成，商家冻结收入会转为可用余额。请确认已收到商品或服务后再操作。",type:"warning",closable:!1,class:"mb-4"}),h(p,{model:E,"label-width":"90px"},{default:b(()=>[h(m,{label:"订单号"},{default:b(()=>[h(i,{modelValue:E.trade_no,"onUpdate:modelValue":u[0]||(u[0]=e=>E.trade_no=e),disabled:""},null,8,["modelValue"])]),_:1}),h(m,{label:"收货手机"},{default:b(()=>[h(i,{modelValue:E.mobile,"onUpdate:modelValue":u[1]||(u[1]=e=>E.mobile=e),disabled:""},null,8,["modelValue"])]),_:1}),h(m,{label:"滑块验证",required:""},{default:b(()=>[(y(),_(c,{key:q.value,captchaApi:g(r),text:"请按住滑块拖动完成验证",successText:"验证通过",onSuccess:N},null,8,["captchaApi"]))]),_:1}),h(m,{label:"短信验证码",required:""},{default:b(()=>[V("div",x,[h(i,{modelValue:E.code,"onUpdate:modelValue":u[2]||(u[2]=e=>E.code=e),placeholder:"请输入验证码",maxlength:"6"},null,8,["modelValue"]),h(v,{loading:A.value,disabled:!D.value,onClick:O},{default:b(()=>[...u[5]||(u[5]=[w(" 获取验证码 ",-1)])]),_:1},8,["loading","disabled"])])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])}}});export{k as _};
