var isonescore='';
|
var hostUrl='';
|
var SessionKey='data_base_id';
|
var oauth2HostName='';
|
var loginSelectArr;//登录时账号多个角色时候存放集合
|
// var logov='';
|
var rsakey={
|
pubkey:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkRupiYcKVGGUtDBDoR1t/1zm3ZtZgnte39iTJW6hlqjdY0UagKjpNiIv7J6XjtgfX7SgsR4AWnivqQHAICIvdPKfGZZzIs62OQ19MqrDTMoB/LvK5teNWhClv23WMUfRbP+EHgprT6hTw8U5apw1IB6i/y57NkLav792wiYBYRU4X45NoTaT+aiTSLFEflbfm94EXnhSS3vFkBmrZGy5BRNI8gmzafroslGx2Hk90CqlNdeKYxgZQ6xtvj+u33yrszWvPT6F9fsJT8aMjtvH050iYKRVct+x6Q7VRJgCI4MgvAexnTKdxW54YzvXCuO5bDiy5la7CgerWkTAq9dzXwIDAQAB"
|
};
|
(function($) {
|
$.Read=function(){
|
var _this=this;
|
var select;
|
var browserName = myexplorer();
|
if (browserName && browserName != "" && browserName != "谷歌") {
|
$(".tips").show();
|
alert("您正在使用 " + browserName +" 浏览器,强烈推荐您使用【谷歌】浏览器登录系统!");
|
}else {
|
$(".tips").hide();
|
}
|
|
if(window.parent.length>0){
|
window.parent.location=hostUrl+'/login.jsp';
|
}
|
|
if($("#snDiv").is(":visible")){
|
$("#cltsn").focus();
|
} else{
|
$("#name").focus();
|
}
|
|
//系统下拉选择
|
this.setDate=function(event){
|
if(event.selectedIndex!=-1){
|
var text=event.options[event.selectedIndex].text;
|
var version = $(event.options[event.selectedIndex]).attr("version");
|
$.post('/getDateDemo.do',{'id':event.value,"dataBaseDis":text,"version":version},function(data){
|
if(data!=null&&$.trim(data)!=""){
|
if(data.indexOf("<html>")!=-1){
|
location = "/home.jsp";
|
return;
|
}
|
alert(data);
|
}
|
});
|
//设置有LOGO加载
|
$('.login_logo img').attr('src','/getLogoIcon.do?dbid='+event.value);
|
}
|
select=event;
|
}
|
|
this.reloadCode=function(i,event) {
|
if(null!=event){
|
event.src="/imageCode?rand="+i;
|
}
|
}
|
|
this.initValue=function(){
|
if(select.selectedIndex!=-1){
|
var text=select.options[select.selectedIndex].text;
|
$("#dataBaseDis").val(text);
|
return;
|
}
|
}
|
|
this.disableButton=function(){
|
$("#sub").attr("disabled",true);
|
$("#sub").css("background-color","#bec4c8");
|
}
|
|
$("#sub").click(function(){
|
_this.disableButton();
|
var flg=false;
|
var isAccount=$($(".nav_tab")[0]).hasClass("active");//是否是账号登录,flse表示短信登录
|
if($("#snDiv").is(":visible") && isAccount){
|
if($("#cltsn").val()==""){
|
$(".cltsn").find("span").html("请输入通行证");
|
$("#cltsn").addClass("errorinput");
|
}
|
flg=true;
|
}
|
if($("#name").val()=="" && isAccount){
|
$(".name").find("span").html("请输入账号 / 手机号");
|
$("#name").addClass("errorinput");
|
flg=true;
|
}
|
if($("#pwd").val()=="" && isAccount){
|
$(".pwd").find("span").html("请输入密码");
|
$("#pwd").addClass("errorinput");
|
flg=true;
|
}
|
if($("#code").val()=="" && isAccount){
|
$(".code").find("span").html("请输入验证码");
|
$("#code").addClass("errorinput");
|
flg=true;
|
}
|
//短信登录验证
|
if($("#telephone").val()=="" && !isAccount){
|
$(".telephone").find("span").html("请输入手机号码");
|
$("#telephone").addClass("errorinput");
|
flg=true;
|
}
|
if($("#phoneCode").val()=="" && !isAccount){
|
$(".phoneCode").find("span").html("请输入手机验证码");
|
$("#phoneCode").addClass("errorinput");
|
flg=true;
|
}
|
|
if(flg){
|
removeDisableButton();
|
return false;
|
}
|
|
if(!flg && ""==select.value && isonescore==""){
|
$(".login_select").find("span").html("请选择一个系统");
|
if(!$(".select").hasClass('l_select')){
|
$(".select").addClass('l_select');
|
}
|
$(".login_select").show()
|
removeDisableButton();
|
return false;
|
}
|
if($("#name").val()!=""&&$("#pwd").val()!=""&&$("#code").val()!=""){
|
_this.initValue();
|
if(typeof(isonescore)!="undefined"&&isonescore!=""){
|
$("#isone").val(isonescore);
|
}
|
var encrypt = new JSEncrypt();
|
encrypt.setPublicKey(rsakey.pubkey);
|
var encryptPwd = encrypt.encrypt($("#pwd").val());
|
var encryptUser = encrypt.encrypt($("#name").val());
|
//登录请求
|
loginRequest(encryptUser,encryptPwd,select.value);
|
}else if($("#telephone").val()!="" && $("#phoneCode").val()!=""){
|
//短信登录
|
loginRequest("","",select.value);
|
}
|
});
|
|
$("#name").keydown(function(e){
|
var e=e||window.event;
|
if(e.keyCode==13){//回车键
|
$("#pwd").focus();
|
}
|
});
|
|
$("#pwd").keydown(function(e){
|
var e=e||window.event;
|
if(e.keyCode==13){//回车键
|
if(document.getElementById("code")){
|
$("#code").focus();
|
return;
|
}
|
$("#sub").click();
|
}
|
});
|
|
$("#code").keydown(function(e){
|
var e=e||window.event;
|
if(e.keyCode==13){//回车键
|
$("#sub").click();
|
}
|
});
|
|
$("#reset").click(function(){
|
$("#name").val("");
|
$("#pwd").val("");
|
$("#code").val("");
|
$("#name").focus();
|
|
});
|
// $("#ppwd").keyup(function() {
|
// $("#pwd").val(hex_md5($("#ppwd").attr("value")));
|
|
// });
|
|
// $(".sub_button").click(function(){
|
// _this.initValue();
|
// });
|
|
$("#randomming").click(function(){
|
_this.reloadCode(Math.random(),this);
|
});
|
|
$(".pop-sns-weixin-m").on("touchstart",function () {
|
$(".icon-weixin-m").addClass("weixin-hover");
|
});
|
$(".pop-sns-qq-m").on("touchstart",function () {
|
$(".icon-qq-m").addClass("qq-hover");
|
});
|
$(".pop-sns-weixin-m").on("touchend",function () {
|
$(".icon-weixin-m").removeClass("weixin-hover");
|
});
|
$(".pop-sns-qq-m").on("touchend",function () {
|
$(".icon-qq-m").removeClass("qq-hover");
|
});
|
|
$("#dataName").change(function(){
|
_this.setDate(this);
|
});
|
|
$("#dataName").click(function(){
|
_this.setDate(this);
|
});
|
$("#dataName").triggerHandler('click');
|
$("#randomming").triggerHandler('click');
|
|
$(".pop-sns-weixin").click(function () {
|
if(select.selectedIndex==-1){
|
alert("必须选择一个账套");
|
return ;
|
}
|
try{
|
layer.open({
|
title:'微信二维码',
|
type: 1,
|
resize :false,
|
maxWidth:500,
|
content:'<div style="text-align:center;">'+
|
'<iframe src="'+oauth2HostName+'/oauth2/weixin.do?'+SessionKey + '=' + select.value + '&orghost='
|
+ hostUrl+'&SelfRedirect=false" style="width:400px;height:400px;border:1px solid #CCC;"></iframe></div>',
|
end :function(){//关闭二维码层,执行刷新当前页面
|
location.reload();
|
}
|
});
|
}catch(e){
|
|
}
|
//location = oauth2HostName+"/oauth2/weixin.do?"+SessionKey+"="+select.value+"&orghost="+hostUrl;
|
});
|
|
$(".pop-sns-qq").click(function () {
|
if(select.selectedIndex==-1){
|
alert("必须选择一个账套");
|
return ;
|
}
|
location.href=oauth2HostName+'/oauth2/qq.do?'+SessionKey + '=' + select.value + '&orghost='+ hostUrl+'&SelfRedirect=false';
|
// try{
|
// layer.open({
|
// title:'QQ二维码',
|
// type: 1,
|
// resize :false,
|
// maxWidth:500,
|
// content:'<div style="text-align:center;">'+
|
// '<iframe src="'+oauth2HostName+'/oauth2/qq.do?'+SessionKey + '=' + select.value + '&orghost='
|
// + hostUrl+'&SelfRedirect=false" style="width:550px;height:400px;border:1px solid #CCC;"></iframe></div>',
|
// end :function(){//关闭二维码层,执行刷新当前页面
|
// location.reload();
|
// }
|
// });
|
// }catch(e){
|
//
|
// }
|
//location =oauth2HostName+"/oauth2/qq.do?"+SessionKey+"="+select.value+"&orghost="+hostUrl;
|
});
|
|
//maintaince.dbid=select.value;
|
// maintaince.isStop='false';
|
//setInterval(maintaince.checkSysIsExpired, 10000);//10秒调用一次
|
//checkSysIsExpired('<%=dbId%>','false'); //检查系统是否停止使用 Added by Johns Wang ,2017-05-26
|
|
|
// 登录方式切换
|
$(".nav_tab").on("click", function () {
|
if(!$(this).hasClass('active')){
|
$(".nav_tab").removeClass("active");
|
$(this).addClass("active");
|
$(".login_form").hide();
|
$(".login_form").eq($(".nav_tab").index(this)).show();
|
if($(".nav_tab").index(this)==1){
|
$("#name").val("");
|
$("#pwd").val("");
|
}
|
}
|
});
|
//二维码切换
|
$(".qrcode_login").on("click", function () {
|
if(!$(this).hasClass("active")){
|
$(this).addClass("active");
|
$('.login-password').hide();
|
$('.qrcode-logins').show();
|
//获取二维码
|
_this.createqrCode();
|
}else{
|
if(webSocket!=null){
|
$(this).removeClass("active");
|
$('.login-password').show();
|
$('.qrcode-logins').hide();
|
webSocketClose();//关闭链接
|
webSocket=null;
|
}
|
}
|
});
|
// 获取验证码按钮
|
var countTime = 60; //倒计时时间
|
var isCount = false; // 是否倒计时中
|
// 获取验证码按钮点击事件
|
$(".get_phoneCode").click(function () {
|
var phone=$("#telephone").val();
|
if(!(/^1[3456789]\d{9}$/.test(phone))){
|
$(".telephone").find("span").html("请输入正确的手机号码");
|
$("#telephone").addClass("errorinput");
|
return;
|
}
|
if (isCount) {
|
return;
|
}
|
$(".get_phoneCode").addClass('is-disabled');
|
// 获取验证码
|
$.post('/ws/phoneCode.do',{'dbId':select.value,'telephone':phone,'type':1},function(r){
|
if(r!=null){
|
if(r.code && r.code==-1){
|
layer.msg(r.info);
|
return;
|
}
|
isCount = true;
|
countDown();
|
function countDown() {
|
setTimeout(function () {
|
countTime--;
|
$(".get_phoneCode").text(countTime+'秒后再获取')
|
if (countTime>0){
|
countDown()
|
} else {
|
isCount = false;
|
countTime = 60;
|
$(".get_phoneCode").text('获取验证码').removeClass('is-disabled')
|
}
|
}, 1000)
|
}
|
}
|
});
|
});
|
|
//二维码过期刷新
|
$('.qrcode-error a').on('click',function(){
|
//获取二维码
|
_this.createqrCode();
|
});
|
|
//生成二维码图片
|
this.createqrCode=function(){
|
$(".qrcode-error").hide();
|
$.post("/ws/qrCode.do?appId="+select.value,function(res){
|
if(res!=null && res.code==0){
|
$(".qrcode-logins").find("img").attr("src",res.data.url);
|
initWebSocket(hostUrl+"/ws/qrLogin/"+select.value+"/"+res.data.qrcode+"/0",res.data.qrcode);
|
}else{
|
alert(res.msg);
|
webSocket=-1;
|
}
|
},"json").error(function(e){
|
webSocket=-1;
|
alert(e.responseText);
|
$(".qrcode-logins").find("img").attr("src","");
|
});
|
}
|
}
|
})(jQuery);
|
//登录请求
|
function loginRequest(encryptUser,encryptPwd,dataName){
|
$.ajax({
|
type:"POST",
|
url: $("#hostUrl").val()+"/login.do",
|
//contentType: "application/json", //如果提交的是json数据类型,则必须有此参数,表示提交的数据类型
|
dataType: "json", //表示返回值类型,不必须
|
data:{
|
"account":encryptUser,
|
'pwd': encryptPwd,
|
'code': $("#code").val(),
|
'redirect': $("#redirect").val(),
|
'cltsn': $("#cltsn").val(),
|
"dataName":dataName,
|
"isone":$("#isone").val(),
|
"telephone":$("#telephone").val(),
|
"phoneCode":$("#phoneCode").val()
|
},
|
success: function (jsonResult) {
|
if(jsonResult!=undefined &&jsonResult!=null){
|
if (jsonResult.state == -1009) {//存在多个角色的账号
|
loginSelectArr=jsonResult.data;
|
layer.open({
|
title:'请选择登录身份',
|
type: 2,
|
closeBtn:0,
|
offset:'60px',//只定义top坐标,水平保持居中
|
area: ['500px', '600px'],
|
content: '/general/loginSelect/loginSelect.html'
|
});
|
return false;
|
}
|
var redirect="";
|
if(jsonResult.data!=undefined &&jsonResult.data!=""){
|
var json=JSON.parse(jsonResult.data);
|
redirect=json.redirect;
|
|
}
|
if(jsonResult.state==-1){//出错
|
removeDisableButton();
|
alert(jsonResult.msg);
|
}else{
|
var url=$("#hostUrl").val()+"/home.jsp";
|
if(redirect!=""){
|
url+="?redirect="+redirect;
|
}
|
window.location.replace(url);
|
}
|
}
|
},
|
error: function (data){
|
removeDisableButton();
|
let msg = data.responseText || "登录请求失败!";//显示错误信息 xin 2022-8-19 17:36:38
|
alert(msg);
|
}
|
});
|
}
|
|
function removeDisableButton(){
|
$("#sub").attr("disabled",false);
|
$("#sub").css("background-color","#116eab");
|
}
|
function loginRefresh(){
|
layer.closeAll();
|
window.location.href= hostUrl + "/home.jsp";
|
}
|
|
$(function(){
|
hostUrl=$('#hostUrl').val();
|
isonescore=$('#isonescore').val();
|
SessionKey=$('#SessionKey').val();
|
oauth2HostName=$('#oauth2HostName').val();
|
// logov=$('#logov').val();
|
$.Read();
|
});
|