公共参数,登录后本地缓存
This commit is contained in:
parent
f194075ffc
commit
9c2e22aa18
@ -61,7 +61,7 @@
|
|||||||
<a href="javascript:;" data-check-screen="full"><i class="fa fa-arrows-alt"></i></a>
|
<a href="javascript:;" data-check-screen="full"><i class="fa fa-arrows-alt"></i></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="layui-nav-item layuimini-setting">
|
<li class="layui-nav-item layuimini-setting">
|
||||||
<a href="javascript:;">admin</a>
|
<a href="javascript:;">@userName</a>
|
||||||
<dl class="layui-nav-child">
|
<dl class="layui-nav-child">
|
||||||
<dd>
|
<dd>
|
||||||
<a href="javascript:;" layuimini-content-href="page/user-setting.html" data-title="基本资料"
|
<a href="javascript:;" layuimini-content-href="page/user-setting.html" data-title="基本资料"
|
||||||
@ -163,7 +163,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('.login-out').on("click", function () {
|
$('.login-out').on("click", function () {
|
||||||
layer.msg('退出登录成功', function () {
|
layui.data('UserInfo', null);
|
||||||
|
layer.msg('退出登录成功', { time: 500 }, function () {
|
||||||
window.location = 'page/login.html';
|
window.location = 'page/login.html';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -173,6 +174,7 @@
|
|||||||
if (isLogin != 1) {
|
if (isLogin != 1) {
|
||||||
window.location = 'page/login.html';
|
window.location = 'page/login.html';
|
||||||
}
|
}
|
||||||
|
var userName = UserInfo.userName;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
10
Pages/js/PublicParameters/PublicParameters.js
Normal file
10
Pages/js/PublicParameters/PublicParameters.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//WebApi公关部分url
|
||||||
|
var apiUrl = 'http://localhost:21021';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//返回WebApiUrl公共部分
|
||||||
|
function GetWebApiUrl(s) {
|
||||||
|
return apiUrl;
|
||||||
|
}
|
@ -2,18 +2,18 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<title>ProManager</title>
|
<title>ProManager</title>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
<meta http-equiv="Access-Control-Allow-Origin" content="*" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="format-detection" content="telephone=no">
|
<meta name="format-detection" content="telephone=no" />
|
||||||
<link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
|
<link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all" />
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
|
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
|
||||||
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<style>
|
<style>
|
||||||
.main-body {
|
.main-body {
|
||||||
@ -135,7 +135,7 @@
|
|||||||
width: 74px;
|
width: 74px;
|
||||||
height: 74px;
|
height: 74px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
opacity: .1;
|
opacity: 0.1;
|
||||||
border-radius: 0 74px 0 0;
|
border-radius: 0 74px 0 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
@ -147,7 +147,7 @@
|
|||||||
width: 94px;
|
width: 94px;
|
||||||
height: 94px;
|
height: 94px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
opacity: .1;
|
opacity: 0.1;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: -16px;
|
right: -16px;
|
||||||
@ -241,7 +241,7 @@
|
|||||||
.login-main .login-bottom .login-btn {
|
.login-main .login-bottom .login-btn {
|
||||||
width: 288px;
|
width: 288px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
background-color: #1E9FFF;
|
background-color: #1e9fff;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
margin: 24px auto 0;
|
margin: 24px auto 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -283,7 +283,7 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width:428px) {
|
@media screen and (max-width: 428px) {
|
||||||
.login-main {
|
.login-main {
|
||||||
width: 360px !important;
|
width: 360px !important;
|
||||||
}
|
}
|
||||||
@ -316,80 +316,102 @@
|
|||||||
|
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<span class="icon icon-3"></span>
|
<span class="icon icon-3"></span>
|
||||||
<input type="password" name="password" lay-verify="required" placeholder="请输入密码" maxlength="20">
|
<input type="password" name="password" lay-verify="required" placeholder="请输入密码"
|
||||||
|
maxlength="20" />
|
||||||
<span class="bind-password icon icon-4"></span>
|
<span class="bind-password icon icon-4"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item" style="text-align:center; width:100%;height:100%;margin:0px;">
|
<div class="layui-form-item" style="text-align: center; width: 100%; height: 100%; margin: 0px">
|
||||||
<button class="login-btn" lay-submit="" lay-filter="login">立即登录</button>
|
<button class="login-btn" lay-submit="" lay-filter="login">
|
||||||
|
立即登录
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">© 矿洞科技工作室</div>
|
||||||
© 矿洞科技工作室
|
|
||||||
</div>
|
|
||||||
<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
|
<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
|
||||||
<script src="../js/md5/md5.js" charset="utf-8"></script>
|
<script src="../js/md5/md5.js" charset="utf-8"></script>
|
||||||
|
<script src="../js/PublicParameters/PublicParameters.js" charset="utf-8"></script>
|
||||||
<script>
|
<script>
|
||||||
layui.use(['form', 'jquery'], function () {
|
layui.use(["form", "jquery"], function () {
|
||||||
var $ = layui.jquery,
|
var $ = layui.jquery,
|
||||||
form = layui.form,
|
form = layui.form,
|
||||||
layer = layui.layer;
|
layer = layui.layer;
|
||||||
|
|
||||||
// 登录过期的时候,跳出ifram框架
|
// 登录过期的时候,跳出ifram框架
|
||||||
if (top.location != self.location) top.location = self.location;
|
//if (top.location != self.location) top.location = self.location;
|
||||||
|
|
||||||
$('.bind-password').on('click', function () {
|
$(".bind-password").on("click", function () {
|
||||||
if ($(this).hasClass('icon-5')) {
|
if ($(this).hasClass("icon-5")) {
|
||||||
$(this).removeClass('icon-5');
|
$(this).removeClass("icon-5");
|
||||||
$("input[name='password']").attr('type', 'password');
|
$("input[name='password']").attr("type", "password");
|
||||||
} else {
|
} else {
|
||||||
$(this).addClass('icon-5');
|
$(this).addClass("icon-5");
|
||||||
$("input[name='password']").attr('type', 'text');
|
$("input[name='password']").attr("type", "text");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 进行登录操作
|
// 进行登录操作
|
||||||
form.on('submit(login)', function (data) {
|
form.on("submit(login)", function (data) {
|
||||||
data = data.field;
|
data = data.field;
|
||||||
if (data.username == '') {
|
if (data.username == "") {
|
||||||
layer.msg('用户名不能为空');
|
layer.msg("用户名不能为空");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (data.password == '') {
|
if (data.password == "") {
|
||||||
layer.msg('密码不能为空');
|
layer.msg("密码不能为空");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var password=b64_md5(data.password);
|
var password = b64_md5(data.password);
|
||||||
var apiUrl = 'http://localhost:21021/api/services/app/UserInfo/GetLoginUser';
|
var apiUrl = GetWebApiUrl();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: apiUrl, //请求的url地址
|
url: apiUrl + "/api/services/app/UserInfo/GetLoginUser", //请求的url地址
|
||||||
dataType: "json", //返回格式为json
|
dataType: "json", //返回格式为json
|
||||||
//async: false,//请求是否异步,默认为异步,这也是ajax重要特性
|
//async: false,//请求是否异步,默认为异步,这也是ajax重要特性
|
||||||
data: { "Account": data.username, "PassWord": password }, //参数值
|
data: { Account: data.username, PassWord: password }, //参数值
|
||||||
type: "GET", //请求方式
|
type: "GET", //请求方式
|
||||||
success: function (req) {
|
success: function (req) {
|
||||||
//请求成功时处理
|
//请求成功时处理
|
||||||
alert(22)
|
var result = req.result;
|
||||||
|
var totalCount = result.totalCount;
|
||||||
|
if (totalCount > 1) {
|
||||||
|
layer.msg("存在多个重复账号,请联系管理员!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (totalCount == 0) {
|
||||||
|
layer.msg("账号或密码有误,请检查!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (totalCount == 1) {
|
||||||
|
//登陆成功,设置登录用户信息
|
||||||
|
var UserInfo = result.items[0];
|
||||||
|
layui.data('UserInfo', {
|
||||||
|
key: 'userid', value: UserInfo.id,
|
||||||
|
key: 'account', value: UserInfo.account,
|
||||||
|
key: 'userName', value: UserInfo.userName,
|
||||||
|
key: 'workNo', value: UserInfo.workNo,
|
||||||
|
key: 'sex', value: UserInfo.sex,
|
||||||
|
key: 'deptID', value: UserInfo.deptID,
|
||||||
|
key: 'deptName', value: UserInfo.deptName,
|
||||||
|
key: 'postID', value: UserInfo.postID,
|
||||||
|
key: 'postName', value: UserInfo.postName,
|
||||||
|
key: 'cellPhoneNum', value: UserInfo.cellPhoneNum,
|
||||||
|
key: 'powerLevel', value: UserInfo.powerLevel,
|
||||||
|
key: 'isAdmin', value: UserInfo.isAdmin,
|
||||||
|
key: 'isLogin', value: 1,
|
||||||
|
});
|
||||||
|
layer.msg('登录成功', { time: 500 }, function () {
|
||||||
|
window.location = '../index.html';
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function (xhr, textStatus, errorThrown) {
|
error: function () {
|
||||||
/*错误信息处理*/
|
/*错误信息处理*/
|
||||||
alert("进入error---");
|
layer.msg("登录失败,请重试!");
|
||||||
alert("状态码:" + xhr.status);
|
return false;
|
||||||
alert("状态:" + xhr.readyState);//当前状态,0-未初始化,1-正在载入,2-已经载入,3-数据进行交互,4-完成。
|
},
|
||||||
alert("错误信息:" + xhr.statusText);
|
|
||||||
alert("返回响应信息:" + xhr.responseText);//这里是详细的信息
|
|
||||||
alert("请求状态:" + textStatus); alert(errorThrown); alert("请求失败");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// layer.msg('登录成功', function () {
|
|
||||||
// window.location = '../index.html';
|
|
||||||
// });
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user