guhongwei 3 gadi atpakaļ
vecāks
revīzija
3dd8cbb7d8

+ 5 - 0
src/router/index.js

@@ -155,6 +155,11 @@ const exchange = [
     meta: { title: '基本信息' },
     component: () => import('../views/exchange/center/userCenter/basic/index.vue'),
   },
+  {
+    path: '/exchange/center/userCenter/password/index',
+    meta: { title: '修改密码' },
+    component: () => import('../views/exchange/center/userCenter/password/index.vue'),
+  },
   // {
   //   path: '/exchange/center/user/index',
   //   meta: { title: '关联用户' },

+ 1 - 0
src/views/exchange/center/parts/role-3.vue

@@ -3,6 +3,7 @@
     <van-row>
       <van-col span="24" class="main">
         <van-cell title="基本信息" @click="to('basic')" is-link />
+        <van-cell title="修改密码" @click="to('password')" is-link />
       </van-col>
     </van-row>
   </div>

+ 68 - 0
src/views/exchange/center/userCenter/password/index.vue

@@ -0,0 +1,68 @@
+<template>
+  <div id="login">
+    <admin-frame topType="2" @back="back" :rightArrow="false" :usePage="false" :useNav="false">
+      <template v-slot:info>
+        <van-form @submit="onSubmit">
+          <van-field v-model="form.password" type="password" name="password" label="新密码" :rules="[{ required: true, message: '请填写密码' }]" />
+          <div style="margin: 16px">
+            <van-button round block type="info" native-type="submit">提交修改</van-button>
+          </div>
+        </van-form>
+      </template>
+    </admin-frame>
+  </div>
+</template>
+
+<script>
+import adminFrame from '@frame/src/components/mobile-frame/mobile-main.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: personal } = createNamespacedHelpers('personal');
+export default {
+  name: 'login',
+  props: {},
+  components: {
+    adminFrame,
+  },
+  data: function () {
+    return {
+      form: {},
+    };
+  },
+  async created() {},
+  methods: {
+    ...personal(['updatePassword']),
+    async onSubmit(values) {
+      let data = { id: this.user.id, password: values.password };
+      let res = await this.updatePassword(data);
+      if (this.$checkRes(res)) {
+        let token = localStorage.removeItem('token');
+        let openid = sessionStorage.removeItem('openid');
+        if (token == undefined && openid == undefined) {
+          this.$toast({ type: 'fail', message: '退出登录成功' });
+          this.$router.push({ path: '/login', query: { path: '/exchange/center/index', type: '1' } });
+        }
+      } else {
+        this.$toast({ type: `fail`, message: `${res.errmsg}` });
+      }
+    },
+    back() {
+      this.$router.push({ path: `/exchange/center/index` });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>