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

2 lines
9.6 KiB
JavaScript
Raw Normal View History

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