xiaodai2017 1 year ago
parent
commit
0566a7e6dd

+ 3 - 1
src/apis/user/index.js

@@ -7,7 +7,9 @@ export default {
   login: (data, params) => http("admin/login/login", data, "post", params),
   //手机号验证码登录
   mobileLogin: (data, params) => http("api/wechat/loginByMobile", data, "post", params),
-  //
+   //手机号获取验证码
+  getCodebyMombile: (data, params) => http("api/wechat/getCodebyMombile", data, "post", params),
+  //获取菜单
   requestMenus: (data, params) =>
     http("admin/menu/query", data, "post", params),
   // 获取个人信息

+ 1 - 1
src/router/index.js

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

+ 65 - 25
src/views/login/index1.vue

@@ -16,7 +16,7 @@
           </h3>
         </div>
 
-        <el-form-item prop="mobile" >
+        <el-form-item prop="mobile">
           <el-input
             ref="mobile"
             v-model="loginForm.mobile"
@@ -27,31 +27,30 @@
             maxlength="11"
             autocomplete="on"
           >
-          <span class="svg-container" slot="prepend">
+            <span class="svg-container" slot="prepend">
               <i class="el-icon-user" />
             </span>
           </el-input>
         </el-form-item>
 
-   
-          <el-form-item prop="code" >
-            
-            <el-input
-              ref="code"
-              v-model="loginForm.code"
-              placeholder="验证码"
-              type="text"
-              tabindex="2"
-              autocomplete="on"
-              maxlength="6"
-             
-            >
+        <el-form-item prop="code">
+          <el-input
+            ref="code"
+            v-model="loginForm.code"
+            placeholder="验证码"
+            type="text"
+            tabindex="2"
+            autocomplete="on"
+            maxlength="6"
+          >
             <span class="svg-container" slot="prepend">
               <i class="el-icon-unlock" />
             </span>
-              <el-button slot="append" >获取验证码</el-button>
-            </el-input>
-          </el-form-item>
+            <el-button slot="append" :disabled="numbers > 60" @click="codeTap">{{
+              numbers === 60 ? "获取验证码" : numbers + "s后重试"
+            }}</el-button>
+          </el-input>
+        </el-form-item>
 
         <el-button
           :loading="loading"
@@ -112,6 +111,8 @@ export default {
 
     return {
       ver: "",
+      numbers: 60,
+      timer: null,
       show: false,
       loginTitle: urlConfig.loginTitle,
       loginBeian: urlConfig.loginBeian,
@@ -154,13 +155,8 @@ export default {
       this.$refs.code.focus();
     }
   },
- 
+
   methods: {
- 
-  
-  
-  
-   
     async handleLogin() {
       try {
         await this.$refs.loginForm.validate();
@@ -173,6 +169,51 @@ export default {
         this.loading = false;
       }
     },
+    async codeTap() {
+      if (this.loginForm.mobile === "") {
+        this.$message.warning("手机号不能为空!");
+
+        return;
+      }
+      if (!isMobile(this.loginForm.mobile)) {
+        this.$message.warning("手机号不正确!");
+
+        return;
+      }
+      if (this.numbers !== 60) {
+        return;
+      }
+
+      // const {
+      //   code,
+      //   msg
+      // } = await asyncRequest.getCodebyMombile({
+      //   mobile:this.loginForm.mobile
+      // })
+      const code = 1,
+        msg = "";
+      if (code === 1) {
+        this.timer = setInterval(() => {
+          if (this.numbers !== 0) {
+            this.numbers--;
+          } else {
+            if (this.timer) {
+              clearTimeout(this.timer);
+              this.numbers = 60;
+            }
+          }
+        }, 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);
+      }
+    },
+
     getMenu() {
       this.$store
         .dispatch("user/getMenuList", this)
@@ -199,7 +240,6 @@ export default {
 };
 </script>
 
-
 <style lang="scss" scoped>
 $bg: #2d3a4b;
 $dark_gray: #38c1e7;

+ 0 - 4
src/views/operate/shopTrim/baseData/index.vue

@@ -451,10 +451,6 @@ export default {
           this.loading = true;
           let model = JSON.parse(JSON.stringify(this.ruleForm));
           model.store_id = this.store_id;
-          // model.id = this.store_id;
-          // model.park_num = 0;
-          console.log(model);
-
           let res = await asyncRequest.update(model);
 
           this.loading = false;