// pages/mUser/pChangepw/pChangepw.js import bInputCheck from '../../../base/behaviors/bInputCheck' import bLoadingToast from '../../../base/behaviors/bLoadingToast' import userservice from '../../../service/userservice' const app = getApp() Page({ behaviors: [bInputCheck, bLoadingToast], /** * 页面的初始数据 */ 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, }) } } }) } })