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