cashier-mer/build/assets/pay-BMjw3Xka.js

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