YY hace 3 años
padre
commit
0450f82a94
Se han modificado 1 ficheros con 19 adiciones y 16 borrados
  1. 19 16
      pages/password/index.js

+ 19 - 16
pages/password/index.js

@@ -10,8 +10,8 @@ Page({
         // 主体高度
         infoHeight: '',
         frameStyle: { useTop: true, name: '修改密码', leftArrow: true, useBar: false },
-        form: {}
-    },  
+        form: {},
+    },
     //验证必填项    
     initValidate() {
         const rules = { password: { required: true }, }
@@ -25,30 +25,32 @@ Page({
     //提交
     formSubmit: function (e) {
         const value = e.detail.value;
+        var id = this.data.id;
         if (!this.WxValidate.checkForm(value)) {
             const error = this.WxValidate.errorList[0];
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
             wx.request({
-                url: `${app.globalData.publicUrl}/courtAdmin/api/user/updatePwd/${res.data.id}`,
+                url: `${app.globalData.publicUrl}/courtAdmin/api/user/updatePwd/${id}`,
                 method: "post",
                 data: value,
                 header: {},
                 success: res => {
-                    if (res.data.errcode == 0) {
-                        wx.showToast({
-                            title: '保存成功',
-                            icon: 'success',
-                            duration: 2000
-                        })
-                    } else {
-                        wx.showToast({
-                            title: '保存失败',
-                            icon: 'success',
-                            duration: 2000
-                        })
-                    }
+                    wx.showModal({
+                        title: '是否修改密码',
+                        success(res) {
+                            if (res.confirm) {
+                                wx.removeStorage({
+                                    key: 'token',
+                                    success(res) {
+                                        return wx.redirectTo({ url: '/pages/index/index', })
+                                    }
+                                })
+                            } else if (res.cancel) {
+                            }
+                        }
+                    })
                 },
             })
         }
@@ -71,6 +73,7 @@ Page({
         wx.getStorage({
             key: 'token',
             success: res => {
+                that.setData({ id: res.data.id })
                 wx.request({
                     url: `${app.globalData.publicUrl}/courtAdmin/api/user/${res.data.id}`,
                     method: "get",