Quellcode durchsuchen

Finish Hotfix-15

chen vor 3 Jahren
Ursprung
Commit
5e6ecddff0
3 geänderte Dateien mit 52 neuen und 13 gelöschten Zeilen
  1. 4 1
      src/store/modules/user.js
  2. 4 6
      src/views/finance/credit_list.vue
  3. 44 6
      src/views/login/index.vue

+ 4 - 1
src/store/modules/user.js

@@ -65,13 +65,16 @@ const mutations = {
 const actions = {
   // user login
   login({ commit }, userInfo) {
-    const { username, password, code, codeValue } = userInfo;
+    const { username, password, code, codeValue, loginType, smsCode } =
+      userInfo;
     return new Promise((resolve, reject) => {
       login({
         userName: username.trim(),
         password: password,
         code: code,
         codeValue: codeValue,
+        loginType,
+        smsCode,
       })
         .then((response) => {
           const { data } = response;

+ 4 - 6
src/views/finance/credit_list.vue

@@ -164,10 +164,9 @@
           <el-date-picker
             class="selectStyle"
             v-model="addForm.startTime"
-            type="datetime"
+            type="date"
             placeholder="选择日期时间"
-            default-time="00:00:00"
-            value-format="yyyy-MM-dd HH:mm:ss"
+            value-format="yyyy-MM-dd"
           >
           </el-date-picker>
         </el-form-item>
@@ -175,10 +174,9 @@
           <el-date-picker
             class="selectStyle"
             v-model="addForm.endTime"
-            type="datetime"
+            type="date"
             placeholder="选择日期时间"
-            default-time="00:00:00"
-            value-format="yyyy-MM-dd HH:mm:ss"
+            value-format="yyyy-MM-dd"
           >
           </el-date-picker>
         </el-form-item>

+ 44 - 6
src/views/login/index.vue

@@ -23,7 +23,10 @@
                 class="carousel"
               >
                 <el-carousel-item v-for="item in banner" :key="item.id">
-                  <el-image :z-index="1" :src="imageURL + item.imgCarouselUrl"></el-image>
+                  <el-image
+                    :z-index="1"
+                    :src="imageURL + item.imgCarouselUrl"
+                  ></el-image>
                 </el-carousel-item>
               </el-carousel>
             </div>
@@ -220,7 +223,11 @@
                         />
                       </el-form-item>
                       <div class="code2" @click.stop="getSmsCode">
-                        <el-button>获取验证码</el-button>
+                        <el-button :disabled="countDown != 60">{{
+                          countDown == 60
+                            ? getCodeText
+                            : "重新获取(" + countDown + "s)"
+                        }}</el-button>
                       </div>
                     </div>
                     <div class="button-container">
@@ -277,8 +284,11 @@ export default {
   name: "Login",
   data() {
     const validateUsername = (rule, value, callback) => {
-      if (value.length <= 0) {
+      console.log(this.loginForm.loginType);
+      if (value.length <= 0 && this.loginForm.loginType == "account") {
         callback(new Error("请输入用户名"));
+      } else if (value.length <= 0 && this.loginForm.loginType == "mobile") {
+        callback(new Error("请输入手机号"));
       } else {
         callback();
       }
@@ -297,7 +307,17 @@ export default {
         callback();
       }
     };
+    const validatesmsCode = (rule, value, callback) => {
+      if (value.length <= 0) {
+        callback(new Error("请输入短信验证码"));
+      } else {
+        callback();
+      }
+    };
     return {
+      getCodeText: "获取验证码",
+      countDown: 60,
+      timer: null,
       imageURL: this.$imageUrl,
       loginForm: {
         username: "",
@@ -317,6 +337,9 @@ export default {
         codeValue: [
           { required: true, trigger: "change", validator: validateCode },
         ],
+        smsCode: [
+          { required: true, trigger: "change", validator: validatesmsCode },
+        ],
       },
       loading: false,
       passwordType: "password",
@@ -355,6 +378,17 @@ export default {
     //获取短信验证码
     async getSmsCode() {
       await getAdminUserSmsCode({ mobile: this.loginForm.username });
+      this.$successMsg("短信已发送");
+      this.isDisabled = true;
+      this.countDown--;
+      this.timer = setInterval(() => {
+        this.countDown--;
+        if (this.countDown == 0) {
+          this.countDown = 60;
+          this.getCodeText = "重新获取";
+          clearInterval(this.timer);
+        }
+      }, 1000);
     },
     // 获取验证码
     getCode() {
@@ -374,9 +408,12 @@ export default {
         this.banner = res.data;
       });
     },
-    hanleTabs(val, type) {
+    async hanleTabs(val, type) {
       this.acitve = val;
       this.loginForm.loginType = type;
+      this.$refs.loginForm.resetFields();
+      this.loginForm.password = "";
+      this.loginForm.username = "";
     },
     // 显示隐藏密码
     showPwd() {
@@ -392,17 +429,18 @@ export default {
 
     // 登录
     handleLogin() {
-      console.log(this.loginForm, "lll");
+      // console.log(this.loginForm, "lll");
       this.$refs.loginForm.validate((valid) => {
         if (valid) {
           this.loading = true;
           this.$store
             .dispatch("user/login", this.loginForm)
             .then(() => {
-              console.log(this.redirect);
+              // console.log(this.redirect);
               this.$router.push({ path: this.redirect || "/" });
               this.saveUnAndPw();
               this.$store.commit("user/showMessage", "yes");
+              // this.$message.success("登录成功");
               this.loading = false;
             })
             .catch(() => {