Commit 1fc64dd1 by sunchao

滑动解锁后出现登录信息框

parent cce68b18
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
<div id="dragContainer" class="dragContainer" #dragContainer> <div id="dragContainer" class="dragContainer" #dragContainer>
<div id="dragBg"></div> <div id="dragBg"></div>
<div id="dragText"></div> <div id="dragText"></div>
<div id="dragHandler" class="dragHandlerBg slideController"></div> <div id="dragHandler" class="dragHandlerBg slideController" #dragHandler></div>
</div> </div>
<div *ngIf="isVertifySucc == true" style="color: red;text-align: center;margin-top: 25px;">请先滑动解锁后再登录</div>
<div class="weui-cells__group weui-cells__group_form" *ngIf="isVertifySucc == false"> <div class="weui-cells__group weui-cells__group_form" *ngIf="isVertifySucc == false">
<div class="weui-cells weui-cells_form"> <div class="weui-cells weui-cells_form">
<div class="weui-cell" style="padding:10px 0px"> <div class="weui-cell" style="padding:10px 0px">
......
...@@ -10,6 +10,7 @@ import { LifeCommonService } from '../../common/life-common.service'; ...@@ -10,6 +10,7 @@ import { LifeCommonService } from '../../common/life-common.service';
}) })
export class LoginComponent implements OnInit, OnDestroy { export class LoginComponent implements OnInit, OnDestroy {
@ViewChild('dragContainer') dragContainer: ElementRef; @ViewChild('dragContainer') dragContainer: ElementRef;
@ViewChild('dragHandler') dragHandler: ElementRef;
MOBILE_REGEXP = /^(1)\d{10}$/; MOBILE_REGEXP = /^(1)\d{10}$/;
sendCodeHtml: string = '获取验证码'; sendCodeHtml: string = '获取验证码';
timer: any; timer: any;
...@@ -24,7 +25,6 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -24,7 +25,6 @@ export class LoginComponent implements OnInit, OnDestroy {
redirect: any; redirect: any;
dragBg:any; dragBg:any;
dragText:any; dragText:any;
dragHandler:any;
maxHandlerOffset:any; maxHandlerOffset:any;
isVertifySucc:boolean = true; isVertifySucc:boolean = true;
left:any; left:any;
...@@ -57,9 +57,9 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -57,9 +57,9 @@ export class LoginComponent implements OnInit, OnDestroy {
// //获取滑动验证容器文本 // //获取滑动验证容器文本
this.dragText = document.getElementById("dragText"); this.dragText = document.getElementById("dragText");
// //获取滑块 // //获取滑块
this.dragHandler = document.getElementsByClassName("slideController")[0]; // this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
// //滑块的最大偏移量 = 滑动验证容器文本长度 - 滑块长度 // //滑块的最大偏移量 = 滑动验证容器文本长度 - 滑块长度
this.maxHandlerOffset = this.dragContainer.nativeElement.clientWidth - this.dragHandler.clientWidth; this.maxHandlerOffset = this.dragContainer.nativeElement.clientWidth - this.dragHandler.nativeElement.clientWidth;
this.initDrag(); this.initDrag();
this.len = (window.innerWidth-document.body.clientWidth)/2; this.len = (window.innerWidth-document.body.clientWidth)/2;
...@@ -197,11 +197,11 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -197,11 +197,11 @@ export class LoginComponent implements OnInit, OnDestroy {
this.dragText.textContent = "拖动滑块验证"; this.dragText.textContent = "拖动滑块验证";
//给滑块添加鼠标按下监听 //给滑块添加鼠标按下监听
if(this.deviceType == 2 || this.deviceType == 3){ if(this.deviceType == 2 || this.deviceType == 3){
this.dragHandler.addEventListener("touchstart", ()=>{ this.dragHandler.nativeElement.addEventListener("touchstart", ()=>{
this.onDragHandlerMouseDown() this.onDragHandlerMouseDown()
},false); },false);
}else{ }else{
this.dragHandler.addEventListener("mousedown", ()=>{ this.dragHandler.nativeElement.addEventListener("mousedown", ()=>{
this.onDragHandlerMouseDown() this.onDragHandlerMouseDown()
}); });
} }
...@@ -222,13 +222,13 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -222,13 +222,13 @@ export class LoginComponent implements OnInit, OnDestroy {
}else{ }else{
document.querySelector('#dragHandler').classList.add('slideController'); document.querySelector('#dragHandler').classList.add('slideController');
//获取滑块 //获取滑块
this.dragHandler = document.getElementsByClassName("slideController")[0]; this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
//鼠标移动监听 //鼠标移动监听
this.dragHandler.addEventListener("mousemove",(e)=>{ this.dragHandler.nativeElement.addEventListener("mousemove",(e)=>{
this.onDragHandlerMouseMove(e); this.onDragHandlerMouseMove(e);
}); });
//鼠标松开监听 //鼠标松开监听
this.dragHandler.addEventListener("mouseup", ()=>{this.onDragHandlerMouseUp}); this.dragHandler.nativeElement.addEventListener("mouseup", ()=>{this.onDragHandlerMouseUp});
} }
} }
...@@ -248,12 +248,12 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -248,12 +248,12 @@ export class LoginComponent implements OnInit, OnDestroy {
*/ */
//滑块移动量 //滑块移动量
if(this.deviceType == 2 || this.deviceType == 3){ if(this.deviceType == 2 || this.deviceType == 3){
this.left = touch.clientX - this.dragHandler.clientWidth / 2; this.left = touch.clientX - this.dragHandler.nativeElement.clientWidth / 2;
}else{ }else{
//获取滑块 //获取滑块
this.dragHandler = document.getElementsByClassName("slideController")[0]; this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
if(this.dragHandler){ if(this.dragHandler.nativeElement){
this.left = touch.clientX - this.dragHandler.clientWidth / 2 - this.len; this.left = touch.clientX - this.dragHandler.nativeElement.clientWidth / 2 - this.len;
}else{ }else{
this.left = 0; this.left = 0;
} }
...@@ -266,11 +266,11 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -266,11 +266,11 @@ export class LoginComponent implements OnInit, OnDestroy {
this.left = this.maxHandlerOffset; this.left = this.maxHandlerOffset;
this.verifySucc(); this.verifySucc();
} }
if(this.dragHandler){ if(this.dragHandler.nativeElement){
//滑块移动量 //滑块移动量
this.dragHandler.style.left = this.left + "px"; this.dragHandler.nativeElement.style.left = this.left + "px";
//绿色背景的长度 //绿色背景的长度
this.dragBg.style.width = this.dragHandler.style.left; this.dragBg.style.width = this.dragHandler.nativeElement.style.left;
} }
} }
...@@ -283,14 +283,14 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -283,14 +283,14 @@ export class LoginComponent implements OnInit, OnDestroy {
document.removeEventListener("touchend", this.onDragHandlerMouseUp); document.removeEventListener("touchend", this.onDragHandlerMouseUp);
}else{ }else{
//移除鼠标移动监听 //移除鼠标移动监听
this.dragHandler.removeEventListener("mousemove", this.onDragHandlerMouseMove); document.removeEventListener("mousemove", this.onDragHandlerMouseMove);
//移除鼠标松开监听 //移除鼠标松开监听
this.dragHandler.removeEventListener("mouseup", this.onDragHandlerMouseUp); document.removeEventListener("mouseup", this.onDragHandlerMouseUp);
document.querySelector('#dragHandler').classList.remove('slideController'); document.querySelector('#dragHandler').classList.remove('slideController');
} }
if(this.isVertifySucc){ if(this.isVertifySucc){
//初始化滑块移动量 //初始化滑块移动量
this.dragHandler.style.left = 0; this.dragHandler.nativeElement.style.left = 0;
//初始化绿色背景 //初始化绿色背景
this.dragBg.style.width = 0; this.dragBg.style.width = 0;
} }
...@@ -301,15 +301,15 @@ export class LoginComponent implements OnInit, OnDestroy { ...@@ -301,15 +301,15 @@ export class LoginComponent implements OnInit, OnDestroy {
this.isVertifySucc = false; this.isVertifySucc = false;
this.dragText.textContent = "验证通过"; this.dragText.textContent = "验证通过";
this.dragText.style.color = "white"; this.dragText.style.color = "white";
this.dragHandler.setAttribute("class", "dragHandlerOkBg"); this.dragHandler.nativeElement.setAttribute("class", "dragHandlerOkBg");
if(this.deviceType == 2 || this.deviceType == 3){ if(this.deviceType == 2 || this.deviceType == 3){
this.dragHandler.removeEventListener("touchstart", this.onDragHandlerMouseDown); this.dragHandler.nativeElement.removeEventListener("touchstart", this.onDragHandlerMouseDown);
document.removeEventListener("touchmove", this.onDragHandlerMouseMove); document.removeEventListener("touchmove", this.onDragHandlerMouseMove);
document.removeEventListener("touchend", this.onDragHandlerMouseUp); document.removeEventListener("touchend", this.onDragHandlerMouseUp);
}else{ }else{
this.dragHandler.removeEventListener("mousedown", this.onDragHandlerMouseDown); this.dragHandler.nativeElement.removeEventListener("mousedown", this.onDragHandlerMouseDown);
this.dragHandler.removeEventListener("mousemove", this.onDragHandlerMouseMove); this.dragHandler.nativeElement.removeEventListener("mousemove", this.onDragHandlerMouseMove);
this.dragHandler.removeEventListener("mouseup", this.onDragHandlerMouseUp); this.dragHandler.nativeElement.removeEventListener("mouseup", this.onDragHandlerMouseUp);
} }
setTimeout(()=>{ setTimeout(()=>{
this.dragContainer.nativeElement.style.display = 'none' this.dragContainer.nativeElement.style.display = 'none'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment