cashier-mer/build/assets/pay-cocbD1Lo.js

2 lines
9.7 KiB
JavaScript
Raw Normal View History

2024-10-07 16:09:26 +08:00
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_s