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

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