| // pages/editpwd/editpwd.js |
| Page({ |
| |
| /** |
| * 页面的初始数据 |
| */ |
| data: { |
| newpwd: '', |
| renewpwd: '', |
| oldpwd: '' |
| }, |
| |
| setPassword: function(e) { |
| this.setData({ |
| newpwd: e.detail.value |
| }) |
| }, |
| |
| setPassword2: function(e) { |
| this.setData({ |
| renewpwd: e.detail.value |
| }) |
| }, |
| |
| setOriPassword: function(e) { |
| this.setData({ |
| oldpwd: e.detail.value |
| }) |
| }, |
| |
| /** |
| * 生命周期函数--监听页面加载 |
| */ |
| onLoad: function(options) { |
| wx.setNavigationBarTitle({ |
| title: '修改登录密码', |
| }) |
| }, |
| |
| doNext: function() { |
| var oldpwd = this.data.oldpwd; |
| var pwd = this.data.newpwd; |
| var repwd = this.data.renewpwd; |
| if (wx.$isEmpty(pwd) || wx.$isEmpty(repwd) || wx.$isEmpty(oldpwd)) { |
| return; |
| } |
| if (pwd.length < 6) { |
| wx.showModal({ |
| title: '提示', |
| content: '密码为6位以上字符', |
| }) |
| return; |
| } |
| if (pwd != repwd) { |
| wx.showModal({ |
| title: '提示', |
| content: '两次密码不一致', |
| }) |
| return; |
| } |
| wx.showLoading("正在保存"); |
| var param = { |
| "newpwd": pwd, |
| "renewpwd": repwd, |
| "oldpwd": oldpwd |
| } |
| wx.$doPost('/v1/pwdset', param, function(ok, ret) { |
| wx.hideLoading(); |
| if (ok) { |
| ret = ret.data; |
| |
| if (ret.code == 200) { |
| wx.showModal({ |
| title: '提示', |
| content: '修改密码成功', |
| showCancel: false, |
| success(res) { |
| wx.navigateBack({}) |
| } |
| }) |
| } else { |
| if (ret.code == -1) { |
| wx.removeStorageSync("token"); |
| wx.showModal({ |
| title: '提示', |
| content: ret.msg, |
| duration: 2000 |
| }) |
| wx.navigateTo({ |
| url: '../wxlogin/wxlogin', |
| }) |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: ret.msg, |
| |
| duration: 4000 |
| }) |
| } |
| } |
| } else { |
| |
| wx.showModal({ |
| title: '错误', |
| content: ret.msg, |
| duration: 4000 |
| }) |
| } |
| }) |
| }, |
| |
| /** |
| * 生命周期函数--监听页面初次渲染完成 |
| */ |
| onReady: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面显示 |
| */ |
| onShow: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面隐藏 |
| */ |
| onHide: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面卸载 |
| */ |
| onUnload: function() { |
| |
| }, |
| |
| /** |
| * 页面相关事件处理函数--监听用户下拉动作 |
| */ |
| onPullDownRefresh: function() { |
| |
| }, |
| |
| /** |
| * 页面上拉触底事件的处理函数 |
| */ |
| onReachBottom: function() { |
| |
| }, |
| |
| /** |
| * 用户点击右上角分享 |
| */ |
| onShareAppMessage: function() { |
| |
| } |
| }) |