// pages/reset_password/reset_password.js Page({ /** * 页面的初始数据 */ data: { userName: null, password: null, rePassword: null, checkPass: false, errorMsg: '' }, resetPassword(e) { let that = this; let{ userName : loginName, password } = this.data; wx.request({ url: getApp().globalData.postHeadAgreement + '/restapi/wechat/resetPassword', data: { loginName, password }, method: 'POST', success(res) { //console.log(res); //console.log(res.data.code == 1); if (res.data.code == 1) { // that.setData({ // errorMsg: res.data.msg // }); wx.showModal({ title: '提示', content: res.data.msg, showCancel: false, confirmColor: '#4359b5' }); } else { wx.navigateBack(); } } }); }, inputPassword(e) { this.setData({ password: e.detail.value }); this.checkAll(); }, inputRepassword(e) { this.setData({ rePassword: e.detail.value }); this.checkAll(); }, checkPassword() { if (!this.data.password || !this.data.rePassword || this.data.password != this.data.rePassword) { return false; } return true; }, checkAll() { if (this.data.password && (this.data.password.length < 5 || this.data.password.length > 20)) { this.setData({ errorMsg: '密码长度应为5-20' }); this.setData({ checkPass: false }); return; } if (!this.checkPassword()) { this.setData({ errorMsg: '两次密码输入不一致,请重新输入' }); this.setData({ checkPass: false }); return; } else { this.setData({ errorMsg: '' }); } this.setData({ checkPass: true }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { let { loginName } = options; this.setData({ userName: loginName }); //resetPassword }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })