微信小程序?qū)崿F(xiàn)登錄注冊功能
本文實(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)文章
將HTML格式的String轉(zhuǎn)化為HTMLElement的實(shí)現(xiàn)方法
本節(jié)主要介紹了將HTML格式的String轉(zhuǎn)化為HTMLElement的實(shí)現(xiàn)方法,需要的朋友可以參考下2014-08-08
JavaScript實(shí)現(xiàn)網(wǎng)頁截屏的5種方法小結(jié)
本文主要介紹了JavaScript實(shí)現(xiàn)網(wǎng)頁截屏的5種方法小結(jié),感興趣的可以了解一下2009-10-10
JavaScript引用類型Function實(shí)例詳解
這篇文章主要介紹了JavaScript引用類型Function,結(jié)合實(shí)例形式詳細(xì)分析了javascript引用類型Function概念、定義、原理、相關(guān)使用技巧與操作注意事項(xiàng),需要的朋友可以參考下2018-08-08
兼容IE/Firefox/Opera/Safari的檢測頁面裝載完畢的腳本Ext.onReady的實(shí)現(xiàn)
其中對于IE的檢測很有意思。 以上代碼,整理自Extjs的腳本,完全可以代替 Ext.onReady使用。2009-07-07
JavaScript async/await原理及實(shí)例解析
這篇文章主要介紹了JavaScript async/await原理及實(shí)例解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-12-12
用javascript實(shí)現(xiàn)的支持lrc歌詞的播放器
用javascript實(shí)現(xiàn)的支持lrc歌詞的播放器...2007-05-05

