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

2 lines
8.1 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{A as v,_ as de,r as n,u as ve,D as _e,o as pe,m as j,a as fe,b as I,j as me,c as k,d as X,w as b,e as o,l as q,g as L,t as F,p as ge,h as S,f as A,k as ye,F as he,i as ke,n as V,E as m,s as be,v as we}from"./index-CDJP75me.js";function Ze(t){return v.post("user/cart/create",t)}function ea(t){return v.get("user/cart/lst",{params:t})}function aa(t,i){return v.post(`user/cart/change/${t}`,i)}function sa(t){return v.post("v2/order/check",t)}function ta(t){return v.post("user/cart/delete",t)}function Y(t){return v.post("v2/order/create",t)}function Ce(t,i){return v.post(`order/pay/${t}`,i)}function Se(t){return v.get("micropay_query",{params:t})}function oa(t,i){return v.get(`admin/${t}/order_list`,{params:i})}function la(t,i){return v.get(`verifier/${t}/order/${i}`)}function ra(t){return v.get("order_lading",{params:t})}const T=t=>{if(!t)return;let i=new window.SpeechSynthesisUtterance(t);window.speechSynthesis.speak(i)},D=t=>(be("data-v-f7abe660"),t=t(),we(),t),Ae=D(()=>o("h4",null,"选择支付方式",-1)),xe={class:"dra-body"},$e={class:"header"},Le=D(()=>o("div",{style:{color:"#999",padding:"2rem 0 0.3rem 0"}},"应收金额(元):",-1)),Ve={style:{color:"#f5222d","padding-bottom":"2rem"}},De={style:{"font-size":"1.6rem"}},Ee={key:0,"element-loading-text":"支付中",class:"card1"},Be=D(()=>o("div",{class:"tips"},null,-1)),je={key:1,class:"card2"},Ie={class:"drawer-body"},Pe={class:"counter"},Fe={class:"received"},Te={key:0},Ue={key:1,style:{"font-size":"1rem",color:"#999"}},ze={key:0,class:"balance"},Ne={class:"money"},Oe=D(()=>o("div",{class:"tips"},"按回车(Enter)确认支付",-1)),qe={key:1,class:"balance"},Re=D(()=>o("div",null,"不够找零, 请支付更多金额",-1)),Ke=D(()=>o("div",{class:"tips"},"按下小键盘输入金额",-1)),Me=[Re,Ke],We={class:"keypad"},Ge={class:"left"},He={class:"right"},Je={style:{width:"100%",display:"flex","justify-content":"center"}},Qe={__name:"pay",emits:["paySuccess"],setup(t,{expose:i,emit:Z}){const g=n(!1),y=n(1),l=n(""),d=n(""),R=ve(),ee=()=>{w()},ae=()=>{V(()=>{setTimeout(()=>{var e;u.value=!1,l.value="",z.value=!0,(e=d.value)==null||e.focus(),x(y.value)},300)})},x=e=>{y.value=e,y.value==2?window.addEventListener("keydown",O):(window.removeEventListener("keydown",O),V(()=>{var a;l.value="",(a=d.value)==null||a.focus()}))},h=n({}),U=n([]),se=e=>{h.value=e.data,U.value=e.cart_id},te=e=>{h.value.order_price=e.price,_.value=e.order_id},oe=Z,z=n(!1),le=n(["1","2","3","4","5","6","7","8","9","0","00","."]);let $=0;const K=/^(10|11|12|13|14|15)\d{16}$/,M=/^(25|26|27|28|29|30)\d{14,22}$/,_=n(""),re=()=>{if(u.value=!0,d.value.blur(),_.value)W(_.value);else{let e;if(K.test(l.value))e="micropay";else if(M.test(l.value))e="alipayBar";else return u.value=!1,l.value="",d.value.focus(),m.error("请输入正确的支付码");Y({address_id:"",key:h.value.key,cart_id:U.value,pay_type:e,auth_code:l.value,staff_id:R.userInfo.service.service_id}).then(a=>{if(a.status==200&&(a.message=="支付成功"||a.message=="success"))g.value=!1,m({message:a.message=="success"?"支付成功":a.message,type:"success"}),T(a.data.message||a.data.result.message),w();else if(a.data.group_order_sn)_.value=a.data.group_order_id,E.value=0,$=0,P(a.data.group_order_sn);else return _.value=a.data.result.order_id,u.value=!1,m({message:a.message,type:"error"})}).catch(a=>{u.value=!1,V(()=>{var s;(s=d.value)==null||s.focus()})})}},W=e=>{let a;if(y.value==1){let s;if(K.test(l.value))s="micropay";else if(M.test(l.value))s="alipayBar";else return u.value=!1,l.value="",d.value.focus(),m.error("请输入正确的支付码");a={type:s,auth_code:l.value}}else a={type:"cash_payment"};Ce(e,a).then(s=>{s.status==200&&(s.message=="支付成功"||s.message=="success")?(g.value=!1,m({message:s.message=="success"?"支付成功":s.message,type:"success"}),T(s.data.message||s.data.result.message),w()):(_.value=s.data.group_order_id,E.value=0,$=0,P(s.data.group_order_sn))}).catch(s=>{l.value="",u.value=!1,V(()=>{var C;(C=d.value)==null||C.focus()})})},E=n(0),P=e=>{e&&(E.value++,$+=5e3,Se({order_sn:e}).then(a=>{a.data.paid==1||a.message=="支付成功"?(m({message:a.message,type:"success"}),T(a.data.message),w()):(m({message:a.message,type:"error"}),l.value="",u.value=!1,V(()=>{var s;(s=d.value)==null||s.focus()}))}).catch(a=>{z.value&&E.value<3?setTimeout(()=>{P(e)},15e3-$>0?15e3-$:0):(l.value="",u.value=!1,V(()=>{var s;(s=d.value)==null||s.focus()}))}))},w=()=>{var e;window.removeEventListener("keydown",O),z.value=!1,u.value=!1,l.value="",r.value="",p.value=[],(e=d.value)==null||e.blur(),oe("paySuccess"),g.value=!1},u=n(!1);i({drawer:g,setForm:se,setRePay:te,beforeClose:w});const p=n([]),r=n(""),B=_e(()=>+r.value>0?(r.value-h.value.order_price).toFixed(2):-1),G=n(!1),N=e=>{e===-1?p.value=[]:p.value.pop(),r.value=p.value.length?p.value.join(""):0},c=e=>{G.value===!1&&(r.value="",G.value=!0);let a=String(r.value).indexOf(".")+1,s=String(r.value).length-a;console.log(a,s),(a===0||s<2)&&(p.value.join("")<=9999999&&p.value.push(e),r.value=p.value.join("")>99999999?99999999:p.value.join(""))},H=()=>{if(B.value===""||B.value===null||B.value===void 0||+r.value<+h.value.order_price)return m.error("收款金额应该大于等于应收金额");_.value?W(_.value):Y({address_id:"",key:h.value.key,cart_id:U.value,pay_type:"cash_payment",staff_id:R.userInfo.service.service_id}).then(e=>{if(e.status==200&&e.message=="支付成功")g.value=!1,m({message:e.message,type:"success"}),T(e.data.message),w();else if(e.data.group_order_sn)_.value=e.data.group_order_id,E.value=0,$=0,P(e.data.group_order_sn);else return _.value=e.data.result.order_id,r.value="",p.value=[],u.value=!1,m({message:e.message,type:"error"})}).catch(e=>{u.value=!1})},O=e=>{let s=(e||window.event).keyCode;if(s==37)return x(2);if(s==120)return j.emit("F9");if(s==27)return w();switch(e.stopPropagation(),e.preventDefault(),s){case 96:case 48:c(0);break;case 97:case 49:c(1);break;case 98:case 50:c(2);break;case 99:case 51:c(3);break;case 100:case 52:c(4);break;case 101:case 53:c(5);break;case 102:case 54:c(6);break;case 103:case 55:c(7);break;case 104:case 56:c(8);break;case 105:case 57:c(9);break;case 110:c(".");break;case 190:c(".");break;case 8:N();break;case 13:H();break}},J=()=>{if(g.value&&y.value==2)return x(1)},Q=()=>{if(g.value&&y.value==1)return x(2)};return pe(()=>{j.on("left",J),j.on("right",Q)}),fe(()=>{j.off("left",J),j.off("right",Q)}),(e,a)=>{const s=I("el-input"),C=I("el-button"),ne=I("Delete"),ue=I("el-icon"),ce=I("el-drawer"),ie=me("loading");return k(),X(ce,{size:800,modelValue:g.value,"onUpdate:modelValue":a[4]||(a[4]=f=>g.value=f),direction:"rtl",onOpen:ae,"before-close":w},{header:b(()=>[Ae]),default:b(()=>[o("div",xe,[o("div",$e,[o("div",{class:q(["left",{active:y.value==1}]),onClick:a[0]||(a[0]=f=>x(1))}," 微信/支付宝 ",2),o("div",{class:q(["right",{active:y.value==2}]),onClick:a[1]||(a[1]=f=>x(2))}," 现金收款 ",2)]),Le,o("div",Ve,[L(" ¥"),o("span",De,F(h.value.order_price),1)]),y.value==1?ge((k(),S("div",Ee,[A(s,{ref_key:"codeRef",ref:d,modelValue:l.value,"onUpdate:modelValue":a[2]||(a[2]=f=>l.value=f),autofocus:"",class:"code-input",placeholder:"请点击输入框聚焦扫码或输入编码号",onKeyup:ye(re,["enter"])},null,8,["modelValue"]),Be])),[[ie,u.value]]):(k(),S("div",je,[o("div",Ie,[o("div",Pe,[o("div",Fe,[r.value?(k(),S("span",Te,F(r.value),1)):(k(),S("span",Ue,"按下键盘输入客户支付金额"))]),B.value>=0?(k(),S("div",ze,[o("div",null,[L("需找零(元)"),o("span",Ne,"¥"+F(B.value),1)]),Oe])):(k(),S("div",qe,Me)),o("div",We,[o("div",Ge,[(k(!0),S(he,null,ke(le.value,f=>(k(),X(C,{key:f,onClick:Xe=>c(f)},{default:b(()=>[L(F(f),1)]),_:2},1032,["onClick"]))),128))]),o("div",He,[A(C,{onClick:N},{default:b(()=>[A(ue,null,{default:b(()=>[A(ne)]),_:1})]),_:1}),A(C,{onClick:a[3]||(a[3]=f=>N(-1))},{default:b(()=>[L("C")]),_:1}),A(C,{class:q(["enter",{"enter-disable":+r.value<+h.value.order_price}]),disabled:+r.value<+h.value.order_price,onClick:H},{default:b(()=>[L(" 确认 ")]),_:1},8,["class","disabled"])])])])])]))])]),footer:b(()=>[o("div",Je,[A(C,{class:"cancel-btn",onClick:ee},{default:b(()=>[L("取消收款")]),_:1})])]),_:1},8,["modelValue"])}}},na=de(Qe,[["__scopeId","data-v-f7abe660"]]);export{ea as a,aa as b,ta as c,Ze as d,oa as e,ra as f,Se as g,sa as o,na as p,la as v};