import{_ as me,r as o,u as ge,J as ke,o as he,m,a as be,b as D,h as we,c as _,d as K,w as g,e as s,z as j,k as w,g as C,t as P,p as ee,j as Ce,f as x,i as ae,F as xe,l as $e,n as R,E as u,q as Ve,s as Se}from"./index-CUhlpiMv.js";import{h as M,i as Pe,j as Ee,k as Be}from"./store-99ZpBOIP.js";import{_ as Fe}from"./authCode-DtkLY9H_.js";/* empty css */const S=L=>(Ve("data-v-24942126"),L=L(),Se(),L),Te=S(()=>s("h4",null,"选择支付方式",-1)),je={class:"dra-body"},ze={class:"header"},Ae={key:0,style:{display:"inline-block","margin-right":"20px"}},De={style:{display:"inline-block","margin-right":"20px"}},Le=S(()=>s("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"原价:",-1)),Re={style:{color:"#f5222d","padding-bottom":"2rem"}},Ne={style:{"font-size":"1.6rem"}},Ue={style:{display:"inline-block"}},Ie=S(()=>s("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"活动折扣: ",-1)),Oe={style:{color:"#f5222d","padding-bottom":"2rem"}},Ke={style:{"font-size":"1.6rem"}},Me={style:{display:"inline-block"}},qe=S(()=>s("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),Je={style:{color:"#f5222d","padding-bottom":"2rem"}},We={style:{"font-size":"1.6rem"}},Ge={key:0,"element-loading-text":"支付中",class:"card1"},He=S(()=>s("div",{class:"tips"},null,-1)),Qe={key:1,class:"card2"},Xe={class:"drawer-body"},Ye={class:"counter"},Ze={class:"received"},ea={key:0},aa={key:1,style:{"font-size":"1rem",color:"#999"}},sa={key:0,class:"balance"},ta={class:"money"},la=S(()=>s("div",{class:"tips"},"按回车(Enter)确认支付",-1)),oa={key:1,class:"balance"},na=S(()=>s("div",null,"不够找零, 请支付更多金额",-1)),ia=S(()=>s("div",{class:"tips"},"按下小键盘输入金额",-1)),ua=[na,ia],ra={class:"keypad"},ca={class:"left"},da={class:"right"},va={key:2,class:"card3"},_a={class:"codes"},pa={style:{width:"100%",display:"flex","justify-content":"center"}},fa={__name:"pay",emits:["paySuccess"],setup(L,{expose:se,emit:te}){const v=o(!1),$=o(!0),t=o(1),i=o(""),k=o("");ge(),o(0);const E=a=>{Be({id:a}).then(e=>{m.emit("letPrintReceipt",e.data)})},le=()=>{y()},oe=()=>{R(()=>{setTimeout(()=>{var a;h.value=!1,i.value="",q.value=!0,(a=k.value)==null||a.focus(),p(t.value)},300)})},p=a=>{t.value=a,t.value==2?window.addEventListener("keydown",I):(window.removeEventListener("keydown",I),R(()=>{var e;i.value="",(e=k.value)==null||e.focus()}))},r=o({}),z=o([]),f=o(""),B=o(null),N=o(!1);let F=0;const ne=a=>{r.value=a.data,z.value=a.cart_id,f.value=a.uid,B.value=a.reservation||null,F=a.is_storage||0,console.log("选择了用户==",f.value||"游客"),N.value=a.isRePay||!1},ie=a=>{r.value.pay_price=a.price,ce.value=a.order_id,F=a.is_storage||0},ue=te,q=o(!1),re=o(["1","2","3","4","5","6","7","8","9","0","00","."]),J=/^(10|11|12|13|14|15)\d{16}$/,W=/^(25|26|27|28|29|30)\d{14,22}$/,ce=o(""),de=()=>{if(h.value=!0,k.value.blur(),N.value)G();else{let a;if(J.test(i.value))a="9";else if(W.test(i.value))a="13";else return h.value=!1,i.value="",k.value.focus(),u.error("请输入正确的支付码");M({key:r.value.key,cart_id:z.value,pay_type:a,is_storage:F,auth_code:i.value,reservation:B.value,uid:f.value}).then(e=>{e.data.out_trade_no&&e.msg=="支付成功"?(v.value=!1,u({message:"支付成功",type:"success"}),y(e.data),E(e.data.id)):e.msg=="用户支付中"&&e.code==1&&(u.warning(e.msg),m.on("pay_success",l=>{u({message:"支付成功",type:"success"}),E(e.data.id),setTimeout(()=>{m.off("pay_success")},200),v.value=!1,y(l)}))}).catch(e=>{h.value=!1,R(()=>{var l;(l=k.value)==null||l.focus()})})}},G=()=>{let a=17;if(t.value==1)if(J.test(i.value))a="9";else if(W.test(i.value))a="13";else return h.value=!1,i.value="",k.value.focus(),u.error("请输入正确的支付码");Pe({order_id:r.value.order_id,pay_type:a,is_storage:F,auth_code:i.value,reservation:B.value,uid:f.value}).then(e=>{var l;(l=e.msg)!=null&&l.includes("成功")?(v.value=!1,u({message:"支付成功",type:"success"}),E(e.data.id),y()):e.msg=="用户支付中"&&e.code==1&&(u.warning(e.msg),m.on("pay_success",V=>{u({message:"支付成功",type:"success"}),E(e.data.id),setTimeout(()=>{m.off("pay_success")},200),v.value=!1,y(V)}))}).catch(e=>{i.value="",h.value=!1,R(()=>{var l;(l=k.value)==null||l.focus()})})};o(0);const y=a=>{var e;try{window.removeEventListener("keydown",I),q.value=!1,h.value=!1,i.value="",c.value="",b.value=[],(e=k.value)==null||e.blur(),ue("paySuccess",a),v.value=!1}catch{}},h=o(!1);se({drawer:v,setForm:ne,setRePay:ie,beforeClose:y});const b=o([]),c=o(""),A=ke(()=>+c.value>0?(+c.value-r.value.pay_price).toFixed(2):-1),H=o(!1),U=a=>{a===-1?b.value=[]:b.value.pop(),c.value=b.value.length?b.value.join(""):0},d=a=>{H.value===!1&&(c.value="",H.value=!0);let e=String(c.value).indexOf(".")+1,l=String(c.value).length-e;console.log(e,l),(e===0||l<2)&&(b.value.join("")<=9999999&&b.value.push(a),c.value=b.value.join("")>99999999?99999999:b.value.join(""))},Q=()=>{if(A.value===""||A.value===null||A.value===void 0||+c.value<+r.value.pay_price)return u.error("收款金额应该大于等于应收金额");if($.value==!1)return u.error("不能重复点击");($.value=!0)&&($.value=!1,setTimeout(()=>{$.value=!0},5e3)),N.value?G():(c.value="",M({cart_id:z.value,pay_type:"17",is_storage:F,reservation:B.value,uid:f.value}).then(a=>{v.value=!1,u({message:a.msg,type:"success"}),E(a.data.id),t.value=1,y()}).catch(a=>{h.value=!1}))},I=a=>{let l=(a||window.event).keyCode;if(l==37)return p(2);if(l==120)return m.emit("F9");if(l==27)return y();switch(a.stopPropagation(),a.preventDefault(),l){case 96:case 48:d(0);break;case 97:case 49:d(1);break;case 98:case 50:d(2);break;case 99:case 51:d(3);break;case 100:case 52:d(4);break;case 101:case 53:d(5);break;case 102:case 54:d(6);break;case 103:case 55:d(7);break;case 104:case 56:d(8);break;case 105:case 57:d(9);break;case 110:d(".");break;case 190:d(".");break;case 8:U();break;case 13:Q();break}},ve=()=>{if(!f.value)return u.error("请先选择用户");let a=1;t.value==4&&(a=2),t.value==5&&(a=3),Ee({cart_id:z.value,reservation:B.value,uid:f.value,type:a}).then(e=>{u({message:"发送成功",type:"success"})})},O=o(""),X=()=>{if(!f.value)return u.error("请先选择用户");let a=18;if(t.value==4&&(a=19),t.value==5&&(a=3),$.value==!1)return u.error("不能重复点击");($.value=!0)&&($.value=!1,setTimeout(()=>{$.value=!0},5e3)),M({pay_type:a,is_storage:F,sms_code:O.value,cart_id:z.value,reservation:B.value,uid:f.value}).then(e=>{v.value=!1,u({message:e.msg,type:"success"}),E(e.data.id),p(1),y()})},T=o(!1),Y=()=>{if(!(!v.value||T.value&&i.value.length>0)&&t.value!=1)return p(t.value-1)},Z=()=>{if(!(!v.value||T.value&&i.value.length>0)&&t.value!=5)return p(t.value+1)};return he(()=>{m.on("left",Y),m.on("right",Z)}),be(()=>{m.off("left",Y),m.off("right",Z)}),(a,e)=>{const l=D("el-input"),V=D("el-button"),_e=D("Delete"),pe=D("el-icon"),fe=D("el-drawer"),ye=we("loading");return _(),K(fe,{size:"60rem",modelValue:v.value,"onUpdate:modelValue":e[12]||(e[12]=n=>v.value=n),direction:"rtl",onOpen:oe,"before-close":y},{header:g(()=>[Te]),default:g(()=>[s("div",je,[s("div",ze,[s("div",{class:j(["left",{active:t.value==1}]),onClick:e[0]||(e[0]=n=>p(1))}," 微信/支付宝 ",2),s("div",{class:j(["center",{active:t.value==2}]),onClick:e[1]||(e[1]=n=>p(2))}," 现金收款 ",2),s("div",{class:j(["center",{active:t.value==3}]),style:{"border-left":"none"},onClick:e[2]||(e[2]=n=>p(3))}," 采购款 ",2),s("div",{class:j(["center",{active:t.value==4}]),style:{"border-left":"none"},onClick:e[3]||(e[3]=n=>p(4))}," 礼品券兑换 ",2),s("div",{class:j(["right",{active:t.value==5}]),onClick:e[4]||(e[4]=n=>p(5))}," 余额 ",2)]),s("div",null,[r.value.activities==1&&t.value!=4?(_(),w("div",Ae,[s("div",De,[Le,s("div",Re,[C(" ¥"),s("span",Ne,P(r.value.total_price),1)])]),s("div",Ue,[Ie,s("div",Oe,[C(P(r.value.activity)+"¥",1),s("span",Ke,P(r.value.activity_price),1)])])])):ee("",!0),s("div",Me,[qe,s("div",Je,[C(" ¥"),s("span",We,P(t.value==4?r.value.total_price:r.value.pay_price),1)])])]),t.value==1?Ce((_(),w("div",Ge,[x(l,{ref_key:"codeRef",ref:k,modelValue:i.value,"onUpdate:modelValue":e[5]||(e[5]=n=>i.value=n),autofocus:"",class:"code-input",placeholder:"请点击输入框聚焦扫码或输入编码号",onKeyup:ae(de,["enter"]),onFocus:e[6]||(e[6]=n=>T.value=!0),onBlur:e[7]||(e[7]=n=>T.value=!1)},null,8,["modelValue"]),He])),[[ye,h.value]]):t.value==2?(_(),w("div",Qe,[s("div",Xe,[s("div",Ye,[s("div",Ze,[c.value?(_(),w("span",ea,P(c.value),1)):(_(),w("span",aa,"按下键盘输入客户支付金额"))]),A.value>=0?(_(),w("div",sa,[s("div",null,[C(" 需找零(元):"),s("span",ta,"¥"+P(A.value),1)]),la])):(_(),w("div",oa,ua)),s("div",ra,[s("div",ca,[(_(!0),w(xe,null,$e(re.value,n=>(_(),K(V,{key:n,onClick:ya=>d(n)},{default:g(()=>[C(P(n),1)]),_:2},1032,["onClick"]))),128))]),s("div",da,[x(V,{onClick:U},{default:g(()=>[x(pe,null,{default:g(()=>[x(_e)]),_:1})]),_:1}),x(V,{onClick:e[8]||(e[8]=n=>U(-1))},{default:g(()=>[C("C")]),_:1}),x(V,{class:j(["enter",{"enter-disable":+c.value<+r.value.pay_price}]),disabled:+c.value<+r.value.pay_price,onClick:Q},{default:g(()=>[C(" 确认 ")]),_:1},8,["class","disabled"])])])])])])):t.value==3||t.value==4||t.value==5?(_(),w("div",va,[s("div",_a,[x(l,{modelValue:O.value,"onUpdate:modelValue":e[9]||(e[9]=n=>O.value=n),autofocus:"",class:"code-input",placeholder:"请输入验证码",onKeyup:ae(X,["enter"]),onFocus:e[10]||(e[10]=n=>T.value=!0),onBlur:e[11]||(e[11]=n=>T.value=!1)},null,8,["modelValue"]),(_(),K(Fe,{style:{"margin-left":"1rem"},onSendCode:ve,start:f.value>0,key:r.value.order_id,class:"get-code-btn"},null,8,["start"]))]),x(V,{type:"primary",onClick:X,class:"code-pay"},{default:g(()=>[C("确认支付")]),_:1})])):ee("",!0)])]),footer:g(()=>[s("div",pa,[x(V,{class:"cancel-btn",onClick:le},{default:g(()=>[C("取消收款")]),_:1})])]),_:1},8,["modelValue"])}}},ba=me(fa,[["__scopeId","data-v-24942126"]]);export{ba as p};