quanwei
2025-11-21 2d9362ae6f528f57e6133d5d80f0b633c24e8eb6
shop_vue/src/views/login.vue
@@ -20,7 +20,7 @@
          </el-input>
        </div>
      </el-form-item>
      <el-form-item prop="verifycode" style="line-height:0px;">
      <el-form-item prop="verifycode" style="line-height:0px;" v-show="shop_login_err_num >= 3">
        <div class="d-b-c">
          <div class="left-img-input" style="width: auto;">
            <el-input v-model="ruleForm.verifycode" ref="verifycode" placeholder="验证码" class="l-input"
@@ -46,6 +46,7 @@
  import UserApi from '@/api/user.js';
  import {
    setCookie,
    getCookie,
    setSessionStorage
  } from '@/utils/base.js';
  export default {
@@ -55,16 +56,19 @@
    data() {
      // 验证码自定义验证规则
      const validateVerifycode = (rule, value, callback) => {
        if (value === "") {
          this.refreshCode();
          callback(new Error('请输入验证码'))
        } else if (value !== this.identifyCode) {
          console.log('验证码:', value);
          this.refreshCode();
          callback(new Error('验证码不正确!'))
        } else {
          callback()
        this.shop_login_err_num = parseInt(getCookie('shop_login_err_num')) || 0;
        // 错误次数过多时校验验证码 by lyzflash
        if (this.shop_login_err_num >= 3) {
          if (value === "") {
            this.refreshCode();
            callback(new Error('请输入验证码'))
          } else if (value !== this.identifyCode) {
            // console.log('验证码:', value);
            this.refreshCode();
            callback(new Error('验证码不正确!'))
          }
        }
        callback();
      }
      return {
        loginForm: {},
@@ -106,10 +110,12 @@
          }]
        },
        /*基础配置*/
        baseData: {}
        baseData: {},
        shop_login_err_num: 0, // 登录错误次数
      };
    },
    created() {
      this.shop_login_err_num = parseInt(getCookie('shop_login_err_num')) || 0;
      this.refreshCode();
      this.getData();
      if (this.$route.query.from && this.$route.query.from == 'admin') {
@@ -178,6 +184,7 @@
                  setCookie('userinfo', res.data);
                  /*设置一个登录状态*/
                  setCookie('isLogin', true);
                  setCookie('shop_login_err_num', 0); // 登录成功后将登录错误次数清0 by lyzflash
                  /*跳转到首页*/
                  this.$router.push({
                    path: '/'