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