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

2 lines
8.1 KiB
JavaScript
Raw Normal View History

2024-04-10 10:28:50 +08:00
import{A as v,_ as de,r as n,u as ve,D as _e,o as pe,m as j,a as fe,b as I,j as me,c as k,d as X,w as b,e as o,l as q,g as L,t as F,p as ge,h as S,f as A,k as ye,F as he,i as ke,n as V,E as m,s as be,v as we}from"./index-CDJP75me.js";function Ze(t){return v.post("user/cart/create",t)}function ea(t){return v.get("user/cart/lst",{params:t})}function aa(t,i){return v.post(`user/cart/change/${t}`,i)}function sa(t){return v.post("v2/order/check",t)}function ta(t){return v.post("user/cart/delete",t)}function Y(t){return v.post("v2/order/create",t)}function Ce(t,i){return v.post(`order/pay/${t}`,i)}function Se(t){return v.get("micropay_query",{params:t})}function oa(t,i){return v.get(`admin/${t}/order_list`,{params:i})}function la(t,i){return v.get(`verifier/${t}/order/${i}`)}function ra(t){return v.get("order_lading",{params:t})}const T=t=>{if(!t)return;let i=new window.SpeechSynthesisUtterance(t);window.speechSynthesis.speak(i)},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)),je={key:1,class:"card2"},Ie={class:"drawer-body"},Pe={class:"counter"},Fe={class:"received"},Te={key:0},Ue={key:1,style:{"font-size":"1rem",color:"#999"}},ze={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:i,emit:Z}){const g=n(!1),y=n(1),l=n(""),d=n(""),R=ve(),ee=()=>{w()},ae=()=>{V(()=>{setTimeout(()=>{var e;u.value=!1,l.value="",z.value=!0,(e=d.value)==null||e.focus(),x(y.value)},300)})},x=e=>{y.value=e,y.value==2?window.addEventListener("keydown",O):(window.removeEventListener("keydown",O),V(()=>{var a;l.value="",(a=d.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=Z,z=n(!1),le=n(["1","2","3","4","5","6","7","8","9","0","00","."]);let $=0;const K=/^(10|11|12|13|14|15)\d{16}$/,M=/^(25|26|27|28|29|30)\d{14,22}$/,_=n(""),re=()=>{if(u.value=!0,d.value.blur(),_.value)W(_.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="",d.value.focus(),m.error("请输入正确的支付码");Y({address_id:"",key:h.value.key,cart_id:U.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"))g.value=!1,m({message:a.message=="success"?"支付成功":a.message,type:"success"}),T(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,P(a.data.group_order_sn);else return _.value=a.data.result.order_id,u.value=!1,m({message:a.message,type:"error"})}).catch(a=>{u.value=!1,V(()=>{var s;(s=d.value)==null||s.focus()})})}},W=e=>{let a;if(y.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="",d.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")?(g.value=!1,m({message:s.message=="success"?"支付成功":s.message,type:"success"}),T(s.data.message||s.data.result.message),w()):(_.value=s.data.group_order_id,E.value=0,$=0,P(s.data.group_order_sn))}).catch(s=>{l.value="",u.value=!1,V(()=>{var C;(C=d.value)==null||C.focus()})})},E=n(0),P=e=>{e&&(E.value++,$+=5e3,Se({order_sn:e}).then(a=>{a.data.paid==1||a.m