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