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