博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
h5手势密码开发(使用jq)
阅读量:6872 次
发布时间:2019-06-26

本文共 3395 字,大约阅读时间需要 11 分钟。

直接上代码:

目录结构:

1347866-20180823171801617-1060062306.png

本次开用到的技术jq,以及引入的jq插件jquery.gesture.password.min.js
index.html
    
jq设置h5的手势密码
至少连接四个点
再次绘制解锁图案
两次不一致,请重新绘制
重新绘制
index.js
$(function () {    /*      *count记录输入手势密码次数     * pwd1第一次输入的手势密码     */    let count = 0,        pwd1 = null,        lis = $('li')    $('.again,.disagree,.limit').hide()    $("#gesturepwd").GesturePasswd({        backgroundColor: "white", //背景色        color: "#E4E4E4", //主要的控件颜色        roundRadii: 25, //大圆点的半径        pointRadii: 6, //大圆点被选中时显示的圆心的半径        space: 30, //大圆点之间的间隙        width: 240, //整个组件的宽度        height: 240, //整个组件的高度        lineColor: "red", //用户划出线条的颜色        zindex: 100 //整个组件的css z-index属性    });    $("#gesturepwd").on("hasPasswd", function (e, passwd) {        var result;        count++        console.log(count)        if (count == 1) {            if (passwd.length < 4) {                $("#gesturepwd").trigger("passwdWrong");                $('.limit').show()                count = 0                return            }            $('.limit').hide()            pwd1 = passwd            lis.each(function (i, ele) {                if (passwd.indexOf(i + 1) != -1) {                    $(this).css({                        backgroundColor: 'red'                    })                }            })            $("#gesturepwd").trigger("passwdWrong");        }        $('.againcn').show()        if (count >= 2) {            $('.again').hide()            if (passwd == pwd1) {                result = true;            } else {                result = false;            }            if (result == true) {                $("#gesturepwd").trigger("passwdRight");                setTimeout(function () {                    //密码验证正确后的其他操作,打开新的页面等。。。                    alert('密码正确')                }, 500); //延迟半秒以照顾视觉效果            } else {                $("#gesturepwd").trigger("passwdWrong");                //密码验证错误后的其他操作。。。                $('.disagreecn').show()            }        }    });    //重新绘制    $('.clear_again').click(function () {        count = 0        pwd1 = null        $('.again,.disagree').hide()        lis.each(function (i, ele) {            $(this).css({                backgroundColor: 'white'            })        })    })})
index.css
*{    list-style: none;    margin: 0;    padding: 0;}.gesture_wrapper {    margin-top: 5px;}.gesturepwd_modal {    display: flex;    justify-content: center;    margin-top: 60px;}.thumbnail {    margin-top: 60px;    overflow: hidden;    display: flex;    flex-direction: column;    align-items: center;}.again,.disagree,.limit {    margin-top: 20px;}ul {    display: flex;    width: 100px;    flex-wrap: wrap;}li {    width: 20px;    margin-left: 10px;    margin-top: 10px;    border-radius: 50%;    height: 20px;    border: 1px solid #E4E4E4;}.clear_again {    margin-top: 80px;    color: #009943;    display: flex;    justify-content: center;}
效果图

1347866-20180823172335661-1083518878.png

资源文件可到本人github地址:

转载于:https://www.cnblogs.com/raind/p/9525121.html

你可能感兴趣的文章
ZOJ-2913 Bus Pass---BFS进阶版
查看>>
合并排序(非哨兵方法)
查看>>
PHP 依赖管理神器 Composer 基本使用
查看>>
sass进阶篇
查看>>
为项目配置logback日志
查看>>
另外一种C#多选下拉框
查看>>
伸展树的学习(七):伸展树常用的操作合集
查看>>
在Windows Server 2008 R2上安装 PowerShell 5.0
查看>>
Hyper-V 2016 系列教程32 StartWind 虚拟NFS,iSCSI软件
查看>>
高阶函数、柯里化及装饰器的使用
查看>>
redis 实验(七)监控和性能
查看>>
elasticsearch如何安全加固?
查看>>
AlwaysOn 同步提交模式是否会丢失数据?
查看>>
大数据学习贴(1)-环境搭建
查看>>
Windows Server入门系列32 利用SamInside获取系统密码Hash值
查看>>
juniper SRX vmware模拟器(能够出现可用网卡)
查看>>
WPF-15:AutoCompleteBox的使用(实现下拉列表)
查看>>
记录我所接触的python模块
查看>>
Windows Server2012域用户映射网络驱动器
查看>>
IBM X3650 M3服务器安装SUSE LINUX 10实战
查看>>