验证码

This commit is contained in:
dimengzhe
2025-04-21 08:59:47 +08:00
parent a36e6c7833
commit 87108a0dcd
3 changed files with 10 additions and 14 deletions

View File

@@ -11,21 +11,17 @@ layui.use([ 'carousel', 'form' ], function() {
// 刷新验证码方法 // 刷新验证码方法
function refreshCaptcha() { function refreshCaptcha() {
timestamp = (new Date()).valueOf(); timestamp = (new Date()).valueOf();
var type = system_config?.captchaType || "math"; // 默认 math,可根据配置变更 var type = system_config?.captchaType || "math"; // 默认 math
var url = basePath + "/captcha/captchaImage?type=" + type + "&timestamp=" + timestamp; var url = basePath + "/captcha/captchaImage?type=" + type + "&timestamp=" + timestamp;
$(".imgcode").attr("src", url); $(".imgcode").attr("src", url);
} }
// 页面加载时刷新验证码 // 页面加载时刷新验证码
$(function() { refreshCaptcha(); // ✅ 页面加载手动刷新
refreshCaptcha();
$('#telephone').focus(); $('#telephone').focus();
});
// 点击验证码图片刷新 // 点击验证码图片刷新
$('.imgcode').click(function () { $('.imgcode').off('click').on('click', refreshCaptcha); // ✅ 点击后刷新
refreshCaptcha();
});
// 监听提交 // 监听提交
form.on('submit(login_)', function(data) { form.on('submit(login_)', function(data) {
@@ -132,8 +128,8 @@ layui.use([ 'carousel', 'form' ], function() {
} }
}); });
setTimeout(function () { /*setTimeout(function () {
$('.imgcode').click(); $('.imgcode').click();
}, 100); // 确保 DOM 渲染完成 }, 100); // 确保 DOM 渲染完成*/
}); });

View File

@@ -97,7 +97,7 @@
</div>--> </div>-->
<div class="kelp_lofo_vercode kelpVerCode" > <div class="kelp_lofo_vercode kelpVerCode" >
<img class="imgcode" width="85%" title="看不清?点击更换" style="cursor:pointer;" <img class="imgcode" width="85%" title="看不清?点击更换" style="cursor:pointer;"
<#--src="${base}/captcha/captchaImage?type=math&timestamp=${.now?long}"--> /> src="${base}/captcha/captchaImage?type=math&timestamp=${.now?long}" />
</div> </div>
</div> </div>
</div> </div>

View File

@@ -12,8 +12,8 @@ public class RichFreeMarkerView extends FreeMarkerView {
protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request) protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request)
throws Exception { throws Exception {
// String baseUrl = "http://aos.yyundong.com" + request.getContextPath(); String baseUrl = "http://aos.yyundong.com" + request.getContextPath();
String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); // String baseUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
model.put("contextPath", request.getContextPath()); model.put("contextPath", request.getContextPath());
model.put("base", baseUrl); model.put("base", baseUrl);