// pages/m_user/p_changepw/p_changepw.js import b_inputCheck from '../../../base/behaviors/b_inputCheck' import b_loadingToast from '../../../base/behaviors/b_loadingToast' import userservice from '../../../service/userservice' const app = getApp() Page({ behaviors: [b_inputCheck, b_loadingToast], /** * 页面的初始数据 */ data: { msg: [{ name: "原密码", id: "oldPassword", input: true, // type: 'password', value: '', noValue: false, }, { name: "新密码", id: "newPassword", input: true, type: 'password', value: '', noValue: false, }, { name: "确认密码", id: "pwCheck", input: true, type: 'password', value: "", noValue: false, }, ], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, _submit(e) { if (e.oldPassword == e.newPassword) { this.setData({ errorMsg: '新密码不能和原密码相同', }) return } userservice.changePW(app.globalData.accessToken.userId, e.oldPassword, e.newPassword, { success(res) { if (res.success) { wx.navigateBack({ delta: 1, success: () => { wx.showToast({ title: res.message, duration: 2000, icon: 'success', mask: true, }) } }) } else { wx.showToast({ title: res.message, duration: 2000, icon: 'error', mask: true, }) } } }) } })