溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

微信小程序怎么實現手勢解鎖

發布時間:2022-04-28 16:48:44 來源:億速云 閱讀:333 作者:iii 欄目:開發技術

本文小編為大家詳細介紹“微信小程序怎么實現手勢解鎖”,內容詳細,步驟清晰,細節處理妥當,希望這篇“微信小程序怎么實現手勢解鎖”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。

一、項目展示

這是一款簡單實用的手勢解鎖工具

手勢解鎖是當下常用的解鎖方式

本實例以工具的形式

可以嵌入到不同的項目之中

微信小程序怎么實現手勢解鎖

二、設置手勢、手勢解鎖

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();
        }

讀到這里,這篇“微信小程序怎么實現手勢解鎖”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女