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