cashier-ERP/dist/assets/pay-Bt7FIL7i.js

2 lines
7.7 KiB
JavaScript
Raw Normal View History

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