2 lines
6.7 KiB
JavaScript
2 lines
6.7 KiB
JavaScript
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-B3GfFMCJ.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=()=>{D.value===""||D.value===null||D.value===void 0||(u.value?O(u.value):G({address_id:"",key:x.value.key,cart_id:z.value,pay_type:"cash_payment",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,r.value="",d.value=[],c.value=!1,C({message:e.message,type:"error"})}).catch(e=>{c.value=!1}))},N=e=>{let t=(e||window.event).keyCode;switch(e.stopPropagation(),e.preventDefault(),t){case 96:case 48:n(0);break;case 97:case 49:n(1);break;case 98:case 50:n(2);break;case 99:case 51:n(3);break;case 100:case 52:n(4);break;case 101:case 53:n(5);break;case 102:case 54:n(6);break;case 103:case 55:n(7);break;case 104:case 56:n(8);break;case 105:case 57:n(9);break;case 110:n(".");break;case 190:n(".");break;case 8:I();break;case 13:U();break}};return(e,a)=>{const t=E("el-input"),g=E("el-button"),ae=E("Delete"),se=E("el-icon"),te=E("el-drawer"),oe=ce("loading");return f(),K(te,{size:800,modelValue:h.value,"onUpdate:modelValue":a[4]||(a[4]=i=>h.value=i),direction:"rtl",onOpen:Q,"before-close":A},{header:m(()=>[me]),default:m(()=>[o("div",ye,[o("div",ge,[o("div",{class:M(["left",{active:k.value==1}]),onClick:a[0]||(a[0]=i=>T(1))}," 微信 ",2),o("div",{class:M(["right",{active:k.value==2}]),onClick:a[1]||(a[1]=i=>T(2))}," 现金收款 ",2)]),he,o("div",ke,[L(" ¥"),o("span",be,B(x.value.order_price),1)]),k.value==1?re((f(),b("div",we,[w(t,{ref_key:"codeRef",ref:y,modelValue:_.value,"onUpdate:modelValue":a[2]||(a[2]=i=>_.value=i),autofocus:"",class:"code-input",placeholder:"请点击输入框聚焦扫码或输入编码号",onKeyup:ue(ee,["enter"])},null,8,["modelValue"]),Ce])),[[oe,c.value]]):(f(),b("div",xe,[o("div",Se,[o("div",Ae,[o("div",Le,[r.value?(f(),b("span",Ve,B(r.value),1)):(f(),b("span",De,"按下键盘输入客户支付金额"))]),D.value>=0?(f(),b("div",Ee,[L(" 需找零(元):"),o("span",$e,"¥"+B(D.value),1)])):(f(),b("div",je,"不够找零, 请支付更多金额")),o("div",Be,[o("div",Pe,[(f(!0),b(de,null,ie(Z.value,i=>(f(),K(g,{key:i,onClick:Ie=>n(i)},{default:m(()=>[L(B(i),1)]),_:2},1032,["onClick"]))),128))]),o("div",Te,[w(g,{onClick:I},{default:m(()=>[w(se,null,{default:m(()=>[w(ae)]),_:1})]),_:1}),w(g,{onClick:a[3]||(a[3]=i=>I(-1))},{default:m(()=>[L("C")]),_:1}),w(g,{class:"enter",onClick:U},{default:m(()=>[L("确认")]),_:1})])])])])]))])]),footer:m(()=>[o("div",ze,[w(g,{class:"cancel-btn",onClick:J},{default:m(()=>[L("取消收款")]),_:1})])]),_:1},8,["modelValue"])}}},He=le(Fe,[["__scopeId","data-v-517a591d"]]);export{Oe as a,Re as b,Ke as c,qe as d,Me as e,Ge as f,fe as g,Ue as o,He as p};
|