// pages/studentLogin/studentLogin.js Page({ /** * 页面的初始数据 */ data: { userName:'', password:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, //表单项内容发生改变的回调 handleInput(event){ // console.log(type,event.detail.value); let type=event.currentTarget.dataset.type; //用data-type=value的形式传参 //当需要向event对象传多个数据(参数)时,使用“data-”的形式,因为“data-”的后面可以自己命名变量名 //当需要传的值只有一个,且唯一时,使用id的方法 this.setData({ [type]:event.detail.value }) }, //登录 login(){ let{userName,password}=this.data; if(!userName){ wx.showToast({ title: '账号不能为空', icon:'none' }) return } if(!password){ wx.showToast({ title: '密码不能为空', icon:'none' }) return }else if(password.length<6){ wx.showToast({ title: '密码不能小于6位', icon:'none' }) return } wx.redirectTo({ url: '/pages/myInfo/myInfo', }) }, //点击“马上注册”,跳转到注册页面 toLoginIn(){ wx.navigateTo({ url: '/pages/index/index', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })