2 lines
7.5 KiB
JavaScript
2 lines
7.5 KiB
JavaScript
|
import{_ as ce,r as o,u as ie,G as ue,o as re,m as h,a as de,b as P,l as ve,c as d,d as G,w as g,e as a,s as j,h as k,g as b,t as V,x as _e,v as fe,f as S,p as pe,F as ye,i as me,n as F,E as v,y as he,z as ge}from"./index-CWN5yz9-.js";import{f as W,g as ke}from"./store-cGjVPjwr.js";/* empty css */const w=$=>(he("data-v-16249cbf"),$=$(),ge(),$),be=w(()=>a("h4",null,"选择支付方式",-1)),we={class:"dra-body"},xe={class:"header"},Ce={key:0,style:{display:"inline-block","margin-right":"20px"}},Ve={style:{display:"inline-block","margin-right":"20px"}},Se=w(()=>a("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"原价:",-1)),Ee={style:{color:"#f5222d","padding-bottom":"2rem"}},Pe={style:{"font-size":"1.6rem"}},$e={style:{display:"inline-block"}},ze=w(()=>a("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"活动折扣:",-1)),Fe={style:{color:"#f5222d","padding-bottom":"2rem"}},Be={style:{"font-size":"1.6rem"}},De={style:{display:"inline-block"}},Le=w(()=>a("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),Te={style:{color:"#f5222d","padding-bottom":"2rem"}},je={style:{"font-size":"1.6rem"}},Ne={key:0,"element-loading-text":"支付中",class:"card1"},Re=w(()=>a("div",{class:"tips"},null,-1)),Ae={key:1,class:"card2"},Ie={class:"drawer-body"},Ue={class:"counter"},Ke={class:"received"},Me={key:0},Oe={key:1,style:{"font-size":"1rem",color:"#999"}},Ge={key:0,class:"balance"},We={class:"money"},qe=w(()=>a("div",{class:"tips"},"按回车(Enter)确认支付",-1)),He={key:1,class:"balance"},Je=w(()=>a("div",null,"不够找零, 请支付更多金额",-1)),Qe=w(()=>a("div",{class:"tips"},"按下小键盘输入金额",-1)),Xe=[Je,Qe],Ye={class:"keypad"},Ze={class:"left"},es={class:"right"},ss={style:{width:"100%",display:"flex","justify-content":"center"}},as={__name:"pay",emits:["paySuccess"],setup($,{expose:q,emit:H}){const r=o(!1),_=o(1),l=o(""),f=o("");ie();const J=()=>{p()},Q=()=>{F(()=>{setTimeout(()=>{var s;y.value=!1,l.value="",N.value=!0,(s=f.value)==null||s.focus(),x(_.value)},300)})},x=s=>{_.value=s,_.value==2?window.addEventListener("keydown",T):(window.removeEventListener("keydown",T),F(()=>{var e;l.value="",(e=f.value)==null||e.focus()}))},n=o({}),B=o([]),D=o(!1),X=s=>{n.value=s.data,B.value=s.cart_id,D.value=s.isRePay||!1},Y=s=>{n.value.total=s.price,se.value=s.order_id},Z=H,N=o(!1),ee=o(["1","2","3","4","5","6","7","8","9","0","00","."]),R=/^(10|11|12|13|14|15)\d{16}$/,A=/^(25|26|27|28|29|30)\d{14,22}$/,se=o(""),ae=()=>{if(y.value=!0,f.value.blur(),D.value)I();else{let s;if(R.test(l.value))s="9";else if(A.test(l.value))s="13";else return y.value=!1,l.value="",f.value.focus(),v.error("请输入正确的支付码");W({key:n.value.key,cart_id:B.value,pay_type:s,auth_code:l.value}).then(e=>{e.data.out_trade_no&&e.msg=="支付成功"?(r.value=!1,v({message:"支付成功",type:"success"}),p(e.data)):e.msg=="用户支付中"&&e.code==1&&(v.warning(e.msg),h.on("pay_success",t=>{v({message:"支付成功",type:"success"}),setTimeout(()=>{h.off("pay_success")},200),r.value=!1,p(t)}))}).catch(e=>{y.value=!1,F(()=>{var t;(t=f.value)==null||t.focus()})})}},I=()=>{let s=17;if(_.value==1)if(R.test(l.value))s="9";else if(A.test(l.value))s="13";else return y.value=!1,l.value="",f.value.focus(),v.error("请输入正确的支付码");ke({order_id:n.value.order_id,pay_type:s,auth_code:l.value}).then(e=>{var t;(t=e.msg)!=null&&t.includes("成功")?(r.value=!1,v({message:"支付成功",type:"success"}),p()):e.msg=="用户支付中"&&e.code==1&&(v.warning(e.msg),h.on("pay_success",C=>{v({message:"支付成功",type:"success"}),setTimeout(()=>{h.off("pay_success")},200),r.value=!1,p(C)}))}).catch(e=>{l.value="",y.value=!1,F(()=>{var t;(t=f.value)==null||t.focus()})})};o(0);const p=s=>{var e;window.removeEventListener("keydown",T),N.value=!1,y.value=!1,l.value="",c.value="",m.value=[],(e=f.value)==null||e.blur(),Z("paySuccess",s),r.value=!1},y=o(!1);q({drawer:r,setForm:X,setRePay:Y,beforeClose:p});const m=o([]),c=o(""),E=ue(()=>+c.value>0?(c.v
|