更新二维码过期模式

This commit is contained in:
李志强 2025-06-07 16:10:42 +08:00
parent de2fcc055b
commit 58f330a0c9
2 changed files with 22 additions and 97 deletions

View File

@ -290,7 +290,7 @@
function bindTabEvents(moduleId) {
const tabItems = document.querySelectorAll(`#${moduleId} .tab-item`);
tabItems.forEach(tab => {
tab.addEventListener('click', function() {
tab.addEventListener('click', function () {
// 移除所有active类
tabItems.forEach(item => item.classList.remove('active'));
// 添加active类到当前点击的tab
@ -300,7 +300,7 @@
const selectedCategoryId = this.getAttribute('data-tab');
// 根据不同模块加载对应数据
switch(moduleId) {
switch (moduleId) {
case 'opencourse':
loadCategoryArticles(selectedCategoryId, 'webArticlesList');
break;
@ -498,7 +498,7 @@
return `
<div class="opencourse product-item" onclick="window.open('/index/program/detail?id=${program.id || ''}', '_blank')">
<div class="video">
<img src="${program.icon || '/static/images/default-program.png'}" alt="" class="cover">
<img src="${program.icon || ''}" alt="" class="cover">
</div>
<div class="introduction">
<div class="title">${program.title || '无标题'}</div>
@ -614,89 +614,8 @@
});
}
// 搜索功能相关代码
layui.use(['layer'], function () {
var layer = layui.layer;
var $ = layui.jquery;
// 搜索功能相关变量
var searchMask = $('#searchMask');
var searchInput = $('#searchInput');
var searchBtn = $('#searchBtn');
var searchIcons = $('#mainSearchIcon, #stickySearchIcon');
// 显示搜索框
function showSearch() {
searchMask.addClass('show');
searchInput.focus();
}
// 隐藏搜索框
function hideSearch() {
searchMask.removeClass('show');
searchInput.val('').blur();
}
// 执行搜索
function doSearch() {
var keyword = searchInput.val().trim();
if (keyword) {
window.location.href = '/search?keyword=' + encodeURIComponent(keyword);
} else {
layer.msg('请输入搜索关键词', { icon: 0 });
}
}
// 事件绑定
function bindEvents() {
// 点击搜索图标显示搜索框
searchIcons.on('click', showSearch);
// 点击蒙版背景隐藏搜索框
searchMask.on('click', function (e) {
if ($(e.target).hasClass('search-mask')) {
hideSearch();
}
});
// 搜索按钮点击事件
searchBtn.on('click', function (e) {
e.preventDefault();
doSearch();
});
// 回车键触发搜索
searchInput.on('keypress', function (e) {
if (e.which === 13) {
e.preventDefault();
doSearch();
}
});
// ESC键关闭搜索框
$(document).on('keydown', function (e) {
if (e.keyCode === 27 && searchMask.hasClass('show')) {
hideSearch();
}
});
// 输入框获得焦点时全选文本
searchInput.on('focus', function () {
this.select();
});
}
// 初始化
function init() {
bindEvents();
}
// 启动
init();
});
// 页面加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
loadWebArticles();
loadTechArticles();
loadResources();

View File

@ -276,7 +276,7 @@
<h2>微信扫码登录</h2>
<div class="qrcode-container">
<img id="qrcode" src="__IMAGES__/loading.gif" alt="微信登录二维码" onclick="reGenerateQrcode()">
<p>点击二维码可刷新</p>
<!-- <p>点击二维码可刷新</p> -->
</div>
<div id="status" class="status">正在加载二维码...</div>
<div id="error" class="error"></div>
@ -330,8 +330,14 @@
// 检查二维码是否过期
if (new Date().getTime() > qrcodeExpireTime) {
clearInterval(checkLoginTimer);
$('#status').text('二维码已过期,请点击刷新');
$('#qrcode').css('opacity', '0.5');
$('#status').html('二维码已过期<br>请点击刷新');
$('#qrcode').css('opacity', '0.02');
$('#status').css({
'position': 'relative',
'top': '-150px',
'font-size': '20px',
'font-weight': 'bolder'
});
return;
}