微信小程序?qū)崿F(xiàn)手勢解鎖的示例詳解
更新時間:2022年04月28日 14:32:11 作者:失散多年的哥哥
手勢解鎖是生活中常用的解鎖方式,本文將通過微信小程序?qū)崿F(xiàn)手勢解鎖這一功能,本實例以工具的形式可以嵌入到不同的項目之中,感興趣的可以了解一下
一、項目展示
這是一款簡單實用的手勢解鎖工具
手勢解鎖是當(dāng)下常用的解鎖方式
本實例以工具的形式
可以嵌入到不同的項目之中
二、設(shè)置手勢、手勢解鎖
wxlocker.prototype.storePass = function(psw,cb) {// touchend結(jié)束之后對密碼和狀態(tài)的處理 if (this.pswObj.step == 1) {//step==1表示還沒有設(shè)置密碼狀態(tài) if (this.checkPass(this.pswObj.fpassword, psw)) { this.pswObj.step = 2; this.pswObj.spassword = psw; this.resetHidden = false; this.title = "密碼保存成功"; this.titleColor = "succ"; this.drawStatusPoint('#09bb07'); wx.setStorageSync('passwordxx', JSON.stringify(this.pswObj.spassword)); // wx.setStorageSync('chooseType', this.chooseType); } else { this.title = "兩次繪制不一致,重新繪制"; this.titleColor = "error"; this.drawStatusPoint('#e64340'); delete this.pswObj.step; } } else if (this.pswObj.step == 2) { if (this.checkPass(this.pswObj.spassword, psw)) { this.title = "解鎖成功"; this.titleColor = "succ"; this.drawStatusPoint('#09bb07'); cb(); } else { this.title = "解鎖失敗"; this.titleColor = "error"; this.drawStatusPoint('#e64340'); } } else { if(this.lastPoint.length<4){ this.title="密碼過于簡單,請至少連接4個點"; this.resetHidden = true; this.titleColor = "error"; return false; }else{ this.pswObj.step = 1; this.pswObj.fpassword = psw; this.titleColor = ""; this.title = "再次輸入"; } } }
效果圖如下:
手勢設(shè)置:
手勢解鎖(成功):
手勢解鎖(失敗):
三、手勢重置
wxlocker.prototype.updatePassword = function(){//點擊重置按鈕,重置密碼 wx.removeStorageSync("passwordxx"); // wx.removeStorageSync("chooseType"); this.pswObj = {}; this.title="請設(shè)置手勢密碼"; this.resetHidden = true; this.titleColor = ""; this.reset(); }
到此這篇關(guān)于微信小程序?qū)崿F(xiàn)手勢解鎖的示例詳解的文章就介紹到這了,更多相關(guān)微信小程序手勢解鎖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
javascript解析json格式的數(shù)據(jù)方法詳解
這篇文章主要介紹了javascript解析json格式的數(shù)據(jù)方法詳解,文章通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08JavaScript中array.reduce()數(shù)組方法的四種使用實例
reduce為數(shù)組中的每一個元素依次執(zhí)行回調(diào)函數(shù),不包括數(shù)組中被刪除或從未被賦值的元素,下面這篇文章主要給大家介紹了關(guān)于JavaScript中array.reduce()數(shù)組方法的四種使用實例,需要的朋友可以參考下2022-07-07