提示:以下是本篇文章正文內(nèi)容,下面案例可供參考
一、登陸
在登錄表單里,輸入賬號、密碼進行登錄,在賬號、密碼輸入框里都有友好的提示信息;登錄按鈕
默認是灰色不可用狀態(tài),只有輸入內(nèi)容后,才會變?yōu)榭捎脿顟B(tài);在登錄按鈕的下面提供手機快速注
冊、企業(yè)用戶注冊、找回密碼鏈接;界面最下面是微信、QQ第三方登錄方式,如圖所示。
示例代碼
(1) 創(chuàng)建一個form項目,填寫AppID,后端服務(wù)選擇“不使用云服務(wù)”,如圖所示,并在pages同
目錄下創(chuàng)建一個images目錄,用于保存項目中需要用到的圖片。
(2) 在app.json文件里添加"pages/login/login",“pages/mobile/mobile”,
“pages/company/company” 3個文件目錄,并刪除默認的文件目錄以及相應(yīng)的文件夾,如圖
所示。
(3) 在“pages/login/login.wxml”文件里,進行賬號密碼輸入框布局設(shè)計,代碼如下所示。
<!--pages/login/login.wxml-->
<view class="content">
<view class="account">
<view class="title">賬號</view>
<view class="num">
<input type="text" bindinput="nameInput" placeholder="賬號/郵箱/手機號" placeholder-style="color:#999;" />
</view>
</view>
<view class="hr"></view>
<view class="account">
<view class="title">密碼</view>
<view class="num">
<input type="password" bindblur="passwordBlur" placeholder="請輸入密
碼" placeholder-style="color:#999;" />
</view>
<view class="see">
<image src="/images/see.jpg" style="width: 42px; height:32px;" />
</view>
</view>
<view class="hr"></view>
</view>
(4) 在“pages/login/login.wxss”文件中添加相應(yīng)的樣式,代碼如下所示:
/* pages/login/login.wxss */
.content {
margin-top: 20px;
}
.account {
display: flex;
flex-direction: row;
}
.title {
margin: 10px;
font-weight: bold;
}
.num {
margin: 10px;
}
.hr {
height: 1px;
width: 90%;
background-color: #ccc;
opacity: 0.2;
}
.see {
position: absolute;
right: 20px;
}
運行效果如下圖所示:
(5) 在“pages/login/login.wxml”文件里,進行登錄按鈕、手機快速注冊、企業(yè)用戶注冊、找回
密碼以及第三方登錄布局的設(shè)計,代碼如下:
<!--pages/login/login.wxml-->
<view class="content">
<view class="account">
<view class="title">賬號</view>
<view class="num">
<input type="text" bindinput="nameInput" placeholder="賬號/郵箱/手機號" placeholder-style="color:#999;" />
</view>
</view>
<view class="hr"></view>
<view class="account">
<view class="title">密碼</view>
<view class="num">
<input type="password" bindblur="passwordBlur" placeholder="請輸入密碼" placeholder-style="color:#999;" />
</view>
<view class="see">
<image src="/images/see.jpg" style="width: 42px; height:32px;" />
</view>
</view>
<view class="hr"></view>
<button class="btn" disabled="{{disabled}}" type="{{btnType}}" bindtap="login">登錄</button>
<view class="operate">
<view>
<navigator url="../mobile/mobile">手機快速注冊</navigator>
</view>
<view>
<navigator url="../company/company">企業(yè)用戶注冊</navigator>
</view>
</view>
<view class="login">
<view>
<image src="/images/wxlogin.jpg" style="width:70px;height:98px;">
</image>
</view>
<view>
<image src="/images/qqlogin.jpg" style="width:70px;height:98px;">
</image>
</view>
</view>
</view>
(6) 在“pages/login/login.wxss”文件里添加對應(yīng)的樣式,代碼如下:
/* pages/login/login.wxss */
.content {
margin-top: 20px;
}
.account {
display: flex;
flex-direction: row;
}
.title {
margin: 10px;
font-weight: bold;
}
.num {
margin: 10px;
}
.hr {
height: 1px;
width: 90%;
background-color: #ccc;
opacity: 0.2;
}
.see {
position: absolute;
right: 20px;
}
.btn {
margin-top: 40px;
color: #999;
}
.operate {
display: flex;
flex-direction: row;
}
.operate view {
margin: 0 auto;
margin-top: 40px;
font-size: 14px;
color: #333333;
}
.login {
display: flex;
flex-direction: row;
margin-top: 150px;
}
.login view {
margin: 0 auto;
}
運行效果如下:
(7) 在“pages/login/login.js”文件中添加nameInput、passwordBlur事件函數(shù),當(dāng)賬號里輸入
內(nèi)容后,登錄按鈕變?yōu)榭捎脿顟B(tài),代碼如下所示:
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
disabled: true,
btnType: "default",
name: "",
password: ""
},
//輸入賬戶觸發(fā)的事件
nameInput(e) {
var account = e.detail.value; //獲取賬號的值
if (account != "") {
this.setData({ disabled: false, btnType: "primary", name: account });
}
},
//輸入密碼觸發(fā)的事件
passwordBlur(e) {
var pwd = e.detail.value;
if (pwd != "") {
this.setData({ password: pwd });
}
},
運行結(jié)果如下:
二、手機號注冊設(shè)計
在手機號注冊里,需要設(shè)計輸入框用來輸入手機號,設(shè)計同意注冊協(xié)議以及下一步按鈕,如圖所
示。
示例代碼
(1) 在“pages/mobile/mobile.wxml”文件里,進行手機號輸入框布局設(shè)計,代碼如下所示。
<view class="content">
<view class="hr"></view>
<view class="numbg">
<view>+86</view>
<view><input placeholder="請輸入手機號" maxlength="11" bindblur="mobileblur" /></view>
</view>
</view>
(2) 在“pages/mobile/mobile.wxss”文件里添加相應(yīng)的樣式,代碼如下所示。
.content {
width: 100%;
height: 600px;
background-color: #f2f2f2;
}
.hr {
padding-top: 20px;
}
.numbg {
display: flex;
flex-direction: row;
width: 90%;
height: 50px;
border: 1pxsolid#cccccc;
border-radius: 5px;
margin: 0 auto;
background-color: #ffffff;
}
.numbg view {
margin-left: 20px;
margin-top: 14px;
}
運行結(jié)果如下所示:
(3) 在“pages/mobile/mobile.wxml”文件里,設(shè)計注冊協(xié)議和下一步按鈕操作,代碼如下所
示。
<!--pages/mobile/mobile.wxml-->
<view class="content">
<view class="hr"></view>
<view class="numbg">
<view>+86</view>
<view><input placeholder="請輸入手機號" maxlength="11" bindblur="mobileblur" /></view>
</view>
<view class="xieyi">
<icon type="success" color="red" size="18"></icon>
<text class="agree">同意</text>
<text class="opinion">京東用戶注冊協(xié)議</text>
</view>
</view>
<view>
<button class="btn" disabled="{{disabled}}" type="{{btnType}}" bindtap="login">下一步</button>
</view>
(4) 在“pages/mobile/mobile.wxss”文件里添加相應(yīng)的樣式,代碼如下所示。
/* pages/mobile/mobile.wxss */
.content {
width: 100%;
height: 600px;
background-color: #f2f2f2;
}
.hr {
padding-top: 20px;
}
.numbg {
display: flex;
flex-direction: row;
width: 90%;
height: 50px;
border: 1pxsolid#cccccc;
border-radius: 5px;
margin: 0 auto;
background-color: #ffffff;
}
.numbg view {
margin-left: 20px;
margin-top: 14px;
}
.xieyi {
margin-top: 15px;
margin-left: 15px;
}
.agree {
font-size: 13px;
margin-left: 5px;
color: #666666;
}
.opinion {
font-size: 13px;
color: #000000;
font-weight: bold;
}
.btn {
width: 90%;
margin-top: 30px;
}
運行效果如下:
(5) 在“pages/mobile/mobile.js”文件里,添加mobileblur事件,如果輸入手機號,下一步按
鈕變?yōu)榭捎脿顟B(tài),代碼如下所示。
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
disabled: true,
btnType: "default",
mobile: ""
},
//當(dāng)輸入手機號結(jié)束以后,失去焦點時觸發(fā)的事件。
mobileblur(e) {
var phone = e.detail.value;
if (phone != "") { //當(dāng)完成輸入時,“下一步”可用
this.setData({ disabled: false, btnType: "primary", mobile: phone });
} else {
this.setData({ disabled: true, btnType: "default", mobile: "" });
}
},
運行結(jié)果如下:
(6) 在mobile.json文件里,添加“navigationBarTitleText”這個屬性,設(shè)置導(dǎo)航標(biāo)題為手機快速
注冊,代碼如下所示:
{
"navigationBarTitleText":"手機快速注冊"
}
文章來源:http://www.zghlxwxcb.cn/news/detail-482498.html
未完
企業(yè)用戶注冊設(shè)計未上傳,待續(xù)。有問題大家可以盡管提出,謝謝大家。文章來源地址http://www.zghlxwxcb.cn/news/detail-482498.html
到了這里,關(guān)于微信小程序登錄與注冊(沒有連接數(shù)據(jù)庫)(2023年3月31日)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!