YY преди 2 години
родител
ревизия
15d111ac00
променени са 4 файла, в които са добавени 96 реда и са изтрити 1 реда
  1. 2 0
      src/store/index.js
  2. 44 0
      src/store/module/system/emailResetPwd.js
  3. 23 0
      src/views/login.vue
  4. 27 1
      src/views/platmanag/storeAcc/detail.vue

+ 2 - 0
src/store/index.js

@@ -22,6 +22,7 @@ import config from './module/system/config';
 import platformAct from './module/system/platformAct';
 import goodsJoinAct from './module/system/goodsJoinAct';
 import admins from './module/system/admin';
+import emailResetPwd from './module/system/emailResetPwd';
 
 import shop from './module/shop/shop';
 import selfShop from './module/shop/selfShop';
@@ -71,5 +72,6 @@ export default new Vuex.Store({
     getBill,
     outBill,
     admins,
+    emailResetPwd,
   },
 });

+ 44 - 0
src/store/module/system/emailResetPwd.js

@@ -0,0 +1,44 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+const _ = require('lodash');
+Vue.use(Vuex);
+const api = {
+  url: '/point/v1/api/admin/emailResetPwd',
+};
+
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.url}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.url}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.url}/${payload}`);
+    return res;
+  },
+  async update({ commit }, payload) {
+    const id = _.get(payload, 'id', _.get(payload, '_id'));
+    const res = await this.$axios.$post(`${api.url}/${id}`, payload);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.url}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 23 - 0
src/views/login.vue

@@ -27,6 +27,9 @@
                   <el-form-item class="btn">
                     <el-button type="primary" @click="onSubmit('form')">登录</el-button>
                   </el-form-item>
+                  <el-col :span="24" style="text-align: center">
+                    <el-button type="text" style="color: blue; font-size: 14px" @click="toReset()">忘记密码?</el-button>
+                  </el-col>
                 </el-form>
               </el-col>
             </el-col>
@@ -42,6 +45,8 @@
 const _ = require('lodash');
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: maU } = createNamespacedHelpers('admin');
+const { mapActions: emailResetPwd } = createNamespacedHelpers('emailResetPwd');
+
 export default {
   name: 'login',
   props: {},
@@ -61,6 +66,7 @@ export default {
   created() {},
   methods: {
     ...maU(['login']),
+    ...emailResetPwd({ pwdCreate: 'create' }),
     onSubmit(formName) {
       this.$refs[formName].validate(async (valid) => {
         if (valid) {
@@ -80,6 +86,23 @@ export default {
         }
       });
     },
+    async toReset() {
+      if (this.form.account == undefined || this.form.account == '') {
+        this.$message.error('请输入账号');
+      } else {
+        this.$confirm('忘记密码,是否确认重置密码?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning',
+        }).then(async () => {
+          const res = await this.pwdCreate({ account: this.form.account });
+          if (this.$checkRes(res)) {
+            console.log(res);
+            this.$message({ type: `success`, message: `重置密码成功` });
+          }
+        });
+      }
+    },
   },
   computed: {
     ...mapState(['user']),

+ 27 - 1
src/views/platmanag/storeAcc/detail.vue

@@ -18,6 +18,7 @@
         @query="search"
         @edit="toEdit"
         @del="toDel"
+        @reset="toReset"
       ></data-table>
     </template>
     <template v-else>
@@ -43,6 +44,7 @@ import methodsUtil from '@/util/opera';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: admins } = createNamespacedHelpers('admins');
 const { mapActions: role } = createNamespacedHelpers('role');
+const { mapActions: emailResetPwd } = createNamespacedHelpers('emailResetPwd');
 export default {
   name: 'index',
   props: {},
@@ -57,6 +59,7 @@ export default {
       ],
       opera: [
         { label: '修改', method: 'edit' },
+        { label: '重置密码', method: 'reset' },
         { label: '删除', method: 'del', confirm: true, type: 'danger' },
       ],
       btnList: [{ label: '添加', method: 'add' }],
@@ -70,7 +73,8 @@ export default {
         { label: '名称', model: 'name' },
         { label: '账号', model: 'account' },
         { label: '角色', model: 'role', type: 'select' },
-        { label: '密码', model: 'password', type: 'password' },
+        { label: '邮箱', model: 'email' },
+        { label: '密码', model: 'password', type: 'password', display: (i) => i.password == '' },
       ],
       rules: {},
       form: {},
@@ -84,7 +88,9 @@ export default {
   methods: {
     ...methodsUtil,
     ...role({ roleQuery: 'query' }),
+    ...emailResetPwd({ pwdCreate: 'create' }),
     ...admins(['query', 'delete', 'fetch', 'update', 'create']),
+    // 重置
     async search({ skip = 0, limit = this.limit, ...others } = {}) {
       others.shop = this.id;
       let query = { skip, limit, ...others };
@@ -95,10 +101,12 @@ export default {
         this.$set(this, `total`, res.total);
       }
     },
+    // 添加自定义
     initAddData() {
       const obj = { shop: this.id };
       this.$set(this, 'form', obj);
     },
+    // 修改
     async toEdit({ data }) {
       const res = await this.fetch(data._id);
       if (this.$checkRes(res)) {
@@ -109,6 +117,20 @@ export default {
         this.$message.error('未找到指定数据');
       }
     },
+    // 重置密码
+    async toReset({ data }) {
+      this.$confirm('忘记密码,是否确认重置密码?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(async () => {
+        const res = await this.pwdCreate({ account: data.account });
+        if (this.$checkRes(res)) {
+          this.$message({ type: `success`, message: `重置密码成功` });
+          this.search();
+        }
+      });
+    },
     // 删除
     async toDel({ data }) {
       let res = await this.delete(data._id);
@@ -117,6 +139,7 @@ export default {
         this.search();
       }
     },
+    // 保存
     async toSave({ data }) {
       let res;
       if (data.id) res = await this.update(data);
@@ -126,15 +149,18 @@ export default {
         this.toBackList();
       }
     },
+    // 查询其他信息
     async searchOthers() {
       let res = await this.roleQuery();
       if (this.$checkRes(res)) {
         this.$set(this, `roleList`, res.data);
       }
     },
+    // 返回
     toBack() {
       window.history.go('-1');
     },
+    // 返回列表
     toBackList() {
       this.view = 'list';
       this.form = {};