// pages/user/password/password.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { userInfo: wx.getStorageSync('userInfo') }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, async submit(e) { let data = e.detail.value; if (!data.password) { wx.showToast({ title: '请输入原密码!', icon: "error" }); return; } if (!data.newpassword1) { wx.showToast({ title: '请输入新密码', icon: "error" }); return; } if (!data.newpassword2) { wx.showToast({ title: '请输入重复新密码!', icon: "none" }); return; } if (data.newpassword1 != data.newpassword2) { wx.showToast({ title: '重复密码和新密码不一致!', icon: "none" }); return; } if (data.newpassword1 == data.password) { wx.showToast({ title: '旧密码和新密码不能一致!', icon: "none" }); return; } let { data: data1 } = await app.ajax.post({ url: "/admin/user/edit", method: "PUT", data }); if (!data1.data) { wx.showToast({ title: data1.msg, icon: data1.msg.length > 7 ? "none" : "error" }); return; } wx.showToast({ title: '修改成功', }); setTimeout(() => { wx.navigateBack(); }, 1000); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })