本文实例为大家分享了微信小程序实现登录注册的具体代码,供大家参考,具体内容如下
html:
<form bindsubmit="handleSubmit" wx:if="{{ onoff }}"> 用户名: <input type="text" name='username'/> 密码: <input type="password" name='password'/> 手机号: <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({ /** * 页面的初始数据 */ 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) } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })
效果图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持站长技术。
console.log ,作为一个前端开发者,可能每天都会用它来分析调试,但这个简单函...
不少Windows 10用户之前都抱怨一个问题,那就是系统的屏幕出现了渲染问题,而微...
本文转载自微信公众号「Linux开发那些事儿」,作者 LinuxThings 。转载本文请联...
互联网业务往往使用MySQL数据库作为后台存储,存储引擎使用InnoDB。我们针对互联...
前言 aop即是面向切面编程,众多Aop框架里Castle是最为人所知的,另外还有死去的...
2月26日消息 众所周知,Windows 10 的安全更新和其他重要累计更新通常是在同一天...
简介 “ 大家好我是帅哥欢迎来到帅哥的程序人生我会把经历分享出来助你了解圈内...
开发过程中,我们经常会遇到代码回滚的情况。正常人都知道,git 回滚有两大宝: ...
继 Australis 和 Photon 之后,Mozilla 现又酝酿为 Firefox 带来名为Proton的全...
一、Postman背景介绍 用户在开发或者调试网络程序或者是网页B/S模式的程序的时候...