Browse Source

Merge branch 'master' of http://git.cc-lotus.info/count/webnew-count

guhongwei 5 years ago
parent
commit
414d73a67b
3 changed files with 33 additions and 5 deletions
  1. 2 2
      src/store/login.js
  2. 1 1
      src/views/pcenter/pinfo.vue
  3. 30 2
      src/views/pcenter/uppasswd.vue

+ 2 - 2
src/store/login.js

@@ -56,9 +56,9 @@ const actions = {
     // const res = await this.$axios.$post(api.logout, { key: key });
     // commit('deleteUser');
   },
-  async update({ commit }, payload) {
+  async uppasswd({ commit }, payload) {
     let res = await this.$axios.$post(`${api.updatePassword}`, {
-      data: payload,
+      ...payload,
     });
     return res;
   },

+ 1 - 1
src/views/pcenter/pinfo.vue

@@ -181,7 +181,7 @@ export default {
         this.form.gender = gender;
       }
     },
-    async onSubmit(from) {
+    async onSubmit() {
       let res = {};
       let data = JSON.parse(JSON.stringify(this.form));
       if (this.user.type === '3') {

+ 30 - 2
src/views/pcenter/uppasswd.vue

@@ -25,6 +25,8 @@
 </template>
 
 <script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: login } = createNamespacedHelpers('login');
 export default {
   name: 'uppasswd',
   props: {},
@@ -38,15 +40,41 @@ export default {
     display: false,
   }),
   created() {},
-  computed: {},
+  computed: {
+    ...mapState(['user']),
+  },
   methods: {
+    ...login(['logout', 'uppasswd']),
     insurePasswd() {
       let newpasswd = this.form.newpasswd;
       let _newpasswd = this.form._newpasswd;
-      if (newpasswd != _newpasswd) {
+      if (newpasswd === _newpasswd) {
+        this.display = false;
+      } else {
         this.display = true;
       }
     },
+    async onSubmit() {
+      let res = {};
+      let data = JSON.parse(JSON.stringify(this.form));
+      data.userid = this.user.uid;
+      delete data._newpasswd;
+      res = await this.uppasswd(data);
+      if (res.errcode === 0) {
+        this.$message({
+          message: '密码修改成功',
+          type: 'success',
+        });
+        this.logoutBtn();
+      } else {
+        this.$message.error('密码修改失败');
+      }
+    },
+    // 退出登录
+    logoutBtn() {
+      this.logout();
+      this.$router.push({ path: '/' });
+    },
   },
 };
 </script>