Jelajahi Sumber

修改忘记密码

xiaodai2017 1 tahun lalu
induk
melakukan
60507e9e2e

+ 2 - 2
src/apis/service/user/index.js

@@ -3,8 +3,8 @@ import https from '@/apis/axios'
 
 export default {
   // 获取验证码
-  verfiy: (data, params) => http(`admin/verify_code`, data, 'post', params),
-  // 密码重置
+  verfiy: (data, params) => http(`api/wechat/getCodebyMombile`, data, 'post', params),
+  // 手机号验证码密码重置
   resetpwd: (data, params) => http(`admin/user/passmobile`, data, 'post', params),
   // 手机号更换
   resetmobile: (data, params) =>

+ 27 - 20
src/components/globalComponents/send-verification-code/main.vue

@@ -11,10 +11,11 @@
 
 <script>
 import { isMobile } from "@/utils/validate";
-import asyncRequest from "@/apis/service/user/index";
+import asyncRequest from "@/apis/service/user";
+
 import resToken from "@/mixins/resToken";
 export default {
-  name:"sendVerificationCode",
+  name: "sendVerificationCode",
   props: {
     mobile: {
       type: String,
@@ -34,24 +35,30 @@ export default {
     getCode() {
       if (this.mobile !== "" && isMobile(this.mobile)) {
         if (this.num === 60) {
-          asyncRequest.verfiy({ mobile: this.mobile }).then(async (res) => {
-            if (res && res.code === 0) {
-              this.timer = setInterval(() => {
-                if (this.num !== 0) {
-                  this.title = `${this.num}s后可重发`;
-                  this.num--;
-                } else {
-                  clearInterval(this.timer);
-                  this.num = 60;
-                  this.title = "获取验证码";
-                }
-              }, 1000);
-            } else if (res && res.code >= 100 && res.code <= 104) {
-              await this.logout();
-            } else {
-              this.$message.warning(res.message);
-            }
-          });
+          asyncRequest
+            .verfiy({ mobile: this.mobile })
+            .then(async ({ code, msg }) => {
+              if (code === 1) {
+                this.timer = setInterval(() => {
+                  if (this.num !== 0) {
+                    this.title = `${this.num}s后可重发`;
+                    this.num--;
+                  } else {
+                    clearInterval(this.timer);
+                    this.num = 60;
+                    this.title = "获取验证码";
+                  }
+                }, 1000);
+              } else if (code === 1001) {
+                this.$message.warning("验证码发送失败!");
+              } else if (code === 1002) {
+                this.$message.warning("验证码未过期,请2分钟后重试!");
+              } else if (code === 1003) {
+                this.$message.warning("验证码发送失败!!");
+              } else {
+                this.$message.warning(msg);
+              }
+            });
         }
       } else {
         this.$emit("mobileErr", false);

+ 1 - 1
src/main.js

@@ -82,7 +82,7 @@ Vue.config.productionTip = false
 Vue.use(ElementUI)
 
 router.beforeEach((to, from, next) => {
-  if (to.path === '/login' || from.path === '/accept') {
+  if (to.path === '/login' ||to.path === '/forget-password' || from.path === '/accept') {
     next()
   } else if (getToken() === null || getToken() === undefined || getToken() === '') {
     removeMenu()

+ 1 - 1
src/router/index.js

@@ -8,7 +8,7 @@ const routes = [
   // 登录页
   {
     path: '/login',
-    component: () => import('@/views/login/index1'),
+    component: () => import('@/views/login/index'),
     hidden: true
   },
   // 忘记密码

+ 13 - 13
src/views/login/forget-password.vue

@@ -31,7 +31,7 @@
             label-position="left"
             label-width="95px"
           >
-            <el-form-item prop="username" label="账号:">
+            <!-- <el-form-item prop="username" label="账号:">
               <el-input
                 ref="username"
                 v-model="loginFormX.username"
@@ -42,7 +42,7 @@
                 maxlength="50"
                 autocomplete="on"
               />
-            </el-form-item>
+            </el-form-item> -->
             <el-form-item prop="mobile" label="手机号:">
               <el-input
                 ref="mobile"
@@ -163,13 +163,13 @@ export default {
   name: 'Login',
   mixins: [resToken],
   data() {
-    const validateUsername = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请输入账号'))
-      } else {
-        callback()
-      }
-    }
+    // const validateUsername = (rule, value, callback) => {
+    //   if (value === '') {
+    //     callback(new Error('请输入账号'))
+    //   } else {
+    //     callback()
+    //   }
+    // }
     const validatemobile = (rule, value, callback) => {
       if (value === '') {
         callback(new Error('手机号不能为空!'))
@@ -228,14 +228,14 @@ export default {
       num: 3,
       step: 0,
       loginFormX: {
-        username: '',
+        // username: '',
         mobile: '',
         code: ''
       },
       loginRulesX: {
-        username: [
-          { required: true, trigger: 'blur', validator: validateUsername }
-        ],
+        // username: [
+        //   { required: true, trigger: 'blur', validator: validateUsername }
+        // ],
         mobile: [
           { required: true, trigger: 'blur', validator: validatemobile }
         ],

+ 5 - 5
src/views/login/index.vue

@@ -91,8 +91,8 @@
           @click.native.prevent="handleLogin()"
         >登&nbsp;&nbsp;录</el-button>
 
-        <!-- <div style="position: relative; padding: 12px 0 0 0"> -->
-        <!-- <div class="tips" style="float: left">
+        <div style="position: relative; padding: 12px 0 0 0">
+       <!-- <div class="tips" style="float: left">
             <el-popover
               placement="top"
               title="初始密码:"
@@ -103,12 +103,12 @@
               <i slot="reference" class="el-icon-info" />
             </el-popover>
           </div> -->
-        <!-- <router-link to="/forget-password">
+         <router-link to="/forget-password">
             <div class="tips" style="float: right">
               <span>忘记密码</span>
             </div>
-          </router-link> -->
-        <!-- </div> -->
+          </router-link> 
+       </div>
       </el-form>
     </div>
 

+ 45 - 152
src/views/operate/account/addEdit.vue

@@ -5,7 +5,7 @@
     :center="true"
     align="left"
     top="10vh"
-    width="750px"
+    width="500px"
     :close-on-click-modal="false"
     :visible.sync="showModelThis"
     element-loading-text="拼命加载中"
@@ -25,71 +25,30 @@
             label-width="80px"
             class="demo-ruleForm"
           >
-            <el-row style="margin-bottom:20px">
-              <el-form-item prop="username" label="用户名" v-if="id === 'add'">
-                <el-input
-                  ßßsize="mini"
-                  v-model="ruleForm.username"
-                  placeholder="用户名"
-                 />
-              </el-form-item>
+            <el-form-item label="手机号" prop="mobile">
+              <el-input
+                v-model="ruleForm.mobile"
+                :placeholder="'手机号'"
+                maxlength="11"
+                :disabled="isDetail"
+              />
+            </el-form-item>
 
-              <el-col :span="24">
-                <el-form-item label="昵称" prop="nickname">
-                  <el-input
-                    v-model="ruleForm.nickname"
-                    :placeholder="'账号名'"
-                    :disabled="isDetail"
-                    maxlength="100"
-                  />
-                </el-form-item>
-              </el-col>
-
-              <el-col :span="24">
-                <el-form-item label="密码" prop="password" v-if="id === 'add'">
-                  <el-input
-                    type="password"
-                    v-model="ruleForm.password"
-                    :placeholder="'密码'"
-                    :disabled="isDetail"
-                    maxlength="100"
-                  />
-                </el-form-item>
-              </el-col>
-              
-              <el-col :span="24">
-                <el-form-item label="手机号" prop="mobile">
-                  <el-input
-                    v-model="ruleForm.mobile"
-                    :placeholder="'手机号'"
-                    maxlength="11"
-                    :disabled="isDetail"
-                  />
-                </el-form-item>
-              </el-col>
-
-              <el-col :span="24" v-if="id === 'add'">
-                <el-form-item label="邮箱" prop="email">
-                  <el-input
-                    v-model="ruleForm.email"
-                    :placeholder="'邮箱'"
-                    maxlength="11"
-                    :disabled="isDetail"
-                  />
-                </el-form-item>
-              </el-col>
-
-              <!-- <el-col :span="24">
-                <el-form-item label="角色等级" prop="level">
-                  <el-select size="mini" style="width:100%" :disabled="isDetail" v-model="ruleForm.level" placeholder="角色等级">
-                    <el-option />
-                  </el-select>
-                </el-form-item>
-              </el-col> -->
-            </el-row>
+            <el-form-item label="验证码" prop="code">
+              <el-input
+                v-model="ruleForm.code"
+                :placeholder="'验证码'"
+                maxlength="6"
+                :disabled="isDetail"
+              >
+                <el-button slot="append" :disabled="numbers > 60" @click="codeTap">{{
+                  numbers === 60 ? "获取验证码" : numbers + "s后重试"
+                }}</el-button>
+              </el-input>
+            </el-form-item>
           </el-form>
         </el-col>
-        <el-col :span="6" class="bottom-btn">
+        <el-col :span="24" class="tr">
           <el-button v-if="!isDetail" type="primary" @click="submitForm" :size="'mini'"
             >保 存
           </el-button>
@@ -113,53 +72,17 @@ import {
 } from "@/utils/validate";
 
 /**
- * @props 
+ * @props
  *  nickname 账号名
  *  mobile 手机号
  *  level 角色等级
-*/
+ */
 
 export default {
   name: "Account",
   props: ["showModel", "id", "isDetail", "sitem"],
   mixins: [resToken],
   data() {
-    const validateusername = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("账号不能为空!"));
-      } else {
-        if (value.length < 6 || value.length > 18) {
-          callback(new Error("账号规则为6~18位数字与字母组合!"));
-        } else {
-          if (isnumber(value)) {
-            callback(new Error("账号规则为6~18位数字与字母组合!"));
-          } else if (validAlphabets(value)) {
-            callback(new Error("账号规则为6~18位数字与字母组合!"));
-          } else if (!isAlphanumeric(value)) {
-            callback(new Error("账号规则为6~18位数字与字母组合!"));
-          } else {
-            callback();
-          }
-        }
-      }
-    };
-
-    const validatename = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("账号名不能为空!"));
-      } else {
-        if (value.length < 2 || value.length > 12) {
-          callback(new Error("账号名规则为2~12位!"));
-        } else {
-          if (isEmoticon(value)) {
-            callback(new Error("账号名规则为2~12位!"));
-          } else {
-            callback();
-          }
-        }
-      }
-    };
-
     const validatemobile = (rule, value, callback) => {
       if (value === "") {
         callback(new Error("手机号不能为空!"));
@@ -182,35 +105,28 @@ export default {
       is_mainoptions: [],
       isIndeterminate: false,
       ruleForm: {
-        password:"",
-        username:"",
+        password: "",
+        username: "",
         nickname: "", // 账号名
         mobile: "", //手机号
         role_id: "", //角色id
       },
       platformoptions: [],
       rules: {
-        nickname: [
+        mobile: [
           {
             required: true,
-            validator: validatename,
+            validator: validatemobile,
             trigger: "blur",
           },
         ],
-        mobile: [
+        code: [
           {
             required: true,
-            validator: validatemobile,
             trigger: "blur",
+            message: "角色等级",
           },
         ],
-        level:[
-          {
-            required:true,
-            trigger:'blur',
-            message:'角色等级'
-          }
-        ]
       },
     };
   },
@@ -261,7 +177,7 @@ export default {
       if (code === 1) {
         this.organizeList = data;
         this.recursion(this.organizeList);
-      } 
+      }
     },
     handleCheckedCitiesChange(value) {
       console.log(value);
@@ -305,7 +221,7 @@ export default {
       });
       if (code === 1) {
         await this.resetForm(data);
-      } 
+      }
     },
     async resetForm() {
       // 重置
@@ -314,33 +230,23 @@ export default {
           this.$refs.ruleForm.resetFields();
           this.$refs.ruleForm.clearValidate();
           if (this.sitem) {
-            const {
-              email,
-              password,
-              username,
-              nickname,
-              mobile,
-              id
-            } = this.sitem;
+            const { email, password, username, nickname, mobile, id } = this.sitem;
 
             this.ruleForm = {
               id,
-              email:email || "",
-              password:password || "",
-              username:username || "",
+              email: email || "",
+              password: password || "",
+              username: username || "",
               nickname: nickname || "",
-              mobile: mobile || ""
+              mobile: mobile || "",
             };
-
-
-
           } else {
             this.ruleForm = {
-              email:"",
-              password:"",
-              username:"",
+              email: "",
+              password: "",
+              username: "",
               nickname: "", // 账号名
-              mobile: ""
+              mobile: "",
             };
           }
         }
@@ -351,15 +257,9 @@ export default {
         if (valid) {
           if (!this.loading) {
             this.loading = true;
-            const {
-              username,
-              nickname,
-              password,
-              mobile,
-              email,
-              id
-            } = JSON.parse(JSON.stringify(this.ruleForm));
-
+            const { username, nickname, password, mobile, email, id } = JSON.parse(
+              JSON.stringify(this.ruleForm)
+            );
 
             const model = {
               password,
@@ -367,7 +267,7 @@ export default {
               username,
               mobile,
               email,
-              id
+              id,
             };
 
             let res = {};
@@ -401,12 +301,5 @@ export default {
 
 <style lang="scss" scoped>
 .account {
-  .bottom-btn {
-    position: absolute;
-    bottom: 0px;
-    right: 0;
-    text-align: right;
-    z-index: 2;
-  }
 }
 </style>