|
|
|
|
/**
|
|
|
|
|
* Created by ljx on 2019/4/25.
|
|
|
|
|
*/
|
|
|
|
|
$(function () {
|
|
|
|
|
//cookie数据保存格式是key=value;key=value;形式,loginInfo为保存在cookie中的key值,具体看controller代码
|
|
|
|
|
/*if(str != ""){
|
|
|
|
|
var userName = str.split("#")[0];
|
|
|
|
|
var userPwd = str.split("#")[1];
|
|
|
|
|
//自动填充用户名和密码
|
|
|
|
|
$("#userName").val(userName);
|
|
|
|
|
$("#userPwd").val(userPwd);
|
|
|
|
|
//并且选中复选框
|
|
|
|
|
$("#rememberMe").attr("checked", true);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
//获取cookie
|
|
|
|
|
/*function getCookie(cname) {
|
|
|
|
|
var name = cname + "=";
|
|
|
|
|
var ca = document.cookie.split(';');
|
|
|
|
|
for(var i=0; i<ca.length; i++) {
|
|
|
|
|
var c = ca[i];
|
|
|
|
|
while (c.charAt(0)==' ') c = c.substring(1);
|
|
|
|
|
if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
$("#forgetPwd").on("click", function () {
|
|
|
|
|
alert("请联系管理员进行修改密码!");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function login() {
|
|
|
|
|
var userName = $("#userName").val();
|
|
|
|
|
var userPwd = $("#userPwd").val();
|
|
|
|
|
userPwd = hex_hmac_md5(userPwd, userPwd);
|
|
|
|
|
var rememberMeChecked = $("input[type='checkbox']").is(':checked');
|
|
|
|
|
var rememberMe = '';
|
|
|
|
|
if (rememberMeChecked) {
|
|
|
|
|
rememberMe = 'yes';
|
|
|
|
|
}
|
|
|
|
|
if (userName == '') {
|
|
|
|
|
toastr.warning("用户名不能为空!");
|
|
|
|
|
} else {
|
|
|
|
|
if (userPwd == '') {
|
|
|
|
|
toastr.warning("密码不能为空!");
|
|
|
|
|
} else {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
url: path + "/login",
|
|
|
|
|
data: {userName: userName, userPwd: userPwd, rememberMe: rememberMe},
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (data) {
|
|
|
|
|
if (data.code == 100) {
|
|
|
|
|
window.location.href = data.extend.url;
|
|
|
|
|
} else {
|
|
|
|
|
alert(data.msg)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var interval = "";
|
|
|
|
|
var qrCodeIdentity = "";
|
|
|
|
|
|
|
|
|
|
//获取扫码登录二维码
|
|
|
|
|
function handoffLogin() {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: {loginTypeBitValue: 16, type: 3, projectUid: "cloudkey-fstth", ApplicationId: "fstth-wzh"},
|
|
|
|
|
url: path + '/font/getQRcode',
|
|
|
|
|
success: function (data) {
|
|
|
|
|
qrCodeIdentity = data.qrCodeIdentity;
|
|
|
|
|
$("#QRcordImg").prop("src", "data:image/jpeg;base64," + data.qrCodeBase64);
|
|
|
|
|
//轮询监听用户扫码
|
|
|
|
|
interval = setInterval(scanCodeLogin, 1000, qrCodeIdentity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
$("#switchHandoff").css("display", "none");
|
|
|
|
|
$("#switchHandoff2").css("display", "block");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function scanCodeLogin() {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: {qrCodeIdentity: qrCodeIdentity},
|
|
|
|
|
url: path + '/font/getScanCode',
|
|
|
|
|
success: function (body) {
|
|
|
|
|
if (body.verifyStatus == 0) {
|
|
|
|
|
//扫码认证成功后撤销监听
|
|
|
|
|
clearInterval(interval);
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: {userToken: body.userToken},
|
|
|
|
|
url: path + '/font/getUserInfo',
|
|
|
|
|
success: function (tlte) {
|
|
|
|
|
if (tlte.msgType == 1) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: {userName: tlte.uid},
|
|
|
|
|
url: path + '/font/qRCodeLogin',
|
|
|
|
|
success: function (tltel) {
|
|
|
|
|
if (tltel.code == 100) {
|
|
|
|
|
|
|
|
|
|
window.location.href = tltel.extend.url;
|
|
|
|
|
} else {
|
|
|
|
|
$("#msg").text(tltel.msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
alert("登录失败请重新登录")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handoffLogin2() {
|
|
|
|
|
|
|
|
|
|
$("#switchHandoff").css("display", "block");
|
|
|
|
|
$("#switchHandoff2").css("display", "none");
|
|
|
|
|
clearInterval(interval);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('body').keydown(function () {
|
|
|
|
|
if (event.keyCode == '13') {
|
|
|
|
|
login();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
/**
|
|
|
|
|
* 判断是iframe框架跳出iframe框架使用top链接
|
|
|
|
|
*/
|
|
|
|
|
if (top.location != location) {
|
|
|
|
|
top.location.href = location.href;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|