cashier-mer/dist/assets/pay-DsODbiUT.js

2 lines
9.5 KiB
JavaScript
Raw Normal View History

2024-07-31 13:33:15 +08:00
import{_ as ye,r as o,u as me,J as ge,o as he,m,a as ke,b as D,h as be,c as _,d as O,w as g,e as s,z,k as w,g as C,t as S,p as Z,j as we,f as x,i as ee,F as Ce,l as xe,n as R,E as c,q as $e,s as Ve}from"./index-El3JpHtp.js";import{g as K,h as Se,i as Pe,j as Ee}from"./store-D17PfqyZ.js";import{_ as Fe}from"./authCode-p4DlY4hZ.js";/* empty css */const V=L=>($e("data-v-09cf2609"),L=L(),Ve(),L),je=V(()=>s("h4",null,"选择支付方式",-1)),ze={class:"dra-body"},Be={class:"header"},Ae={key:0,style:{display:"inline-block","margin-right":"20px"}},De={style:{display:"inline-block","margin-right":"20px"}},Le=V(()=>s("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"原价:",-1)),Re={style:{color:"#f5222d","padding-bottom":"2rem"}},Te={style:{"font-size":"1.6rem"}},Ne={style:{display:"inline-block"}},Ue=V(()=>s("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"活动折扣: ",-1)),Ie={style:{color:"#f5222d","padding-bottom":"2rem"}},Oe={style:{"font-size":"1.6rem"}},Ke={style:{display:"inline-block"}},Me=V(()=>s("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),qe={style:{color:"#f5222d","padding-bottom":"2rem"}},Je={style:{"font-size":"1.6rem"}},We={key:0,"element-loading-text":"支付中",class:"card1"},Ge=V(()=>s("div",{class:"tips"},null,-1)),He={key:1,class:"card2"},Qe={class:"drawer-body"},Xe={class:"counter"},Ye={class:"received"},Ze={key:0},ea={key:1,style:{"font-size":"1rem",color:"#999"}},aa={key:0,class:"balance"},sa={class:"money"},ta=V(()=>s("div",{class:"tips"},"按回车(Enter)确认支付",-1)),la={key:1,class:"balance"},oa=V(()=>s("div",null,"不够找零, 请支付更多金额",-1)),na=V(()=>s("div",{class:"tips"},"按下小键盘输入金额",-1)),ia=[oa,na],ua={class:"keypad"},ca={class:"left"},ra={class:"right"},da={key:2,class:"card3"},va={class:"codes"},_a={style:{width:"100%",display:"flex","justify-content":"center"}},pa={__name:"pay",emits:["paySuccess"],setup(L,{expose:ae,emit:se}){const v=o(!1),t=o(1),i=o(""),h=o("");me(),o(0);const P=a=>{Ee({id:a}).then(e=>{m.emit("letPrintReceipt",e.data)})},te=()=>{y()},le=()=>{R(()=>{setTimeout(()=>{var a;k.value=!1,i.value="",M.value=!0,(a=h.value)==null||a.focus(),p(t.value)},300)})},p=a=>{t.value=a,t.value==2?window.addEventListener("keydown",U):(window.removeEventListener("keydown",U),R(()=>{var e;i.value="",(e=h.value)==null||e.focus()}))},u=o({}),B=o([]),f=o(""),E=o(null),T=o(!1);let F=0;const oe=a=>{u.value=a.data,B.value=a.cart_id,f.value=a.uid,E.value=a.reservation||null,F=a.is_storage||0,console.log("选择了用户==",f.value||"游客"),T.value=a.isRePay||!1},ne=a=>{u.value.pay_price=a.price,ce.value=a.order_id,F=a.is_storage||0},ie=se,M=o(!1),ue=o(["1","2","3","4","5","6","7","8","9","0","00","."]),q=/^(10|11|12|13|14|15)\d{16}$/,J=/^(25|26|27|28|29|30)\d{14,22}$/,ce=o(""),re=()=>{if(k.value=!0,h.value.blur(),T.value)W();else{let a;if(q.test(i.value))a="9";else if(J.test(i.value))a="13";else return k.value=!1,i.value="",h.value.focus(),c.error("请输入正确的支付码");K({key:u.value.key,cart_id:B.value,pay_type:a,is_storage:F,auth_code:i.value,reservation:E.value,uid:f.value}).then(e=>{e.data.out_trade_no&&e.msg=="支付成功"?(v.value=!1,c({message:"支付成功",type:"success"}),y(e.data),P(e.data.id)):e.msg=="用户支付中"&&e.code==1&&(c.warning(e.msg),m.on("pay_success",l=>{c({message:"支付成功",type:"success"}),P(e.data.id),setTimeout(()=>{m.off("pay_success")},200),v.value=!1,y(l)}))}).catch(e=>{k.value=!1,R(()=>{var l;(l=h.value)==null||l.focus()})})}},W=()=>{let a=17;if(t.value==1)if(q.test(i.value))a="9";else if(J.test(i.value))a="13";else return k.value=!1,i.value="",h.value.focus(),c.error("请输入正确的支付码");Se({order_id:u.value.order_id,pay_type:a,is_storage:F,auth_code:i.value,reservation:E.value,uid:f.value}).then(e=>{var l;(l=e.msg)!=null&&l.includes("成功")?(v.value=!1,c({message:"支付成功",type:"success"}),P(e.data.id),y()):e.msg=="用户支付中"&&e.code==1&&(c.warning(e.msg),m.on("pay_success",$=>{c(