最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序?qū)崿F(xiàn)登錄頁面

 更新時間:2022年05月22日 07:03:46   作者:JYeontu  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)登錄頁面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序?qū)崿F(xiàn)登錄頁面的具體代碼,供大家參考,具體內(nèi)容如下

實現(xiàn)在進(jìn)入微信小程序首頁前的登錄驗證頁面,這里有兩種方法,但其實原理都是一樣的。

1. 在首頁中加入一個彈窗作為登錄窗口,效果如下圖:

(1)index.wxml

登錄窗口代碼如下:

<view class="modal-mask" bindtap="hideModal" catchtouchmove="preventTouchMove" wx:if="{{!hiddenmodalput}}"></view>
<view class="modal-dialog" wx:if="{{!hiddenmodalput}}" catchtouchmove="preventTouchMove">
? <view class="modal-title">{{tip}}</view>
? <view class="modal-content">
? ? <view class="modal-input">
? ? ? <input placeholder-class="input-holder" type="text" maxlength="20" bindinput="inputUsername" class="input" placeholder="用戶名" value="{{username}}">
? ? ? </input>
? ? </view>
? ? <view class="modal-input">
? ? ? <input placeholder-class="input-holder" type="text" maxlength="20" bindinput="inputPassword" class="input" placeholder="密碼" value="{{password}}">
? ? ? </input>
? ? </view>
? </view>
? <view class="modal-footer">
? ? <navigator class="btn-cancel" target="miniProgram" open-type="exit">
? ? ? 退出
? ? </navigator>
? ? <!-- <view class="btn-cancel" bindtap="cancel" data-status="cancel">取消</view> -->
? ? <view class="btn-confirm" bindtap="confirm" data-status="confirm">確定</view>
? </view>
</view>

(2)index.js

在onload方法中判斷當(dāng)前的登錄狀態(tài),這里我用了簡單的 getStorage 來保存登錄信息,hiddenmodalput控制登錄窗口是否顯示,這樣就可以實現(xiàn)簡單的登錄頁面,hideTabBar是用來隱藏底部tab欄按鍵。

? /**
? ?* 生命周期函數(shù)--監(jiān)聽頁面加載
? ?*/
? onLoad: function (options) {
? ? let that = this;
? ? wx.getStorage({
? ? ? key: 'username',
? ? ? success (res) {
? ? ? ? console.log(res.data);
? ? ? ? that.setData({
? ? ? ? ? hiddenmodalput:true,
? ? ? ? })
? ? ? },
? ? ? fail (res) {
? ? ? ? console.log(res);
? ? ? ? that.setData({
? ? ? ? ? hiddenmodalput:false,
? ? ? ? })
? ? ? ? wx.hideTabBar({
? ? ? ? ? animation: true,
? ? ? ? ? success: (res) => {},
? ? ? ? ? fail: (res) => {},
? ? ? ? ? complete: (res) => {},
? ? ? ? })
? ? ? }
? ? })
? },

2.新建一個登錄頁面

(1)在首頁onload中進(jìn)行登錄轉(zhuǎn)態(tài)驗證,如果為未登錄狀態(tài),則可以使用wx.navigateTo跳轉(zhuǎn)到登錄頁面

(2)在登錄頁面中處理登錄的相關(guān)邏輯,也可以實現(xiàn)相同的效果。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

新田县| 喜德县| 霍邱县| 察雅县| 岗巴县| 昆明市| 宜春市| 朔州市| 孙吴县| 清涧县| 遂溪县| 虹口区| 阿瓦提县| 庆阳市| 乐东| 阿克| 黔西| 宁津县| 阳曲县| 眉山市| 吉安县| 精河县| 万年县| 思茅市| 横峰县| 定边县| 新昌县| 文山县| 宁河县| 烟台市| 曲靖市| 北辰区| 北安市| 雷州市| 洛隆县| 台北市| 鄂尔多斯市| 永年县| 永春县| 开封市| 嘉鱼县|