锁屏功能,此处更新需要更新执行数据库语句:ALTER TABLE oa_admin ADD COLUMN is_lock int(1) NOT NULL DEFAULT 0 COMMENT '是否锁屏:1是0否' AFTER status;

This commit is contained in:
hdm 2022-09-06 23:48:59 +08:00
parent cb137323d8
commit 405261d095
5 changed files with 154 additions and 0 deletions

View File

@ -47,6 +47,7 @@ class Login
return to_assign(1, '该用户禁止登录,请与管理者联系');
}
$data = [
'is_lock' => 0,
'last_login_time' => time(),
'last_login_ip' => request()->ip(),
'login_num' => $admin['login_num'] + 1,
@ -68,4 +69,30 @@ class Login
Session::delete($session_admin);
return to_assign(0, "退出成功");
}
//锁屏
public function lock()
{
$session_admin = get_config('app.session_admin');
$admin= Session::get($session_admin);
if (request()->isAjax()) {
$param = get_params();
if($param['lock_password'] == ''){
return to_assign(1, '请输入登录密码解锁');
}
if(empty($admin)){
return to_assign(2, '登录超时,请重新登录');
}
$pwd = set_password($param['lock_password'], $admin['salt']);
if ($admin['pwd'] !== $pwd) {
return to_assign(1, '密码错误');
}
else{
Db::name('admin')->where('id',$admin['id'])->update(['is_lock'=>0]);
return to_assign(0, '解锁成功', ['uid' => $admin['id']]);
}
}
Db::name('admin')->where('id',$admin['id'])->update(['is_lock'=>1]);
return View();
}
}

View File

@ -36,6 +36,11 @@
<a href="javascript:;" id="theme" title="切换主题">
<i class="layui-icon layui-icon-set"></i>
</a>
</span>
<span class="gg-head-item gg-head-set">
<a href="/home/login/lock.html" title="锁屏">
<i class="iconfont icon-suozhu" style="font-size:21px; font-weight:800"></i>
</a>
</span>
<span class="gg-head-item gg-head-message">
<a href="javascript:;" data-href="/message/index/inbox" data-id="78" data-title="消息中心" class="side-menu-item" title="消息中心">

View File

@ -0,0 +1,97 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>{:get_system_config('web','admin_title')}</title>
<link rel="stylesheet" href="{__GOUGU__}/layui/css/layui.css?v={:get_system_config('web','version')}" media="all">
<style type="text/css">
html,body {width: 100%;height: 100%;background: #EAF3FF;}
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset;
}
#container {width: 100%;height: 100%;position: fixed;top: 0;left: 0;z-index: 999;
background: url({__IMG__}/bg.png);
background-size: cover;
}
#container .lock{width: 100%;height: 100%; position:absolute; top:0; left:0;
background:#000 url({__IMG__}/lock_bg.svg);
background-size: cover;
opacity:0.72
}
.login {width: 360px;text-align: center;position: absolute;top: 50%;left: 50%;margin-top: -240px;margin-left: -180px;border-radius: 12px;box-shadow: 0 2px 6px rgba(92, 110, 136, .32);
}
.login .top {width: 360px;height: 117px;background-color: #fbbc05;border-radius: 12px 12px 0 0;line-height: 117px;text-align: center;overflow: hidden;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
.login .top .bg1 {display: inline-block;width: 72px;height: 72px;background: #fff;opacity: .1;border-radius: 0 72px 0 0;position: absolute;left: 0;top: 42px;}
.login .top .bg2 {display: inline-block;width: 92px;height: 92px;background: #fff;opacity: .1;border-radius: 50%;position: absolute;right: -16px;top: -16px;}
.login .bottom {background-color: #fff;padding:26px 24px;border-radius: 0 0 12px 12px;}
.layui-input,.layui-textarea {height: 44px;border: 1px solid #ddd;}
.captcha_img img{width:142px; height:44px; cursor:pointer;}
.layui-btn {height: 45px;font-size: 16px;margin-top: 6px;background-color: #FF6347!important}
</style>
</head>
<body>
<div id="container">
<div class="lock"></div>
<div class="login">
<div class="top">
<img src="{__IMG__}/login_logo.png" height="60" width="200">
<span class="bg1"></span>
<span class="bg2"></span>
</div>
<div class="bottom">
<form class="layui-form" id="gougu-lock">
<div class="layui-form-item" style="font-size:32px; color:#FF6347; padding:16px 0">
当前是锁屏状态
</div>
<div class="layui-form-item">
<input type="password" name="lock_password" lay-verify="required" value="" placeholder="请输入登录密码解锁" lay-reqText="请输入登录密码" autocomplete="off" class="layui-input">
</div>
<button id="lock-submit" class="layui-btn layui-btn-fluid layui-bg-cyan" lay-submit lay-filter="lock-submit">解锁进入系统</button>
</form>
</div>
</div>
</div>
<script src="{__GOUGU__}/layui/layui.js?v={:get_system_config('web','version')}"></script>
<script type="text/javascript">
layui.use(['form'], function() {
var form = layui.form,
$ = layui.$,
layer = layui.layer;
// 登录过期的时候跳出ifram框架
if (top.location != self.location) top.location = self.location;
form.on('submit(lock-submit)', function(data) {
$.ajax({
url: "/home/login/lock",
data: $('#gougu-lock').serialize(),
type: 'post',
async: false,
success: function(res) {
layer.tips(res.msg, '#lock-submit');
if (res.code === 0) {
setTimeout(function() {
parent.document.location.href="/";
}, 1200);
}
else if (res.code === 2) {
setTimeout(function() {
parent.document.location.href="/home/login/index.html";
}, 1200);
}
}
})
return false;
});
});
</script>
</body>
</html>

View File

@ -44,6 +44,7 @@ CREATE TABLE `oa_admin` (
`last_login_time` int(11) NOT NULL DEFAULT 0 COMMENT '最后登录时间',
`login_num` int(11) NOT NULL DEFAULT 0 COMMENT '登录次数',
`last_login_ip` varchar(64) NOT NULL DEFAULT '' COMMENT '最后登录IP',
`is_lock` int(1) NOT NULL DEFAULT 0 COMMENT '是否锁屏:1是0否',
`status` int(1) NOT NULL DEFAULT 1 COMMENT '状态:-1删除,0禁止登录,1正常,2离职',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `id`(`id`) USING BTREE

View File

@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="100%" height="100%" viewBox="0 0 1400 800">
<rect x="1300" y="400" rx="40" ry="40" width="300" height="300" stroke="rgb(129, 201, 149)" fill="rgb(129, 201, 149)">
<animateTransform attributeType="XML" attributeName="transform" begin="0s" dur="35s" type="rotate" from="0 1450 550" to="360 1450 550" repeatCount="indefinite"/>
</rect>
<path d="M 100 350 A 150 150 0 1 1 400 350 Q400 370 380 370 L 250 370 L 120 370 Q100 370 100 350" stroke="rgb(253, 214, 99)" fill="rgb(253, 214, 99)">
<animateMotion path="M 800 -200 L 800 -300 L 800 -200" dur="20s" begin="0s" repeatCount="indefinite"/>
<animateTransform attributeType="XML" attributeName="transform" begin="0s" dur="30s" type="rotate" values="0 210 530 ; -30 210 530 ; 0 210 530" keyTimes="0 ; 0.5 ; 1" repeatCount="indefinite"/>
</path>
<circle cx="200" cy="150" r="30" stroke="#1a73e8" fill="#1a73e8">
<animateMotion path="M 0 0 L 40 20 Z" dur="5s" repeatCount="indefinite"/>
</circle>
<!-- 三角形 -->
<path d="M 165 580 L 270 580 Q275 578 270 570 L 223 483 Q220 480 217 483 L 165 570 Q160 578 165 580" stroke="rgb(238, 103, 92)" fill="rgb(238, 103, 92)">
<animateTransform attributeType="XML" attributeName="transform" begin="0s" dur="35s" type="rotate" from="0 210 530" to="360 210 530" repeatCount="indefinite"/>
</path>
<rect x="400" y="600" rx="40" ry="40" width="100" height="100" stroke="rgb(129, 201, 149)" fill="rgb(129, 201, 149)">
<animateTransform attributeType="XML" attributeName="transform" begin="0s" dur="35s" type="rotate" from="-30 550 750" to="330 550 750" repeatCount="indefinite"/>
</rect>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB