本文小編為大家詳細介紹“微信小程序怎么實現手勢解鎖”,內容詳細,步驟清晰,細節處理妥當,希望這篇“微信小程序怎么實現手勢解鎖”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。
這是一款簡單實用的手勢解鎖工具
手勢解鎖是當下常用的解鎖方式
本實例以工具的形式
可以嵌入到不同的項目之中

wxlocker.prototype.storePass = function(psw,cb) {// touchend結束之后對密碼和狀態的處理
if (this.pswObj.step == 1) {//step==1表示還沒有設置密碼狀態
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 = "再次輸入";
}
}
}效果圖如下:
手勢設置:

手勢解鎖(成功):

手勢解鎖(失敗):

wxlocker.prototype.updatePassword = function(){//點擊重置按鈕,重置密碼
wx.removeStorageSync("passwordxx");
// wx.removeStorageSync("chooseType");
this.pswObj = {};
this.title="請設置手勢密碼";
this.resetHidden = true;
this.titleColor = "";
this.reset();
}讀到這里,這篇“微信小程序怎么實現手勢解鎖”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。