$(function() {
// header处理
$(".span0").text("");
$(".span5").css({"display": "inline"});
// 添加验证码刷新事件
$("#verifycodeImg").click(function(){
$(this).attr("src", "validation_generatorCode.action?" + new Date());
});
// 添加注册按钮事件
$("#login_regist_btn").click(function(){
window.location.href = 'regist.action';
});
var isAgentLogin = false;
// 添加登录按钮事件
$("#login_sign_btn").click(function(){
// FORM验证
var agentcode = $("#login_dialog_agent").val();
var username = $("input[name='j_username']").val();
var password = $("input[name='j_password']").val();
var verifycode = $("input[name='j_verifycode']").val();
if (isAgentLogin && agentcode == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.agentcode")
});
return;
}
if (username == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.username")
});
return;
}
if (password == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.password")
});
return;
}
if (verifycode == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.verifycode")
});
return;
}
//console.info(agentcode + "," + username + "," + password + "," + verifycode);
$.ajax({
url : 'j_spring_security_check',
type : 'post',
data : {
j_organization_code: agentcode,
j_username: username,
j_password: password,
j_verifycode: verifycode
},
success : function(data) {
var result = eval("(" + data + ")");
if (result.data.authentication) {
window.location.href = 'main.action';
} else {
if (result.data.msg == "ERROR_CODE_UM_0011") {
$("input[name='j_verifycode']").val("");
$("#verifycodeImg").attr("src", "validation_generatorCode.action?" + new Date());
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.verifycode.error")
});
} else if (result.data.msg == "ERROR_CODE_UM_0021" || result.data.msg == "ERROR_CODE_UM_0022") {
$("input[name='j_password']").val("");
$("input[name='j_verifycode']").val("");
$("#verifycodeImg").attr("src", "validation_generatorCode.action?" + new Date());
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.username.password.error")
});
}
}
}
});
});
// 加载机构类型信息
function loadAgentTypeInfo() {
$.SelectView.load({
id: ["login_dialog_agentType"],
url: "codetable_getCodeListValue.action",
data: {
codeType: "SYSTEM",
subCodeType: "AGENT_TYPE"
}
});
}
// 加载信息
loadAgentTypeInfo();
$("#login_dialog_agentType").change(function(){
var agentType = $(this).val();
$("#login_dialog_agent").empty();
if (agentType == "1") {
$("#login_agent_code_view").css({"display": "table-row"});
isAgentLogin = true;
//$("<option value='10000108'>Agent 01</option>").appendTo("#login_dialog_agent");
$("#login_dialog_agent").val("10001101");
} else if (agentType == "2") {
$("#login_agent_code_view").css({"display": "none"});
//$("<option value='10000301'>Operation Dept 01</option>").appendTo("#login_dialog_agent");
$("#login_dialog_agent").val("10001102");
isAgentLogin = false;
} else {
$("#login_agent_code_view").css({"display": "none"});
//$("<option value='10000301'>Operation Dept 01</option>").appendTo("#login_dialog_agent");
$("#login_dialog_agent").val("10001103");
isAgentLogin = false;
}
// $.SelectView.load({
// id: ["login_dialog_agent"],
// url: "agentInfo.list.byAgentType.action",
// data: {
// agentType: agentType
// },
// option:{value:"agentCode",name:"agentName"}
// });
});
});
//$("<option value='10000301'>Operation Dept 01</option>").appendTo("#login_dialog_agent");
// header处理
$(".span0").text("");
$(".span5").css({"display": "inline"});
// 添加验证码刷新事件
$("#verifycodeImg").click(function(){
$(this).attr("src", "validation_generatorCode.action?" + new Date());
});
// 添加注册按钮事件
$("#login_regist_btn").click(function(){
window.location.href = 'regist.action';
});
var isAgentLogin = false;
// 添加登录按钮事件
$("#login_sign_btn").click(function(){
// FORM验证
var agentcode = $("#login_dialog_agent").val();
var username = $("input[name='j_username']").val();
var password = $("input[name='j_password']").val();
var verifycode = $("input[name='j_verifycode']").val();
if (isAgentLogin && agentcode == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.agentcode")
});
return;
}
if (username == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.username")
});
return;
}
if (password == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.password")
});
return;
}
if (verifycode == '') {
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.verifycode")
});
return;
}
//console.info(agentcode + "," + username + "," + password + "," + verifycode);
$.ajax({
url : 'j_spring_security_check',
type : 'post',
data : {
j_organization_code: agentcode,
j_username: username,
j_password: password,
j_verifycode: verifycode
},
success : function(data) {
var result = eval("(" + data + ")");
if (result.data.authentication) {
window.location.href = 'main.action';
} else {
if (result.data.msg == "ERROR_CODE_UM_0011") {
$("input[name='j_verifycode']").val("");
$("#verifycodeImg").attr("src", "validation_generatorCode.action?" + new Date());
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.verifycode.error")
});
} else if (result.data.msg == "ERROR_CODE_UM_0021" || result.data.msg == "ERROR_CODE_UM_0022") {
$("input[name='j_password']").val("");
$("input[name='j_verifycode']").val("");
$("#verifycodeImg").attr("src", "validation_generatorCode.action?" + new Date());
$.MessageBox.open({
title: $.i18n.prop("ibts.common.error.title"),
message: $.i18n.prop("ibts.login.form.validate.username.password.error")
});
}
}
}
});
});
// 加载机构类型信息
function loadAgentTypeInfo() {
$.SelectView.load({
id: ["login_dialog_agentType"],
url: "codetable_getCodeListValue.action",
data: {
codeType: "SYSTEM",
subCodeType: "AGENT_TYPE"
}
});
}
// 加载信息
loadAgentTypeInfo();
$("#login_dialog_agentType").change(function(){
var agentType = $(this).val();
$("#login_dialog_agent").empty();
if (agentType == "1") {
$("#login_agent_code_view").css({"display": "table-row"});
isAgentLogin = true;
//$("<option value='10000108'>Agent 01</option>").appendTo("#login_dialog_agent");
$("#login_dialog_agent").val("10001101");
} else if (agentType == "2") {
$("#login_agent_code_view").css({"display": "none"});
//$("<option value='10000301'>Operation Dept 01</option>").appendTo("#login_dialog_agent");
$("#login_dialog_agent").val("10001102");
isAgentLogin = false;
} else {
$("#login_agent_code_view").css({"display": "none"});
//$("<option value='10000301'>Operation Dept 01</option>").appendTo("#login_dialog_agent");
$("#login_dialog_agent").val("10001103");
isAgentLogin = false;
}
// $.SelectView.load({
// id: ["login_dialog_agent"],
// url: "agentInfo.list.byAgentType.action",
// data: {
// agentType: agentType
// },
// option:{value:"agentCode",name:"agentName"}
// });
});
});
//$("<option value='10000301'>Operation Dept 01</option>").appendTo("#login_dialog_agent");