anxiao_web/login.html

190 lines
7.0 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>智慧防控管理平台</title>
<link rel="shortcut icon" href="pages/index/image/system.ico" />
<link rel="stylesheet" href="pages/login/login.css" type="text/css" />
<link rel="stylesheet" href="public/layui/css/layui.css">
</head>
<body style="overflow-y:hidden;">
<!-- 编辑弹框 开始-->
<div class="pop" id="pop" style="display: none;">
<div class="pop-top">
<span>编辑</span>
<img onclick="closePoP()" src="./pages/login/images/bondedArea/close.png">
</div>
<ul class="pop-main">
<li><span class="pop-label">标题:</span><input class="pop-text" id="bigTitle" type="text"></li>
<li>
<span class="pop-label">logo:</span>
<a class="uploadButton">上传logo</a><span class="tip">logo为小于1M的图片</span>
<input type="file" id="file" accept="image/*" onchange="getLogo(this)">
</li>
<li id="popShowImgLi">
<img id="popShowImg" style="height: 60px;" src="" alt="">
</li>
<li style="text-align: center;"><button class="pop-button" onclick="submit()">确认保存</button></li>
</ul>
</div>
<!-- 编辑弹框 结束 -->
<div class="page">
<div id="logodiv" style="display: none;">
<img id="logoImg" src="">
<span id="logoText"></span>
</div>
<div id="setButton" style="display: none;" class="set-div" onclick="set()"><img
src="./pages/login/images/bondedArea/set.png" style="margin-right: 5px;"><span>配置</span>
</div>
<div class="bg">
<div class="main">
<div class="login-div">
<ul>
<!--<li class="title1 setTitle"><span class="title1-span"></span></li>-->
<li class="title1"><span class="title1-span">智慧防控管理平台</span></li>
<li class="title2">
<img src="./pages/login/images/bondedArea/title-left.png">
<span class="title2-span">系统登录</span>
<img src="./pages/login/images/bondedArea/title-right.png">
</li>
</ul>
<ul class="login">
<li><input class="input input-text username" placeholder="用户名" name="user" autocomplete type="text" /></li>
<li><input class="input input-password password" id="pwd" placeholder="密码" name="pwd" autocomplete
type="text" />
<img id="eye" onclick="toggle()" src="./pages/login/images/bondedArea/close-eye.png">
</li>
<li class="yzm-li"><input class="input input-yzm" id="verCode" placeholder="验证码" autocomplete type="text" />
<div class="yzm-div">
<canvas id="canvas"></canvas>
</div>
</li>
<li class="login-li-checkbox">
<label><input type="checkbox" /><span class="checkbox-text" id="rememberPwd">记住密码</span></label>
<span class="error"></span>
</li>
<li class="login-li-button"><input class="button" type="button" value="登录" /></li>
</ul>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="public/layui/layui.all.js"></script>
<script src="public/js/jquery-3.4.1.min.js"></script>
<script src="public/js/md5.js?v=1.0"></script>
<script src="pages/login/login.js" type="module"></script>
<script>
//切换密码眼睛
function toggle() {
var img = document.getElementById('eye');
var pwd = document.getElementById('pwd');
var src = img.getAttribute('src')
if (src == './pages/login/images/bondedArea/close-eye.png') {
img.src = "./pages/login/images/bondedArea/open-eye.png";
pwd.type = 'text'
} else {
img.src = "./pages/login/images/bondedArea/close-eye.png";
pwd.type = 'password'
}
}
function bodyHeight() { // 给body屏幕高度
let windowHeight = document.documentElement.clientHeight
let bodyE = document.getElementsByTagName('body')[0]
bodyE.style.height = windowHeight + 'px'
}
window.onload = function () {
bodyHeight()
}
window.onresize = function () {
bodyHeight()
}
// 获取对象
var setButton = document.getElementById('setButton') // 设置按钮
var pop = document.getElementById('pop') // 弹框
var file = document.getElementById('file') // 上传文件
var bigTitle = document.getElementById('bigTitle')// 标题输入框
var logoText = document.getElementById('logoText') // logo的文字
var logoImg = document.getElementById('logoImg') // logo的图片
var logodiv = document.getElementById('logodiv') // logo 图片连文字那一块
var popShowImg = document.getElementById('popShowImg') // 弹框内显示的图片
var popShowImgLi = document.getElementById('popShowImgLi')
var obj = {} // 用来保存本地的对象
function getLogo(e) { // 得到上传的logo
let size = e.files[0].size
let maxsize = 1024 * 1024 * 1 // 限制为1M
if (size > maxsize) {
alert('请确保图片小于1M')
file.value = ''
}
else {
// 解析成base64格式
var reader = new FileReader()
reader.readAsDataURL(e.files[0])
reader.onload = function () {
obj.img = this.result
popShowImg.setAttribute('src', this.result)
popShowImgLi.setAttribute('style', 'display:block') // 显示出来
}
}
}
function submit() { // 点击提交
obj.text = bigTitle.value
let objString = JSON.stringify(obj) // 对象转字符串
localStorage.setItem("logo", objString)
getStorage()
pop.setAttribute('style', 'display:none') // 关闭弹框
bigTitle.value = '' // 输入框清空
file.value = '' // 清空输入框
}
function set() { // 打开弹框
pop.setAttribute('style', 'display:block')
popShowImgLi.setAttribute('style', 'display:none')
let storageObj = JSON.parse(localStorage.getItem("logo"))
bigTitle.value=storageObj.text;
}
function geturlparam() { // 获取判断url
// window.location.href 获取地址
let url = window.location.href
let p = url.split('?')[1]
let params = new URLSearchParams(p)
if (params.get('logo') == 'true') { // 配置按钮显示
setButton.setAttribute('style', 'display:block')
logodiv.setAttribute('style', 'display:flex')
}
}
function closePoP() { // 关闭弹框
pop.setAttribute('style', 'display:none')
}
geturlparam()
getStorage()
function getStorage() {
// 读取本地logo数据
if (localStorage.getItem("logo")) {
let storageObj = JSON.parse(localStorage.getItem("logo"))
logoText.innerText = storageObj.text// 改变文字
if (!!storageObj.img) { // 有图片哒
logoImg.setAttribute('src', storageObj.img)// 改变logo
logoImg.setAttribute('style', 'display:block')
} else { // 没有图片的
logoImg.setAttribute('style', 'display:none')
}
}
}
</script>
</body>
</html>