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

2 lines
9.0 KiB
JavaScript
Raw Normal View History

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