+
+
+
-
-
所属类别
-
@@ -155,7 +155,7 @@
+ :disabled="isDisabled1 || isGettingCode1" @click="debouncedGetCode1">
{{ SendCode_text1 }}
@@ -246,6 +246,12 @@ export default {
timer: null, // 手机登录验证码定时器
timer1: null, // 重置密码验证码定时器
+ // 防抖相关
+ isGettingCode: false, // 是否正在获取验证码
+ isGettingCode1: false, // 是否正在获取重置密码验证码
+ debounceTimer: null, // 防抖定时器
+ debounceTimer1: null, // 重置密码防抖定时器
+
// 对话框和加载状态
dialogVisible: false, // 重置密码对话框是否可见
loading: false, // 登录按钮加载状态
@@ -347,6 +353,50 @@ export default {
},
methods: {
+ // 防抖函数
+ debounce(func, wait) {
+ return function() {
+ const context = this;
+ const args = arguments;
+ clearTimeout(this.debounceTimer);
+ this.debounceTimer = setTimeout(() => {
+ func.apply(context, args);
+ }, wait);
+ };
+ },
+
+ // 防抖后的获取验证码方法
+ debouncedGetCode: function() {
+ if (this.isDisabled || this.isGettingCode) return;
+
+ this.isGettingCode = true;
+
+ // 清除之前的定时器
+ clearTimeout(this.debounceTimer);
+
+ // 设置新的定时器,300ms后执行
+ this.debounceTimer = setTimeout(() => {
+ this.getCode();
+ this.isGettingCode = false;
+ }, 300);
+ },
+
+ // 防抖后的获取重置密码验证码方法
+ debouncedGetCode1: function() {
+ if (this.isDisabled1 || this.isGettingCode1) return;
+
+ this.isGettingCode1 = true;
+
+ // 清除之前的定时器
+ clearTimeout(this.debounceTimer1);
+
+ // 设置新的定时器,300ms后执行
+ this.debounceTimer1 = setTimeout(() => {
+ this.getCode1();
+ this.isGettingCode1 = false;
+ }, 300);
+ },
+
// 跳转到百度产品页面
goBaidu(listUrl, url) {
this.$store.commit('setRedirectUrl', url)
@@ -695,6 +745,9 @@ export default {
});
}
}
+ }).catch(error => {
+ this.isGettingCode = false;
+ this.$message.error('验证码获取失败');
});
},
@@ -743,6 +796,9 @@ export default {
type: "error",
});
}
+ }).catch(error => {
+ this.isGettingCode1 = false;
+ this.$message.error('验证码获取失败');
});
},