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

2 lines
8.2 KiB
JavaScript
Raw Normal View History

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