Bläddra i källkod

Merge branch 'master' of http://git.cc-lotus.info/service-platform/mobile-official

guhongwei 4 år sedan
förälder
incheckning
fff226a7b9

+ 7 - 0
src/router/index.js

@@ -64,6 +64,13 @@ const routes = [
     meta: { title: '个人中心', isleftarrow: false },
     component: () => import('../views/user/index.vue'),
   },
+  //修改密码
+  {
+    path: '/user/parts/changePwd',
+    name: 'changePwd',
+    meta: { title: '修改密码', isleftarrow: true },
+    component: () => import('../views/user/parts/changePwd.vue'),
+  },
   // 用户-我的发布
   {
     path: '/userCenter/myProduct/index',

+ 4 - 0
src/store/index.js

@@ -8,6 +8,8 @@ import product from './market/product';
 import exportuser from './market/exportuser';
 // 登录
 import login from './user/login';
+//修改密码
+import password from './user/password';
 // 个人中心
 import marketuser from './market/user';
 import markettype from './market/markettype';
@@ -43,5 +45,7 @@ export default new Vuex.Store({
     transaction,
     // 交易记录
     productpact,
+    //修改密码
+    password,
   },
 });

+ 43 - 0
src/store/user/password.js

@@ -0,0 +1,43 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  userInfo: `/api/auth/user/uppasswd`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.userInfo}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.userInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.userInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.userInfo}`, payload);
+    return res;
+  },
+
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.userInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 93 - 0
src/views/user/parts/changePwd.vue

@@ -0,0 +1,93 @@
+<template>
+  <div id="changePwd">
+    <el-row>
+      <el-col :span="24">
+        <el-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
+        </el-col>
+        <el-col :span="24" class="pwd">
+          <van-form :model="form">
+            <van-field v-model="form.oldpasswd" type="password" name="密码" label="旧密码" placeholder="请输入旧密码" />
+            <van-field v-model="form.newpasswd" type="password" name="密码" label="新密码" placeholder="请输入新密码" />
+            <el-col :span="24" class="btn1">
+              <el-button @click="resetForm('form')">取消</el-button>
+              <el-button type="primary" @click="submitForm('form')">提交</el-button>
+            </el-col>
+          </van-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+import NavBar from '@/layout/common/topInfo.vue';
+const { mapActions: password } = createNamespacedHelpers('password');
+const { mapActions: login } = createNamespacedHelpers('login');
+export default {
+  name: 'changePwd',
+  props: {},
+  components: {
+    NavBar,
+  },
+  data: function() {
+    return {
+      // 头部标题
+      title: '',
+      // meta为true
+      isleftarrow: '',
+      // 返回
+      navShow: true,
+      form: {},
+    };
+  },
+  created() {},
+  methods: {
+    ...password(['query', 'update']),
+    ...login(['toGetMenu', 'logout']),
+    resetForm(formName) {
+      this.form = {};
+    },
+    async submitForm() {
+      let data = this.form;
+      data.id = this.user.uid;
+      let res = await this.update(data);
+      if (res.errcode === 0) {
+        this.$notify({
+          message: '修改成功',
+          type: 'success',
+        });
+        this.logout();
+      } else {
+        this.$notify({
+          message: res.errmsg,
+          type: 'danger',
+        });
+      }
+      this.$router.push({ path: '/live/index' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.top {
+  height: 46px;
+  overflow: hidden;
+}
+.btn1 {
+  text-align: center;
+  margin-top: 10px;
+}
+</style>

+ 6 - 0
src/views/user/parts/clickBtn.vue

@@ -28,6 +28,7 @@
           </span>
         </span>
         <van-cell is-link title="退出登录" @click="loginOut()" />
+        <van-cell is-link title="修改密码" @click="change()" />
         <!-- <span v-else>
           <span v-else-if="user.role == '3'">
             <van-cell is-link title="展会管理" @click="$router.push({ path: '/dockCenter/dockInfo/index' })" />
@@ -68,6 +69,7 @@ export default {
   methods: {
     ...login(['toGetMenu', 'logout']),
     async searchMenu() {
+      // console.log(this.user);
       const res = await this.toGetMenu({ id: this.user.uid });
       for (const val of res.data.menus) {
         if (val.role_name == '用户管理') {
@@ -90,6 +92,10 @@ export default {
       });
       this.$router.push({ path: '/live/index' });
     },
+    //修改密码
+    change() {
+      this.$router.push({ path: './parts/changePwd' });
+    },
   },
   computed: {
     ...mapState(['user']),

+ 7 - 7
src/views/userCenter/parts/person.vue

@@ -265,7 +265,7 @@ export default {
         let msg;
         res = await this.expertsuserUpdate(this.form);
       }
-      this.$message({
+      this.$notify({
         message: '修改信息成功',
         type: 'success',
       });
@@ -275,7 +275,7 @@ export default {
       let res;
       let msg;
       res = await this.update(this.form);
-      this.$message({
+      this.$notify({
         message: '提交认证信息成功,等待管理员认证',
         type: 'success',
       });
@@ -286,16 +286,16 @@ export default {
       this.form.uid = this.user.uid;
       let res = await this.expertsuserUpgrade(this.form);
       if (this.$checkRes(res)) {
-        this.$message({
-          message: '用戶升級成功,等待管理员审核',
+        this.$notify({
+          message: '用户升级成功,等待管理员审核',
           type: 'success',
         });
         this.logout();
         this.$router.push({ path: '/webLogin' });
       } else {
-        this.$message({
-          message: '用戶升級失敗',
-          type: 'error',
+        this.$notify({
+          message: res.errmsg,
+          type: 'danger',
         });
       }
     },