cashier-mer/build/assets/pay-lz1-aziY.js

2 lines
6.7 KiB
JavaScript
Raw Normal View History

2024-04-06 16:09:17 +08:00
import{s as v,_ as le,r as l,v as ne,a as E,h as ce,o as f,c as K,w as m,b as o,n as M,e as L,t as B,j as re,f as b,d as w,i as ue,F as de,g as ie,x as $,E as C,p as ve,l as pe}from"./index-Cpj04_tS.js";function qe(s){return v.post("user/cart/create",s)}function Oe(s){return v.get("user/cart/lst",{params:s})}function Re(s,p){return v.post(`user/cart/change/${s}`,p)}function Ue(s){return v.post("v2/order/check",s)}function Ke(s){return v.post("user/cart/delete",s)}function G(s){return v.post("v2/order/create",s)}function _e(s,p){return v.post(`order/pay/${s}`,p)}function fe(s){return v.get("micropay_query",{params:s})}function Me(s,p){return v.get(`admin/${s}/order_list`,{params:p})}function Ge(s){return v.get("order_lading",{params:s})}const P=s=>{let p=new window.SpeechSynthesisUtterance(s);window.speechSynthesis.speak(p)},q=s=>(ve("data-v-517a591d"),s=s(),pe(),s),me=q(()=>o("h4",null,"选择支付方式",-1)),ye={class:"dra-body"},ge={class:"header"},he=q(()=>o("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),ke={style:{color:"#f5222d","padding-bottom":"2rem"}},be={style:{"font-size":"1.6rem"}},we={key:0,"element-loading-text":"支付中",class:"card1"},Ce=q(()=>o("div",{class:"tips"},null,-1)),xe={key:1,class:"card2"},Se={class:"drawer-body"},Ae={class:"counter"},Le={class:"received"},Ve={key:0},De={key:1,style:{"font-size":"1rem",color:"#999"}},Ee={key:0,class:"balance"},$e={class:"money"},je={key:1,class:"balance"},Be={class:"keypad"},Pe={class:"left"},Te={class:"right"},ze={style:{width:"100%",display:"flex","justify-content":"center"}},Fe={__name:"pay",emits:["paySuccess"],setup(s,{expose:p,emit:H}){const h=l(!1),k=l(1),_=l(""),y=l(""),J=()=>{A()},Q=()=>{$(()=>{setTimeout(()=>{var e;c.value=!1,_.value="",F.value=!0,(e=y.value)==null||e.focus(),T(k.value)},300)})},T=e=>{k.value=e,k.value==2?document.addEventListener("keydown",N):document.removeEventListener("keydown",N)},x=l({}),z=l([]),W=e=>{x.value=e.data,z.value=e.cart_id},X=e=>{x.value.order_price=e.price,u.value=e.order_id},Y=H,F=l(!1),Z=l(["1","2","3","4","5","6","7","8","9","0","00","."]);let S=0;const u=l(""),ee=()=>{c.value=!0,y.value.blur(),u.value?O(u.value):G({address_id:"",key:x.value.key,cart_id:z.value,pay_type:"micropay",auth_code:_.value,source:300}).then(e=>{if(e.status==200&&e.message=="支付成功")h.value=!1,C({message:e.message,type:"success"}),P(e.data.message),A();else if(e.data.group_order_sn)u.value=e.data.group_order_id,V.value=0,S=0,j(e.data.group_order_sn);else return u.value=e.data.result.order_id,c.value=!1,C({message:e.message,type:"error"})}).catch(e=>{c.value=!1,$(()=>{var a;(a=y.value)==null||a.focus()})})},O=e=>{let a;k.value==1?a={type:"micropay",auth_code:_.value}:a={type:"cash_payment"},_e(e,a).then(t=>{t.status==200&&t.message=="支付成功"?(h.value=!1,C({message:t.message,type:"success"}),P(t.data.message),A()):(u.value=t.data.group_order_id,V.value=0,S=0,j(t.data.group_order_sn))}).catch(t=>{_.value="",c.value=!1,$(()=>{var g;(g=y.value)==null||g.focus()})})},V=l(0),j=e=>{e&&(V.value++,S+=5e3,fe({order_sn:e}).then(a=>{a.data.paid==1||a.message=="支付成功"?(C({message:a.message,type:"success"}),P(a.data.message),A()):(C({message:a.message,type:"error"}),_.value="",c.value=!1,$(()=>{var t;(t=y.value)==null||t.focus()}))}).catch(a=>{F.value&&V.value<3?setTimeout(()=>{j(e)},15e3-S>0?15e3-S:0):(_.value="",c.value=!1,$(()=>{var t;(t=y.value)==null||t.focus()}))}))},A=()=>{var e;F.value=!1,c.value=!1,_.value="",r.value="",d.value=[],(e=y.value)==null||e.blur(),document.removeEventListener("keydown",N),Y("paySuccess"),h.value=!1},c=l(!1);p({drawer:h,setForm:W,setRePay:X});const d=l([]),r=l(""),D=ne(()=>+r.value>0?(r.value-x.value.order_price).toFixed(2):-1),R=l(!1),I=e=>{e===-1?d.value=[]:d.value.pop(),r.value=d.value.length?d.value.join(""):0},n=e=>{R.value===!1&&(r.value="",R.value=!0);let a=String(r.value).indexOf(".")+1,t=String(r.value).length-a;console.log(a,t),(a===0||t<2)&&(d.value.join("")<=9999999&&d.value.push(e),r.value=d.value.join("")>99999999?99999999:d.value.join(""))},U=()=>{