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

2 lines
9.2 KiB
JavaScript
Raw Normal View History

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