溫馨提示×

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

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

微信小程序怎么實(shí)現(xiàn)手勢(shì)解鎖

發(fā)布時(shí)間:2022-04-28 16:48:44 來源:億速云 閱讀:254 作者:iii 欄目:開發(fā)技術(shù)

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

一、項(xiàng)目展示

這是一款簡(jiǎn)單實(shí)用的手勢(shì)解鎖工具

手勢(shì)解鎖是當(dāng)下常用的解鎖方式

本實(shí)例以工具的形式

可以嵌入到不同的項(xiàng)目之中

微信小程序怎么實(shí)現(xiàn)手勢(shì)解鎖

二、設(shè)置手勢(shì)、手勢(shì)解鎖

wxlocker.prototype.storePass = function(psw,cb) {// touchend結(jié)束之后對(duì)密碼和狀態(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="密碼過于簡(jiǎn)單,請(qǐng)至少連接4個(gè)點(diǎn)";
                    this.resetHidden = true;
                    this.titleColor = "error";
                    return false;
                }else{
                    this.pswObj.step = 1;
                    this.pswObj.fpassword = psw;
                    this.titleColor = "";
                    this.title = "再次輸入";
                }
                
            }
	}

效果圖如下:

手勢(shì)設(shè)置:

微信小程序怎么實(shí)現(xiàn)手勢(shì)解鎖

手勢(shì)解鎖(成功):

微信小程序怎么實(shí)現(xiàn)手勢(shì)解鎖

手勢(shì)解鎖(失敗):

微信小程序怎么實(shí)現(xiàn)手勢(shì)解鎖

三、手勢(shì)重置

        wxlocker.prototype.updatePassword = function(){//點(diǎn)擊重置按鈕,重置密碼
            wx.removeStorageSync("passwordxx");
            // wx.removeStorageSync("chooseType");
            this.pswObj = {};
            this.title="請(qǐng)?jiān)O(shè)置手勢(shì)密碼";
            this.resetHidden = true;
            this.titleColor = "";
            this.reset();
        }

讀到這里,這篇“微信小程序怎么實(shí)現(xiàn)手勢(shì)解鎖”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識(shí)點(diǎn)還需要大家自己動(dòng)手實(shí)踐使用過才能領(lǐng)會(huì),如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI