微信小程序?qū)崿F(xiàn)登錄注冊功能
更新時(shí)間:2020年12月29日 14:37:02 作者:保護(hù)我方豆豆
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)登錄注冊功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)登錄注冊的具體代碼,供大家參考,具體內(nèi)容如下
html:
<form bindsubmit="handleSubmit" wx:if="{{ onoff }}">
用戶名: <input type="text" name='username'/>
密碼: <input type="password" name='password'/>
手機(jī)號: <input type="text" name='phone'/>
<button form-type="submit"> 注冊 </button>
</form>
<form bindsubmit="handleLogin" wx:else>
用戶名: <input type="text" name='username'/>
密碼: <input type="password" name='password'/>
<button form-type="submit"> 登錄 </button>
</form>
js:
// pages/login/login.js
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
onoff: false
},
handleSubmit(e){
const {value} = e.detail;
// console.log(value)
const that = this;
wx.request({
url: 'http://pddapi.h5sm.com/index/pdduser/getpddregister',
method: 'post',
data: value,
success(res){
if(res.data.status == 1){
that.setData({
onoff: false
})
}
}
})
},
handleLogin(e){
const {username, password} = e.detail.value;
const that = this;
wx.request({
url: 'http://pddapi.h5sm.com/index/pdduser/getpddlogin',
method: 'post',
data:{
username, password
},
success(res){
console.log(res)
}
})
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad: function (options) {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面顯示
*/
onShow: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面隱藏
*/
onHide: function () {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面卸載
*/
onUnload: function () {
},
/**
* 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動作
*/
onPullDownRefresh: function () {
},
/**
* 頁面上拉觸底事件的處理函數(shù)
*/
onReachBottom: function () {
},
/**
* 用戶點(diǎn)擊右上角分享
*/
onShareAppMessage: function () {
}
})
效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript實(shí)現(xiàn)簡單圖片滾動附源碼下載
JavaScript實(shí)現(xiàn)簡單圖片滾動,9張圖告訴你,C羅欲哭無淚,另附源碼下載,方便學(xué)習(xí)2014-06-06
json 帶斜杠時(shí)如何解析的實(shí)現(xiàn)
這篇文章主要介紹了json 帶斜杠時(shí)如何解析的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08
AJAX異步從優(yōu)酷專輯中采集所有視頻及信息(JavaScript代碼)
上次寫了一個 .NET從優(yōu)酷專輯中采集所有視頻及信息(VB.NET代碼)2010-11-11

