// pages/pwdSet/index.js const util = require('../../utils/util.js'); const app = getApp(); Page({ /** * 页面的初始数据 */ data: { oldPassword:'', newPassword:'', confirmPassword:'', userInfo:{ password:'' }, message:{} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, changePassword(){ var that = this console.log("66666") console.log(that.data) // that.data.userInfo = app.globalData.userInfo // console.log("88888") // console.log(that.data.userInfo) // if(that.data.userInfo.password != that.data.oldPassword){ // wx.showToast({ // title: "旧密码输入错误!", // icon: "none" // }); // return // } // if(util.isNullOrEmpty(that.data.newPassword)){ // wx.showToast({ // title: "新密码不允许为空!", // icon: "none" // }); // return // } // if(that.data.newPassword != that.data.confirmPassword){ // wx.showToast({ // title: "两次输入密码不一致!", // icon: "none" // }); // return // } util.request(util.api.changePassword, {oldPassword:that.data.oldPassword,newPassword:that.data.newPassword,confirmPassword:that.data.confirmPassword}, "POST", true, true,app.globalData.token).then((res)=>{ console.log("444") console.log(res) console.log("333") that.data.message = res.message if (res.code == 200) { if(res.result === "密码重置成功!"){ wx.showToast({ title: "密码重置成功!", icon: "none" }); setTimeout(()=>{ wx.navigateBack({ delta: 1, }) },500) } } if(res.code == 500){ if(that.data.message === "旧密码输入错误!"){ wx.showToast({ title: "旧密码输入错误!", icon: "none" }); return } if(that.data.message === "新密码不允许为空!"){ wx.showToast({ title: "新密码不允许为空!", icon: "none" }); return } if(that.data.message === "两次输入密码不一致!"){ wx.showToast({ title: "两次输入密码不一致!", icon: "none" }); return } } }).catch((res) => {}) }, inputedit: function (e) { let _this = this; let dataset = e.currentTarget.dataset; let value = e.detail.value; let name = dataset.name; _this.data[name] = value; _this.setData({ [name]: _this.data[name] }); }, })