$(function () { if(localStorage.getItem("userName")){ $(".header-login p").html(localStorage.getItem("userName")) $(".header-login").removeClass('login-user').addClass('login-active') }else{ $(".header-login").removeClass('login-active').addClass('login-user') } //登录 $('.login-user').on('click', function () { layer.open({ type: 1, skin: 'layui-layer-login', //样式类名 title: false, anim: 2, shade: 0.8, shadeClose: false, //开启遮罩关闭 content: $('#form-layer'), cancel: function(index, layero){ // layer.close(index); // alert("你点击了右上角的X"); } }); }) // 登录提交 $('.login-submit').on('click', function (event) { event.preventDefault(); var username = $('input[type="text"]').val(); var password = $('input[type="password"]').val(); if (username === '' || password === '') { layer.msg('账号和密码不能为空!', { offset: 50, anim: 6 }); return; } // 检查账号是否为 "admin" 且密码是否为 "83560792" if (username !== 'admin' || password !== '83560792') { layer.msg('账号或密码错误!', { offset: 50, anim: 6 }); return; } layer.msg('登录成功', { offset: 50, anim: 0 }); setTimeout(()=>{ localStorage.setItem('userName',username) window.location.reload(); layer.closeAll(); },1000) }) // 查看用户信息 $('.login-active').on('click', function () { layer.open({ type: 1, skin: 'layui-layer-login', //样式类名 title: false, anim: 2, shade: 0.8, shadeClose: false, //开启遮罩关闭 content: $('#user-layer') }); }) // 切换账号 $(".change-accout-btn").on('click', function () { layer.closeAll(); localStorage.removeItem('userName') layer.open({ type: 1, skin: 'layui-layer-login', //样式类名 title: false, anim: 2, shade: 0.8, shadeClose: false, //开启遮罩关闭 content: $('#form-layer'), cancel: function(index, layero){ // layer.close(index); window.location.reload(); } }); }) // 退出程序 $(".doubleExit").dblclick(function(){ if (confirm("确定退出?")) { console.log("确定"); } else { console.log("取消"); } }); // 首页样式操作 $('.list-left li').hover( function() { $(this).removeClass('animate__backInLeft').addClass('animate__headShake'); }, function() { $(this).removeClass('animate__headShake') } ); $('.list-right li').hover( function() { $(this).removeClass('animate__backInRight').addClass('animate__headShake'); }, function() { $(this).removeClass('animate__headShake') } ); // 首页菜单点击操作 $('.index-list li').on('click', function () { const _this = $(this) $('.ai-human').css('animation-duration', '0.2s').addClass('animate__animated animate__flash') setTimeout(function () { $('.list-left li').removeClass('animate__backInLeft').addClass('animate__animated animate__backOutLeft') $('.list-right li').removeClass('animate__backInRight').addClass('animate__animated animate__backOutRight') setTimeout(function(){ const href = _this.find('a').attr('id'); if (href === 'page1') { window.location.href = 'page1.html'; } else if (href === 'page2') { window.location.href = 'page2.html'; } else if (href === 'page3') { window.location.href = 'page3.html'; } else if (href === 'page4') { window.location.href = 'page4.html'; } else if (href === 'page5') { window.location.href = 'page5.html'; } else if (href === 'aiChat') { window.location.href = 'ai_chat.html'; } return false; },1000) }, 300) }) })