const md5 = require("../../../../utils/md5"); const _Http = getApp().globalData.http; import Toast from '@vant/weapp/toast/toast'; Page({ /** * 页面的初始数据 */ data: { from: { password: "", //原密码 newPassword: "", //新密码 verifyNewPassword: "" //确认密码 }, disabled: true, loading: false, confirmPassword: "", }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /* 修改密码 */ changePassword() { if (this.data.disabled || this.data.loading) return; if (this.data.confirmPassword != true) return Toast({ message: '请检查新密码与确认密码', position: 'bottom' }); let from = this.data.from; this.setData({ loading: true }) _Http.basic({ "classname": "common.usercenter.usercenter", "method": "changePassWord", "content": { "password": md5.hexMD5(from.password), "newpassword": md5.hexMD5(from.newPassword) } }).then(res => { console.log(res) this.setData({ loading: false }) if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none" }) /* Toast({ message: res.msg, position: 'bottom' }); */ this.setData({ disabled: true }) wx.showToast({ title: '修改成功!', }) setTimeout(() => { wx.navigateBack({ delta: 0 }) }, 300) }) }, /* 表单输入 */ formInput(e) { let v = e.detail.value.trim(), name = e.currentTarget.dataset.name; this.setData({ [`from.${name}`]: v }); let disabled = false, from = this.data.from; for (let i in from) { if (from[i] == '') disabled = true; } this.setData({ disabled }) }, /* 验证确认密码 */ passwordBlur() { let { from } = this.data, confirmPassword = from.newPassword == from.verifyNewPassword; if (from.newPassword == '' || from.verifyNewPassword == '') confirmPassword = "" this.setData({ confirmPassword }) }, /* 清除确认密码 */ clearNewPassword() { this.setData({ ['from.verifyNewPassword']: '', confirmPassword: "" }) }, })