Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydLife
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sweet Zhang
ydLife
Commits
a7419f3d
Commit
a7419f3d
authored
Nov 03, 2021
by
sunchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
滑动验证后出现登录按钮
parent
3095a83c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
237 additions
and
6 deletions
+237
-6
src/app/auth/login/login.component.html
+7
-2
src/app/auth/login/login.component.scss
+62
-0
src/app/auth/login/login.component.ts
+166
-3
src/app/my/application-process/register/register.component.ts
+2
-1
No files found.
src/app/auth/login/login.component.html
View file @
a7419f3d
...
...
@@ -7,7 +7,12 @@
</div>
</div>
<div
class=
"weui-form__control-area"
>
<div
class=
"weui-cells__group weui-cells__group_form"
>
<div
id=
"dragContainer"
class=
"dragContainer"
#
dragContainer
>
<div
id=
"dragBg"
></div>
<div
id=
"dragText"
></div>
<div
id=
"dragHandler"
class=
"dragHandlerBg slideController"
></div>
</div>
<div
class=
"weui-cells__group weui-cells__group_form"
*
ngIf=
"isVertifySucc == false"
>
<div
class=
"weui-cells weui-cells_form"
>
<div
class=
"weui-cell"
style=
"padding:10px 0px"
>
<!-- <div class="weui-cell__hd"><label class="weui-label">手机号</label></div> -->
...
...
@@ -30,7 +35,7 @@
</div>
</div>
</div>
<div
class=
"weui-form__opr-area"
>
<div
class=
"weui-form__opr-area"
*
ngIf=
"isVertifySucc == false"
>
<a
class=
"weui-btn weui-btn_primary login"
href=
"javascript:"
id=
"showTooltips"
style=
"width:100%;padding: 10px 24px;"
(
click
)="
login
()"
>
登录
</a>
</div>
...
...
src/app/auth/login/login.component.scss
View file @
a7419f3d
*
{
touch-action
:
pan-y
;
}
.weui-form__control-area
{
margin
:
20px
0
45px
0
;
}
...
...
@@ -37,3 +41,61 @@
font-size
:
20px
;
}
/* 滑动控件容器,灰色背景 */
#dragContainer
{
position
:
relative
;
background
:
#e8e8e8
;
width
:
100%
;
height
:
50px
;
border
:
2px
solid
#e8e8e8
;
margin
:
0
auto
;
margin-bottom
:
10px
;
}
/* 滑块左边部分,绿色背景 */
#dragBg
{
position
:
absolute
;
background-color
:
#7ac23c
;
width
:
0px
;
height
:
100%
;
}
/* 滑动验证容器文本 */
#dragText
{
position
:
absolute
;
width
:
100%
;
height
:
100%
;
/* 文字水平居中 */
text-align
:
center
;
/* 文字垂直居中,这里不能用百分比,因为百分比是相对原始line-height的,而非div高度 */
line-height
:
50px
;
/* 文本不允许选中 */
user-select
:
none
;
-webkit-user-select
:
none
;
}
/* 滑块 */
#dragHandler
{
position
:
absolute
;
width
:
40px
;
height
:
100%
;
cursor
:
move
;
}
/* 滑块初始背景 */
.dragHandlerBg
{
background
:
#fff
no-repeat
center
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NTc3MiwgMjAxNC8wMS8xMy0xOTo0NDowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW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DlBRDI3NjRGMkQ2MTFFNEI5NDBCMjQ2M0ExMDQ1OUYiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTQgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDphNWEzMWNhMC1hYmViLTQxNWEtYTEwZS04Y2U5NzRlN2Q4YTEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NGQ4ZTVmOTMtOTZiNC00ZTVkLThhY2ItN2U2ODhmMjE1NmU2Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+k+sHwwAAASZJREFUeNpi/P//PwMyKD8uZw+kUoDYEYgloMIvgHg/EM/ptHx0EFk9I8wAoEZ+IDUPiIMY8IN1QJwENOgj3ACo5gNAbMBAHLgAxA4gQ5igAnNJ0MwAVTsX7IKyY7L2UNuJAf+AmAmJ78AEDTBiwGYg5gbifCSxFCZoaBMCy4A4GOjnH0D6DpK4IxNSVIHAfSDOAeLraJrjgJp/AwPbHMhejiQnwYRmUzNQ4VQgDQqXK0ia/0I17wJiPmQNTNBEAgMlQIWiQA2vgWw7QppBekGxsAjIiEUSBNnsBDWEAY9mEFgMMgBk00E0iZtA7AHEctDQ58MRuA6wlLgGFMoMpIG1QFeGwAIxGZo8GUhIysmwQGSAZgwHaEZhICIzOaBkJkqyM0CAAQDGx279Jf50AAAAAABJRU5ErkJggg==")
;
}
#drag
{
width
:
300px
;
height
:
40px
;
line-height
:
40px
;
background-color
:
#e8e8e8
;
position
:
relative
;
margin
:
0
auto
;
}
src/app/auth/login/login.component.ts
View file @
a7419f3d
import
{
Component
,
OnDestroy
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
OnDestroy
,
OnInit
,
HostListener
,
ViewChild
,
ElementRef
}
from
'@angular/core'
;
import
{
NavigationExtras
,
Router
}
from
'@angular/router'
;
import
{
AuthService
}
from
'../auth.service'
;
import
{
LifeCommonService
}
from
'../../common/life-common.service'
;
...
...
@@ -9,6 +9,7 @@ import { LifeCommonService } from '../../common/life-common.service';
styleUrls
:
[
'./login.component.scss'
]
})
export
class
LoginComponent
implements
OnInit
,
OnDestroy
{
@
ViewChild
(
'dragContainer'
)
dragContainer
:
ElementRef
;
MOBILE_REGEXP
=
/^
(
1
)\d{10}
$/
;
sendCodeHtml
:
string
=
'获取验证码'
;
timer
:
any
;
...
...
@@ -21,10 +22,46 @@ export class LoginComponent implements OnInit, OnDestroy {
isNeedAlert
:
boolean
;
dialogInfo
:
any
;
redirect
:
any
;
dragBg
:
any
;
dragText
:
any
;
dragHandler
:
any
;
maxHandlerOffset
:
any
;
isVertifySucc
:
boolean
=
true
;
left
:
any
;
deviceType
:
any
;
len
:
any
;
constructor
(
public
authService
:
AuthService
,
public
router
:
Router
,
public
lifeCommonService
:
LifeCommonService
)
{
this
.
deviceType
=
this
.
lifeCommonService
.
checkDeviceType
();
}
// 监听document离开事件
@
HostListener
(
'document:touchend'
,
[
'$event'
])
ontouchend
(
event
)
{
// 只用当元素移动过了,离开函数体才会触发。
this
.
onDragHandlerMouseUp
();
}
// 监听document离开事件
@
HostListener
(
`mouseup`
,
[
'$event'
])
onmouseup
(
event
)
{
// 只用当元素移动过了,离开函数体才会触发。
this
.
onDragHandlerMouseUp
();
}
ngOnInit
()
{
// //获取滑动控件容器,灰色背景
// this.dragContainer.nativeElement.clientWidth = document.getElementById("dragContainer");
// //获取滑块左边部分,绿色背景
this
.
dragBg
=
document
.
getElementById
(
"dragBg"
);
// //获取滑动验证容器文本
this
.
dragText
=
document
.
getElementById
(
"dragText"
);
// //获取滑块
this
.
dragHandler
=
document
.
getElementsByClassName
(
"slideController"
)[
0
];
// //滑块的最大偏移量 = 滑动验证容器文本长度 - 滑块长度
this
.
maxHandlerOffset
=
this
.
dragContainer
.
nativeElement
.
clientWidth
-
this
.
dragHandler
.
clientWidth
;
this
.
initDrag
();
this
.
len
=
(
window
.
innerWidth
-
document
.
body
.
clientWidth
)
/
2
;
}
...
...
@@ -40,12 +77,13 @@ export class LoginComponent implements OnInit, OnDestroy {
const
compareInfo
=
{
mobileNo
:
this
.
userInfo
.
mobileNo
,
verificationCode
:
this
.
userInfo
.
verificationCode
,
expireTime
:
'3600'
expireTime
:
'3600'
,
fromSystemName
:
'ydLife'
};
if
(
this
.
MOBILE_REGEXP
.
test
(
this
.
userInfo
.
mobileNo
)
&&
this
.
userInfo
.
verificationCode
&&
this
.
userInfo
.
verificationCode
.
length
==
6
)
{
this
.
authService
.
compare
(
compareInfo
).
subscribe
(
res
=>
{
if
(
res
[
'success'
])
{
this
.
authService
.
login
({
mobileNo
:
this
.
userInfo
.
mobileNo
}).
subscribe
((
response
)
=>
{
this
.
authService
.
login
({
mobileNo
:
this
.
userInfo
.
mobileNo
,
fromSystemName
:
'ydLife'
}).
subscribe
((
response
)
=>
{
if
(
response
[
'success'
])
{
this
.
authService
.
isLoggedIn
=
true
;
if
(
response
[
'data'
][
'practitionerBasicInfo'
]
&&
response
[
'data'
][
'practitionerBasicInfo'
][
'subordinateName'
]){
...
...
@@ -153,4 +191,129 @@ export class LoginComponent implements OnInit, OnDestroy {
getPopInfo
()
{
this
.
isNeedAlert
=
false
;
}
initDrag
()
{
//在滑动验证容器文本写入“拖动滑块验证”
this
.
dragText
.
textContent
=
"拖动滑块验证"
;
//给滑块添加鼠标按下监听
if
(
this
.
deviceType
==
2
||
this
.
deviceType
==
3
){
this
.
dragHandler
.
addEventListener
(
"touchstart"
,
()
=>
{
this
.
onDragHandlerMouseDown
()
},
false
);
}
else
{
this
.
dragHandler
.
addEventListener
(
"mousedown"
,
()
=>
{
this
.
onDragHandlerMouseDown
()
});
}
}
//选中滑块
onDragHandlerMouseDown
()
{
if
(
this
.
deviceType
==
2
||
this
.
deviceType
==
3
){
//鼠标移动监听
document
.
addEventListener
(
"touchmove"
,
()
=>
{
this
.
onDragHandlerMouseMove
(
event
)
},
false
);
//鼠标松开监听
document
.
addEventListener
(
"touchend"
,
()
=>
{
this
.
onDragHandlerMouseUp
});
}
else
{
document
.
querySelector
(
'#dragHandler'
).
classList
.
add
(
'slideController'
);
//获取滑块
this
.
dragHandler
=
document
.
getElementsByClassName
(
"slideController"
)[
0
];
//鼠标移动监听
this
.
dragHandler
.
addEventListener
(
"mousemove"
,(
e
)
=>
{
this
.
onDragHandlerMouseMove
(
e
);
});
//鼠标松开监听
this
.
dragHandler
.
addEventListener
(
"mouseup"
,
()
=>
{
this
.
onDragHandlerMouseUp
});
}
}
//滑块移动
onDragHandlerMouseMove
(
event
)
{
event
.
preventDefault
();
let
touch
;
if
(
event
.
touches
)
{
touch
=
event
.
touches
[
0
];
}
else
{
touch
=
event
;
}
/*
html元素不存在width属性,只有clientWidth
offsetX是相对当前元素的,clientX和pageX是相对其父元素的
*/
//滑块移动量
if
(
this
.
deviceType
==
2
||
this
.
deviceType
==
3
){
this
.
left
=
touch
.
clientX
-
this
.
dragHandler
.
clientWidth
/
2
;
}
else
{
//获取滑块
this
.
dragHandler
=
document
.
getElementsByClassName
(
"slideController"
)[
0
];
if
(
this
.
dragHandler
){
this
.
left
=
touch
.
clientX
-
this
.
dragHandler
.
clientWidth
/
2
-
this
.
len
;
}
else
{
this
.
left
=
0
;
}
}
if
(
this
.
left
<
0
)
{
this
.
left
=
0
;
//如果滑块移动量 > 滑块的最大偏移量 ,则调用验证成功函数
}
else
if
(
this
.
left
>
this
.
maxHandlerOffset
)
{
this
.
left
=
this
.
maxHandlerOffset
;
this
.
verifySucc
();
}
if
(
this
.
dragHandler
){
//滑块移动量
this
.
dragHandler
.
style
.
left
=
this
.
left
+
"px"
;
//绿色背景的长度
this
.
dragBg
.
style
.
width
=
this
.
dragHandler
.
style
.
left
;
}
}
//松开滑块函数
onDragHandlerMouseUp
()
{
if
(
this
.
deviceType
==
2
||
this
.
deviceType
==
3
){
//移除鼠标移动监听
document
.
removeEventListener
(
"touchmove"
,
this
.
onDragHandlerMouseMove
);
//移除鼠标松开监听
document
.
removeEventListener
(
"touchend"
,
this
.
onDragHandlerMouseUp
);
}
else
{
//移除鼠标移动监听
this
.
dragHandler
.
removeEventListener
(
"mousemove"
,
this
.
onDragHandlerMouseMove
);
//移除鼠标松开监听
this
.
dragHandler
.
removeEventListener
(
"mouseup"
,
this
.
onDragHandlerMouseUp
);
document
.
querySelector
(
'#dragHandler'
).
classList
.
remove
(
'slideController'
);
}
if
(
this
.
isVertifySucc
){
//初始化滑块移动量
this
.
dragHandler
.
style
.
left
=
0
;
//初始化绿色背景
this
.
dragBg
.
style
.
width
=
0
;
}
}
//验证成功
verifySucc
()
{
this
.
isVertifySucc
=
false
;
this
.
dragText
.
textContent
=
"验证通过"
;
this
.
dragText
.
style
.
color
=
"white"
;
this
.
dragHandler
.
setAttribute
(
"class"
,
"dragHandlerOkBg"
);
if
(
this
.
deviceType
==
2
||
this
.
deviceType
==
3
){
this
.
dragHandler
.
removeEventListener
(
"touchstart"
,
this
.
onDragHandlerMouseDown
);
document
.
removeEventListener
(
"touchmove"
,
this
.
onDragHandlerMouseMove
);
document
.
removeEventListener
(
"touchend"
,
this
.
onDragHandlerMouseUp
);
}
else
{
this
.
dragHandler
.
removeEventListener
(
"mousedown"
,
this
.
onDragHandlerMouseDown
);
this
.
dragHandler
.
removeEventListener
(
"mousemove"
,
this
.
onDragHandlerMouseMove
);
this
.
dragHandler
.
removeEventListener
(
"mouseup"
,
this
.
onDragHandlerMouseUp
);
}
setTimeout
(()
=>
{
this
.
dragContainer
.
nativeElement
.
style
.
display
=
'none'
},
1000
)
};
}
src/app/my/application-process/register/register.component.ts
View file @
a7419f3d
...
...
@@ -151,7 +151,8 @@ export class RegisterComponent implements OnInit {
const
compareCodeObj
=
{
mobileNo
:
this
.
userInfo
.
mobileNo
,
verificationCode
:
this
.
userInfo
.
verificationCode
,
expireTime
:
'3600'
expireTime
:
'3600'
,
fromSystemName
:
'ydLife'
};
this
.
authService
.
compare
(
compareCodeObj
).
subscribe
((
res
)
=>
{
if
(
res
[
'success'
]){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment