3 lines
6.3 KiB
JavaScript
3 lines
6.3 KiB
JavaScript
var K=(s,R,g)=>new Promise((O,d)=>{var p=r=>{try{h(g.next(r))}catch(c){d(c)}},$=r=>{try{h(g.throw(r))}catch(c){d(c)}},h=r=>r.done?O(r.value):Promise.resolve(r.value).then(p,$);h((g=g.apply(s,R)).next())});import{am as re,an as ce,b0 as ve,$ as q}from"./bootstrap-DsjPfOC_.js";import{m as de,bt as he,r as fe,b9 as t,b7 as me,aa as ge,v as pe,ad as M,b2 as J,ac as _,ae as u,aT as m,bL as be,j as oe,u as ye,bJ as we,aR as ne,bp as G,n as xe,ee as ue}from"../jse/index-index-CO0ZsLf2.js";import{r as ke}from"./util-BwSl71C9.js";const Se={style:{position:"relative"}},$e=["src"],ze=["textContent"],Te=["textContent"],Be=["src"],Ie=de({__name:"verify-slide",props:{arith:{},barSize:{default:()=>({height:"40px",width:"310px"})},blockSize:{default:()=>({height:"50px",width:"50px"})},captchaType:{default:"blockPuzzle"},explain:{default:""},figure:{},imgSize:{default:()=>({height:"155px",width:"310px"})},mode:{default:"fixed"},space:{default:5},type:{default:"1"},checkCaptchaApi:{},getCaptchaApi:{}},emits:["onSuccess","onError","onClose"],setup(s,{expose:R,emit:g}){const O=s,d=g,{blockSize:p,captchaType:$,explain:h,mode:r,checkCaptchaApi:c,getCaptchaApi:b}=he(O),{proxy:o}=fe(),y=t(),V=t(),Q=t(),U=t(),z=t(),Y=t(),Z=t(),f=t(),T=t(),A=t(),i=me({barHeight:"0px",barWidth:"0px",imgHeight:"0px",imgWidth:"0px"}),B=t(),C=t(),w=t(),x=t("#ddd"),k=t(),W=t("icon-right"),N=t(!1),S=t(!1),X=t(!0),F=t(),P=t(),j=t(0),E=ge(()=>o==null?void 0:o.$el.querySelector(".verify-bar-area"));function ee(){T.value=h.value===""?q("ui.captcha.sliderDefaultText"):h.value,ae(),xe(()=>{var l;const{barHeight:a,barWidth:e,imgHeight:n,imgWidth:v}=ke(o);i.imgHeight=n,i.imgWidth=v,i.barHeight=a,i.barWidth=e,(l=o==null?void 0:o.$parent)==null||l.$emit("ready",o)}),window.removeEventListener("touchmove",I),window.removeEventListener("mousemove",I),window.removeEventListener("touchend",L),window.removeEventListener("mouseup",L),window.addEventListener("touchmove",I),window.addEventListener("mousemove",I),window.addEventListener("touchend",L),window.addEventListener("mouseup",L)}pe(()=>{ee(),o==null||o.$el.addEventListener("selectstart",()=>!1)});function te(a){var n;const e=(a.touches?(n=a.touches[0])==null?void 0:n.pageX:a.clientX)||0;j.value=Math.floor(e-E.value.getBoundingClientRect().left),Y.value=Date.now(),S.value===!1&&(T.value="",w.value="#337ab7",x.value="#337AB7",k.value="#fff",a.stopPropagation(),N.value=!0)}function I(a){var e;if(N.value&&S.value===!1){const n=(a.touches?(e=a.touches[0])==null?void 0:e.pageX:a.clientX)||0,v=E.value.getBoundingClientRect().left;let l=n-v;l>=E.value.offsetWidth-Number.parseInt(p.value.width)/2-2&&(l=E.value.offsetWidth-Number.parseInt(p.value.width)/2-2),l<=0&&(l=Number.parseInt(p.value.width)/2),B.value=`${l-j.value}px`,C.value=`${l-j.value}px`}}function L(){var a;if(Z.value=Date.now(),N.value&&S.value===!1){let e=Number.parseInt((B.value||"").replace("px",""));e=e*310/Number.parseInt(i.imgWidth);const n={captchaType:$.value,pointJson:y.value?ue.encrypt(JSON.stringify({x:e,y:5}),y.value):JSON.stringify({x:e,y:5}),token:z.value};(a=c==null?void 0:c.value)==null||a.call(c,n).then(v=>{if(v.data.repCode==="0000"){w.value="#5cb85c",x.value="#5cb85c",k.value="#fff",W.value="icon-check",X.value=!1,S.value=!0,r.value==="pop"&&setTimeout(()=>{d("onClose"),H()},1500),V.value=!0,f.value=`${((Z.value-Y.value)/1e3).toFixed(2)}s
|
|
${q("ui.captcha.title")}`;const D=y.value?ue.encrypt(`${z.value}---${JSON.stringify({x:e,y:5})}`,y.value):`${z.value}---${JSON.stringify({x:e,y:5})}`;setTimeout(()=>{f.value="",d("onSuccess",{captchaVerification:D}),d("onClose")},1e3)}else w.value="#d9534f",x.value="#d9534f",k.value="#fff",W.value="icon-close",V.value=!1,setTimeout(()=>{H()},1e3),d("onError",o),f.value=q("ui.captcha.sliderRotateFailTip"),setTimeout(()=>{f.value=""},1e3)}),N.value=!1}}function H(){return K(this,null,function*(){X.value=!0,A.value="",F.value="left .3s",B.value=0,C.value=void 0,P.value="width .3s",x.value="#ddd",w.value="#fff",k.value="#000",W.value="icon-right",S.value=!1,yield ae(),setTimeout(()=>{P.value="",F.value="",T.value=h.value},300)})}function ae(){return K(this,null,function*(){var n,v,l,D,ie,se,le;const a={captchaType:$.value},e=yield(n=b==null?void 0:b.value)==null?void 0:n.call(b,a);((v=e==null?void 0:e.data)==null?void 0:v.repCode)==="0000"?(Q.value=`data:image/png;base64,${(D=(l=e==null?void 0:e.data)==null?void 0:l.repData)==null?void 0:D.originalImageBase64}`,U.value=`data:image/png;base64,${(se=(ie=e==null?void 0:e.data)==null?void 0:ie.repData)==null?void 0:se.jigsawImageBase64}`,z.value=e.data.repData.token,y.value=e.data.repData.secretKey):f.value=(le=e==null?void 0:e.data)==null?void 0:le.repMsg})}return R({init:ee,refresh:H}),(a,e)=>(J(),M("div",Se,[s.type==="2"?(J(),M("div",{key:0,style:m({height:`${Number.parseInt(i.imgHeight)+s.space}px`}),class:"verify-img-out"},[u("div",{style:m({width:i.imgWidth,height:i.imgHeight}),class:"verify-img-panel"},[u("img",{src:Q.value,alt:"",style:{display:"block",width:"100%",height:"100%"}},null,8,$e),be(u("div",{class:"verify-refresh",onClick:H},[oe(ye(ce),{icon:"lucide:refresh-ccw",class:"mr-2 size-5"})],512),[[re,X.value]]),oe(ve,{name:"tips"},{default:we(()=>[f.value?(J(),M("span",{key:0,class:ne([V.value?"suc-bg":"err-bg","verify-tips"])},G(f.value),3)):_("",!0)]),_:1})],4)],4)):_("",!0),u("div",{style:m({width:i.imgWidth,height:s.barSize.height,"line-height":s.barSize.height}),class:"verify-bar-area"},[u("span",{class:"verify-msg",textContent:G(T.value)},null,8,ze),u("div",{style:m({width:C.value!==void 0?C.value:s.barSize.height,height:s.barSize.height,"border-color":x.value,transition:P.value}),class:"verify-left-bar"},[u("span",{class:"verify-msg",textContent:G(A.value)},null,8,Te),u("div",{style:m({width:s.barSize.height,height:s.barSize.height,"background-color":w.value,left:B.value,transition:F.value}),class:"verify-move-block",onMousedown:te,onTouchstart:te},[u("i",{class:ne([[W.value],"iconfont verify-icon"]),style:m({color:k.value})},null,6),s.type==="2"?(J(),M("div",{key:0,style:m({width:`${Math.floor(Number.parseInt(i.imgWidth)*47/310)}px`,height:i.imgHeight,top:`-${Number.parseInt(i.imgHeight)+s.space}px`,"background-size":`${i.imgWidth} ${i.imgHeight}`}),class:"verify-sub-block"},[u("img",{src:U.value,alt:"",style:{display:"block",width:"100%",height:"100%","-webkit-user-drag":"none"}},null,8,Be)],4)):_("",!0)],36)],4)],4)]))}});export{Ie as default};
|