mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2026-01-05 19:48:10 +00:00
2 lines
6.4 KiB
JavaScript
2 lines
6.4 KiB
JavaScript
import{r as ie,a as G,b as ne,c as oe}from"./index-1a1af23f.js";import{Q as se,b3 as le,r as a,n as re,l as ce,R as de,aO as ue,h as C,c as W,x as c,a as o,Z as ve,_ as fe,e as he,w as ge,v as Q,t as D,C as j,b4 as me,aH as ye}from"./index-d3b02fcc.js";import{_ as be}from"./_plugin-vue_export-helper-c27b6911.js";const pe={name:"VerifySlide",props:{captchaType:{type:String},type:{type:String,default:"1"},mode:{type:String,default:"fixed"},vSpace:{type:Number,default:5},explain:{type:String,default:"向右滑动完成验证"},imgSize:{type:Object,default(){return{width:"310px",height:"155px"}}},blockSize:{type:Object,default(){return{width:"50px",height:"50px"}}},barSize:{type:Object,default(){return{width:"310px",height:"40px"}}}},setup(J,r){const{mode:n,captchaType:e,vSpace:Z,imgSize:U,barSize:d,type:Y,blockSize:I,explain:X}=se(J),{proxy:s}=le(),u=a(""),T=a(""),q=a(""),F=a(""),g=a(""),L=a(""),H=a(""),$=a(""),v=a(""),x=a(""),A=a(""),f=re({imgHeight:0,imgWidth:0,barHeight:0,barWidth:0}),ee=a(0),te=a(0),k=a(void 0),E=a(void 0),m=a(void 0),y=a("#ddd"),b=a(void 0),B=a("icon-right"),p=a(!1),h=a(!1),N=a(!0),O=a(""),M=a(""),R=a(0),w=ce(()=>s.$el.querySelector(".verify-bar-area"));function K(){x.value=X.value,P(),ye(()=>{const{imgHeight:t,imgWidth:i,barHeight:S,barWidth:l}=ie(s);f.imgHeight=t,f.imgWidth=i,f.barHeight=S,f.barWidth=l,s.$parent.$emit("ready",s)}),window.removeEventListener("touchmove",function(t){z(t)}),window.removeEventListener("mousemove",function(t){z(t)}),window.removeEventListener("touchend",function(){_()}),window.removeEventListener("mouseup",function(){_()}),window.addEventListener("touchmove",function(t){z(t)}),window.addEventListener("mousemove",function(t){z(t)}),window.addEventListener("touchend",function(){_()}),window.addEventListener("mouseup",function(){_()})}de(Y,()=>{K()}),ue(()=>{K(),s.$el.onselectstart=function(){return!1}});function ae(t){if(t=t||window.event,t.touches)var i=t.touches[0].pageX;else var i=t.clientX;R.value=Math.floor(i-w.value.getBoundingClientRect().left),L.value=+new Date,h.value==!1&&(x.value="",m.value="#337ab7",y.value="#337AB7",b.value="#fff",t.stopPropagation(),p.value=!0)}function z(t){if(t=t||window.event,p.value&&h.value==!1){if(t.touches)var i=t.touches[0].pageX;else var i=t.clientX;const S=w.value.getBoundingClientRect().left;let l=i-S;l>=w.value.offsetWidth-parseInt(parseInt(I.value.width)/2)-2&&(l=w.value.offsetWidth-parseInt(parseInt(I.value.width)/2)-2),l<=0&&(l=parseInt(parseInt(I.value.width)/2)),k.value=l-R.value+"px",E.value=l-R.value+"px"}}function _(){if(H.value=+new Date,p.value&&h.value==!1){let t=parseInt((k.value||"").replace("px",""));t=t*310/parseInt(f.imgWidth);const i={captchaType:e.value,captcha_code:u.value?G(JSON.stringify({x:t,y:5}),u.value):JSON.stringify({x:t,y:5}),captcha_key:g.value};ne(i).then(S=>{if(S.code==1){m.value="#5cb85c",y.value="#5cb85c",b.value="#fff",B.value="icon-check",N.value=!1,h.value=!0,n.value=="pop"&&setTimeout(()=>{s.$parent.clickShow=!1,V()},1500),T.value=!0,v.value=`${((H.value-L.value)/1e3).toFixed(2)}s验证成功`;const l=u.value?G(g.value+"---"+JSON.stringify({x:t,y:5}),u.value):g.value+"---"+JSON.stringify({x:t,y:5});setTimeout(()=>{v.value="",s.$parent.closeBox(),s.$parent.$emit("success",{captchaVerification:l})},1e3)}else m.value="#d9534f",y.value="#d9534f",b.value="#fff",B.value="icon-close",T.value=!1,setTimeout(function(){V()},1e3),s.$parent.$emit("error",s),v.value="验证失败",setTimeout(()=>{v.value=""},1e3)}),p.value=!1}}const V=()=>{N.value=!0,A.value="",O.value="left .3s",k.value=0,E.value=void 0,M.value="width .3s",y.value="#ddd",m.value="#fff",b.value="#000",B.value="icon-right",h.value=!1,P(),setTimeout(()=>{M.value="",O.value="",x.value=X.value},300)};function P(){const t={captchaType:e.value};oe(t).then(i=>{i.code==1?(q.value=i.data.originalImageBase64,F.value=i.data.jigsawImageBase64,g.value=i.data.token,u.value=i.data.secretKey):v.value=i.msg})}return{secretKey:u,passFlag:T,backImgBase:q,blockBackImgBase:F,backToken:g,startMoveTime:L,endMoveTime:H,tipsBackColor:$,tipWords:v,text:x,finishText:A,setSize:f,top:ee,left:te,moveBlockLeft:k,leftBarWidth:E,moveBlockBackgroundColor:m,leftBarBorderColor:y,iconColor:b,iconClass:B,status:p,isEnd:h,showRefresh:N,transitionLeft:O,transitionWidth:M,barArea:w,refresh:V,start:ae}}},we={style:{position:"relative"}},Se=["src"],xe=o("i",{class:"iconfont icon-refresh"},null,-1),ke=[xe],Be=["textContent"],ze=["textContent"],_e=["src"];function Ce(J,r,n,e,Z,U){return C(),W("div",we,[n.type==="2"?(C(),W("div",{key:0,class:"verify-img-out",style:c({height:parseInt(e.setSize.imgHeight)+n.vSpace+"px"})},[o("div",{class:"verify-img-panel",style:c({width:e.setSize.imgWidth,height:e.setSize.imgHeight})},[o("img",{src:"data:image/png;base64,"+e.backImgBase,alt:"",style:{width:"100%",height:"100%",display:"block"}},null,8,Se),ve(o("div",{class:"verify-refresh",onClick:r[0]||(r[0]=(...d)=>e.refresh&&e.refresh(...d))},ke,512),[[fe,e.showRefresh]]),he(me,{name:"tips"},{default:ge(()=>[e.tipWords?(C(),W("span",{key:0,class:Q(["verify-tips",e.passFlag?"suc-bg":"err-bg"])},D(e.tipWords),3)):j("",!0)]),_:1})],4)],4)):j("",!0),o("div",{class:"verify-bar-area",style:c({width:e.setSize.imgWidth,height:n.barSize.height,"line-height":n.barSize.height})},[o("span",{class:"verify-msg",textContent:D(e.text)},null,8,Be),o("div",{class:"verify-left-bar",style:c({width:e.leftBarWidth!==void 0?e.leftBarWidth:n.barSize.height,height:n.barSize.height,"border-color":e.leftBarBorderColor,transaction:e.transitionWidth})},[o("span",{class:"verify-msg",textContent:D(e.finishText)},null,8,ze),o("div",{class:"verify-move-block",onTouchstart:r[1]||(r[1]=(...d)=>e.start&&e.start(...d)),onMousedown:r[2]||(r[2]=(...d)=>e.start&&e.start(...d)),style:c({width:n.barSize.height,height:n.barSize.height,"background-color":e.moveBlockBackgroundColor,left:e.moveBlockLeft,transition:e.transitionLeft})},[o("i",{class:Q(["verify-icon iconfont",e.iconClass]),style:c({color:e.iconColor})},null,6),n.type==="2"?(C(),W("div",{key:0,class:"verify-sub-block",style:c({width:Math.floor(parseInt(e.setSize.imgWidth)*47/310)+"px",height:e.setSize.imgHeight,top:"-"+(parseInt(e.setSize.imgHeight)+n.vSpace)+"px","background-size":e.setSize.imgWidth+" "+e.setSize.imgHeight})},[o("img",{src:"data:image/png;base64,"+e.blockBackImgBase,alt:"",style:{width:"100%",height:"100%",display:"block","-webkit-user-drag":"none"}},null,8,_e)],4)):j("",!0)],36)],4)],4)])}const Le=be(pe,[["render",Ce]]);export{Le as default};
|