| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- // 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() {
- }
- })
|