cashier-mer/dist/assets/pay-Cl97IneR.js

2 lines
7.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as ce,r as o,u as ie,G as ue,o as re,m as h,a as de,b as P,l as ve,c as d,d as G,w as g,e as a,s as j,h as k,g as b,t as V,x as _e,v as fe,f as S,p as pe,F as ye,i as me,n as F,E as v,y as he,z as ge}from"./index-CWN5yz9-.js";import{f as W,g as ke}from"./store-cGjVPjwr.js";/* empty css */const w=$=>(he("data-v-16249cbf"),$=$(),ge(),$),be=w(()=>a("h4",null,"选择支付方式",-1)),we={class:"dra-body"},xe={class:"header"},Ce={key:0,style:{display:"inline-block","margin-right":"20px"}},Ve={style:{display:"inline-block","margin-right":"20px"}},Se=w(()=>a("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"原价:",-1)),Ee={style:{color:"#f5222d","padding-bottom":"2rem"}},Pe={style:{"font-size":"1.6rem"}},$e={style:{display:"inline-block"}},ze=w(()=>a("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"活动折扣:",-1)),Fe={style:{color:"#f5222d","padding-bottom":"2rem"}},Be={style:{"font-size":"1.6rem"}},De={style:{display:"inline-block"}},Le=w(()=>a("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),Te={style:{color:"#f5222d","padding-bottom":"2rem"}},je={style:{"font-size":"1.6rem"}},Ne={key:0,"element-loading-text":"支付中",class:"card1"},Re=w(()=>a("div",{class:"tips"},null,-1)),Ae={key:1,class:"card2"},Ie={class:"drawer-body"},Ue={class:"counter"},Ke={class:"received"},Me={key:0},Oe={key:1,style:{"font-size":"1rem",color:"#999"}},Ge={key:0,class:"balance"},We={class:"money"},qe=w(()=>a("div",{class:"tips"},"按回车(Enter)确认支付",-1)),He={key:1,class:"balance"},Je=w(()=>a("div",null,"不够找零, 请支付更多金额",-1)),Qe=w(()=>a("div",{class:"tips"},"按下小键盘输入金额",-1)),Xe=[Je,Qe],Ye={class:"keypad"},Ze={class:"left"},es={class:"right"},ss={style:{width:"100%",display:"flex","justify-content":"center"}},as={__name:"pay",emits:["paySuccess"],setup($,{expose:q,emit:H}){const r=o(!1),_=o(1),l=o(""),f=o("");ie();const J=()=>{p()},Q=()=>{F(()=>{setTimeout(()=>{var s;y.value=!1,l.value="",N.value=!0,(s=f.value)==null||s.focus(),x(_.value)},300)})},x=s=>{_.value=s,_.value==2?window.addEventListener("keydown",T):(window.removeEventListener("keydown",T),F(()=>{var e;l.value="",(e=f.value)==null||e.focus()}))},n=o({}),B=o([]),D=o(!1),X=s=>{n.value=s.data,B.value=s.cart_id,D.value=s.isRePay||!1},Y=s=>{n.value.total=s.price,se.value=s.order_id},Z=H,N=o(!1),ee=o(["1","2","3","4","5","6","7","8","9","0","00","."]),R=/^(10|11|12|13|14|15)\d{16}$/,A=/^(25|26|27|28|29|30)\d{14,22}$/,se=o(""),ae=()=>{if(y.value=!0,f.value.blur(),D.value)I();else{let s;if(R.test(l.value))s="9";else if(A.test(l.value))s="13";else return y.value=!1,l.value="",f.value.focus(),v.error("请输入正确的支付码");W({key:n.value.key,cart_id:B.value,pay_type:s,auth_code:l.value}).then(e=>{e.data.out_trade_no&&e.msg=="支付成功"?(r.value=!1,v({message:"支付成功",type:"success"}),p(e.data)):e.msg=="用户支付中"&&e.code==1&&(v.warning(e.msg),h.on("pay_success",t=>{v({message:"支付成功",type:"success"}),setTimeout(()=>{h.off("pay_success")},200),r.value=!1,p(t)}))}).catch(e=>{y.value=!1,F(()=>{var t;(t=f.value)==null||t.focus()})})}},I=()=>{let s=17;if(_.value==1)if(R.test(l.value))s="9";else if(A.test(l.value))s="13";else return y.value=!1,l.value="",f.value.focus(),v.error("请输入正确的支付码");ke({order_id:n.value.order_id,pay_type:s,auth_code:l.value}).then(e=>{var t;(t=e.msg)!=null&&t.includes("成功")?(r.value=!1,v({message:"支付成功",type:"success"}),p()):e.msg=="用户支付中"&&e.code==1&&(v.warning(e.msg),h.on("pay_success",C=>{v({message:"支付成功",type:"success"}),setTimeout(()=>{h.off("pay_success")},200),r.value=!1,p(C)}))}).catch(e=>{l.value="",y.value=!1,F(()=>{var t;(t=f.value)==null||t.focus()})})};o(0);const p=s=>{var e;window.removeEventListener("keydown",T),N.value=!1,y.value=!1,l.value="",c.value="",m.value=[],(e=f.value)==null||e.blur(),Z("paySuccess",s),r.value=!1},y=o(!1);q({drawer:r,setForm:X,setRePay:Y,beforeClose:p});const m=o([]),c=o(""),E=ue(()=>+c.value>0?(c.value-n.value.total).toFixed(2):-1),U=o(!1),L=s=>{s===-1?m.value=[]:m.value.pop(),c.value=m.value.length?m.value.join(""):0},i=s=>{U.value===!1&&(c.value="",U.value=!0);let e=String(c.value).indexOf(".")+1,t=String(c.value).length-e;console.log(e,t),(e===0||t<2)&&(m.value.join("")<=9999999&&m.value.push(s),c.value=m.value.join("")>99999999?99999999:m.value.join(""))},K=()=>{if(E.value===""||E.value===null||E.value===void 0||+c.value<+n.value.total)return v.error("收款金额应该大于等于应收金额");D.value?I():W({cart_id:B.value,pay_type:"17"}).then(s=>{r.value=!1,v({message:s.msg,type:"success"}),x(1),p()}).catch(s=>{y.value=!1})},T=s=>{let t=(s||window.event).keyCode;if(t==37)return x(2);if(t==120)return h.emit("F9");if(t==27)return p();switch(s.stopPropagation(),s.preventDefault(),t){case 96:case 48:i(0);break;case 97:case 49:i(1);break;case 98:case 50:i(2);break;case 99:case 51:i(3);break;case 100:case 52:i(4);break;case 101:case 53:i(5);break;case 102:case 54:i(6);break;case 103:case 55:i(7);break;case 104:case 56:i(8);break;case 105:case 57:i(9);break;case 110:i(".");break;case 190:i(".");break;case 8:L();break;case 13:K();break}},z=o(!1),M=()=>{if(!(!r.value||z.value&&l.value.length>0)&&_.value==2)return x(1)},O=()=>{if(!(!r.value||z.value&&l.value.length>0)&&_.value==1)return x(2)};return re(()=>{h.on("left",M),h.on("right",O)}),de(()=>{h.off("left",M),h.off("right",O)}),(s,e)=>{const t=P("el-input"),C=P("el-button"),te=P("Delete"),le=P("el-icon"),oe=P("el-drawer"),ne=ve("loading");return d(),G(oe,{size:"60rem",modelValue:r.value,"onUpdate:modelValue":e[6]||(e[6]=u=>r.value=u),direction:"rtl",onOpen:Q,"before-close":p},{header:g(()=>[be]),default:g(()=>[a("div",we,[a("div",xe,[a("div",{class:j(["left",{active:_.value==1}]),onClick:e[0]||(e[0]=u=>x(1))}," 微信/支付宝 ",2),a("div",{class:j(["right",{active:_.value==2}]),onClick:e[1]||(e[1]=u=>x(2))}," 现金收款 ",2)]),a("div",null,[n.value.activities==1?(d(),k("div",Ce,[a("div",Ve,[Se,a("div",Ee,[b(" ¥"),a("span",Pe,V(n.value.original_price),1)])]),a("div",$e,[ze,a("div",Fe,[b(V(n.value.activity)+"¥",1),a("span",Be,V(n.value.activity_price),1)])])])):_e("",!0),a("div",De,[Le,a("div",Te,[b(" ¥"),a("span",je,V(n.value.pay_price),1)])])]),_.value==1?fe((d(),k("div",Ne,[S(t,{ref_key:"codeRef",ref:f,modelValue:l.value,"onUpdate:modelValue":e[2]||(e[2]=u=>l.value=u),autofocus:"",class:"code-input",placeholder:"请点击输入框聚焦扫码或输入编码号",onKeyup:pe(ae,["enter"]),onFocus:e[3]||(e[3]=u=>z.value=!0),onBlur:e[4]||(e[4]=u=>z.value=!1)},null,8,["modelValue"]),Re])),[[ne,y.value]]):(d(),k("div",Ae,[a("div",Ie,[a("div",Ue,[a("div",Ke,[c.value?(d(),k("span",Me,V(c.value),1)):(d(),k("span",Oe,"按下键盘输入客户支付金额"))]),E.value>=0?(d(),k("div",Ge,[a("div",null,[b(" 需找零(元)"),a("span",We,"¥"+V(E.value),1)]),qe])):(d(),k("div",He,Xe)),a("div",Ye,[a("div",Ze,[(d(!0),k(ye,null,me(ee.value,u=>(d(),G(C,{key:u,onClick:ts=>i(u)},{default:g(()=>[b(V(u),1)]),_:2},1032,["onClick"]))),128))]),a("div",es,[S(C,{onClick:L},{default:g(()=>[S(le,null,{default:g(()=>[S(te)]),_:1})]),_:1}),S(C,{onClick:e[5]||(e[5]=u=>L(-1))},{default:g(()=>[b("C")]),_:1}),S(C,{class:j(["enter",{"enter-disable":+c.value<+n.value.total}]),disabled:+c.value<+n.value.total,onClick:K},{default:g(()=>[b(" 确认 ")]),_:1},8,["class","disabled"])])])])])]))])]),footer:g(()=>[a("div",ss,[S(C,{class:"cancel-btn",onClick:J},{default:g(()=>[b("取消收款")]),_:1})])]),_:1},8,["modelValue"])}}},cs=ce(as,[["__scopeId","data-v-16249cbf"]]);export{cs as p};