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

2 lines
7.6 KiB
JavaScript
Raw Normal View History

2024-04-12 18:17:06 +08:00
import{_ as ie,r as c,u as de,J as ve,o as _e,m as I,a as fe,b as L,l as pe,c as y,d as Q,w as g,e as t,s as O,g as V,t as $,v as me,h as C,f as S,p as ye,F as ge,i as he,n as E,E as _,y as ke,z as be}from"./index-EgCJN650.js";import{j as X,k as we,g as Ce}from"./pay.vue_vue_type_style_index_0_scoped_d2507c03_lang-C3Cm2mXN.js";const z=b=>{if(!b)return;let A=new window.SpeechSynthesisUtterance(b);window.speechSynthesis.speak(A)},B=b=>(ke("data-v-d2507c03"),b=b(),be(),b),Se=B(()=>t("h4",null,"选择支付方式",-1)),xe={class:"dra-body"},Ve={class:"header"},Ee=B(()=>t("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),Be={style:{color:"#f5222d","padding-bottom":"2rem"}},je={style:{"font-size":"1.6rem"}},De={key:0,"element-loading-text":"支付中",class:"card1"},Ie=B(()=>t("div",{class:"tips"},null,-1)),Le={key:1,class:"card2"},Pe={class:"drawer-body"},$e={class:"counter"},ze={class:"received"},Ae={key:0},Fe={key:1,style:{"font-size":"1rem",color:"#999"}},Te={key:0,class:"balance"},Ue={class:"money"},Ne=B(()=>t("div",{class:"tips"},"按回车(Enter)确认支付",-1)),Oe={key:1,class:"balance"},Re=B(()=>t("div",null,"不够找零, 请支付更多金额",-1)),Ke=B(()=>t("div",{class:"tips"},"按下小键盘输入金额",-1)),Me=[Re,Ke],qe={class:"keypad"},Je={class:"left"},We={class:"right"},Ge={style:{width:"100%",display:"flex","justify-content":"center"}},He={__name:"pay",emits:["paySuccess"],setup(b,{expose:A,emit:Y}){const f=c(!1),p=c(1),l=c(""),r=c(""),R=de(),Z=()=>{h()},ee=()=>{E(()=>{setTimeout(()=>{var e;u.value=!1,l.value="",T.value=!0,(e=r.value)==null||e.focus(),w(p.value)},300)})},w=e=>{p.value=e,p.value==2?window.addEventListener("keydown",N):(window.removeEventListener("keydown",N),E(()=>{var a;l.value="",(a=r.value)==null||a.focus()}))},m=c({}),F=c([]),ae=e=>{m.value=e.data,F.value=e.cart_id},se=e=>{m.value.order_price=e.price,i.value=e.order_id},te=Y,T=c(!1),le=c(["1","2","3","4","5","6","7","8","9","0","00","."]);let x=0;const K=/^(10|11|12|13|14|15)\d{16}$/,M=/^(25|26|27|28|29|30)\d{14,22}$/,i=c(""),oe=()=>{if(u.value=!0,r.value.blur(),i.value)q(i.value);else{let e;if(K.test(l.value))e="micropay";else if(M.test(l.value))e="alipayBar";else return u.value=!1,l.value="",r.value.focus(),_.error("请输入正确的支付码");X({address_id:"",key:m.value.key,cart_id:F.value,pay_type:e,auth_code:l.value,staff_id:R.userInfo.service.service_id}).then(a=>{if(a.status==200&&(a.message=="支付成功"||a.message=="success"))f.value=!1,_({message:a.message=="success"?"支付成功":a.message,type:"success"}),z(a.data.message||a.data.result.message),h();else if(a.data.group_order_sn)i.value=a.data.group_order_id,j.value=0,x=0,P(a.data.group_order_sn);else return i.value=a.data.result.order_id,u.value=!1,_({message:a.message,type:"error"})}).catch(a=>{u.value=!1,E(()=>{var s;(s=r.value)==null||s.focus()})})}},q=e=>{let a;if(p.value==1){let s;if(K.test(l.value))s="micropay";else if(M.test(l.value))s="alipayBar";else return u.value=!1,l.value="",r.value.focus(),_.error("请输入正确的支付码");a={type:s,auth_code:l.value}}else a={type:"cash_payment"};we(e,a).then(s=>{s.status==200&&(s.message=="支付成功"||s.message=="success")?(f.value=!1,_({message:s.message=="success"?"支付成功":s.message,type:"success"}),z(s.data.message||s.data.result.message),h()):(i.value=s.data.group_order_id,j.value=0,x=0,P(s.data.group_order_sn))}).catch(s=>{l.value="",u.value=!1,E(()=>{var k;(k=r.value)==null||k.focus()})})},j=c(0),P=e=>{e&&(j.value++,x+=5e3,Ce({order_sn:e}).then(a=>{a.data.paid==1||a.message=="支付成功"?(_({message:a.message,type:"success"}),z(a.data.message),h()):(_({message:a.message,type:"error"}),l.value="",u.value=!1,E(()=>{var s;(s=r.value)==null||s.focus()}))}).catch(a=>{T.value&&j.value<3?setTimeout(()=>{P(e)},15e3-x>0?15e3-x:0):(l.value="",u.value=!1,E(()=>{var s;(s=r.value)==null||s.focus()}))}))},h=()=>{var e;window.removeEventListener("keydown",N),T.value=!1,u.value=!1,l.value="",o.value="",d.value=[],(e=r.value)==null||e.blur(),te("paySuccess"),f.value=!1},u=c(!1);A