riku
2022-10-21 0f2fdf16f47bd2d1d8fee86449c3a5095ccc8c23
pages/m_user/p_changepw/p_changepw.js
@@ -1,6 +1,9 @@
// pages/m_user/p_changepw/p_changepw.js
import b_inputCheck from '../../../base/behaviors/b_inputCheck'
import b_loadingToast from '../../../base/behaviors/b_loadingToast'
import userservice from '../../../service/userservice'
const app = getApp()
Page({
  behaviors: [b_inputCheck, b_loadingToast],
@@ -12,7 +15,7 @@
        name: "原密码",
        id: "oldPassword",
        input: true,
        type: 'password',
        // type: 'password',
        value: '',
        noValue: false,
      },
@@ -42,52 +45,37 @@
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
  _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,
          })
        }
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {
  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
      }
    })
  }
})