2 lines
8.2 KiB
JavaScript
2 lines
8.2 KiB
JavaScript
|
import{A as d,_ 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 Y,w as b,e as o,l as R,g as L,t as F,p as ge,h as A,f as S,k as ye,F as he,i as ke,n as V,E as m,s as be,v as we}from"./index-3-ddzq9I.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 Ae(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,U){return d.post(`verifier/${t}/${u}`,U)}const T=t=>{if(!t)return;let u=new window.SpeechSynthesisUtterance(t);window.speechSynthesis.speak(u)},D=t=>(be("data-v-f7abe660"),t=t(),we(),t),Se=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:u,emit:U}){const g=n(!1),y=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(y.value)},300)})},x=e=>{y.value=e,y.value==2?window.addEventListener("keydown",q):(window.removeEventListener("keydown",q),V(()=>{var a;l.value="",(a=v.value)==null||a.focus()}))},h=n({}),z=n([]),se=e=>{h.value=e.data,z.value=e.cart_id},te=e=>{h.value.order_price=e.price,_.value=e.order_id},oe=U,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:z.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"))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,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(y.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")?(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="",c.value=!1,V(()=>{var C;(C=v.value)==null||C.focus()})})},E=n(0),P=e=>{e&&(E.val
|