|
function login2load(){
$('#loginButton').attr("disabled",true);
var dataCenter = new $.NUI_DataCenter();
var login_username= $('#login_username').val();
var login_password= $('#login_password').val();
// if (login_password == defPwd) {
// alert("当前密码为初始密码,请修改密码");
//// window.location = cpadGlobal.WEB_APP_NAME + "/changePwd.html";
// return;
// }
$('#login_password').val("");
dataCenter.putParameter("userName",login_username);
//dataCenter.putParameter("userPassword",login_password);
dataCenter.putParameter("userPassword",CryptoJS.HmacSHA256(login_password, "123456").toString(CryptoJS.enc.Hex));
var parm=JSON.stringify(dataCenter);
$.ajax({
type: "post",
url: "http://"+window.location.host+cpadGlobal.WEB_APP_NAME+"/login",
processData: false,
data: parm,
contentType:"application/x-www-form-urlencoded; charset=utf-8",
error:function(dc, textStatus, errorThrown){
alert(dc.responseJSON.header.message.detail);
},
success: function(dc){
if (dc.header.code == 0) {
// alert(dc.header.message.detail);
document.getElementById("msg").innerHTML = dc.header.message.detail;
return ;
} else {
document.getElementById("msg").innerHTML = "";
}
$.set_global("token",dc.body.parameters.AccessToken.token);
$.set_global("user",dc.body.parameters.AccessToken.account);
$.set_global("sysdate",dc.body.parameters.SYSDATE);
$.set_global("AccInfo",dc.body.parameters.AccInfo);
var saveConfig = {"option":dc.body.parameters.userCompAuthority.aar099, "flag":dc.body.parameters.userCompAuthority.aar098};
$.set_global("saveConfig",saveConfig);
var rootmenu= $.extend(new $.NUI_DataStore(), dc.body.dataStores.rootMenu);
var submenu= $.extend(new $.NUI_DataStore(), dc.body.dataStores.subMenu);
if(rootmenu.getRowCount()>0){
rootMenuStore=rootmenu.getRows();
basestore=submenu.getRows();
$.each(basestore,function(k,v){
v.id=v.ID;
v.label=v.LABEL;
v.rootId=v.ROOTID;
v.parentId=v.PARENTID;
v.location=v.LOCATION?cpadGlobal.WEB_APP_NAME+v.LOCATION:v.LOCATION;
});
$.set_global("basestore",basestore);
$.set_global("rootMenuStore",rootMenuStore);
(function initStatePathMapping(source){
var securityAjax = function(config){
var microTime = new Date().getTime(),
digest = function (url, method, params, data, microTime) {
var content = method + ':' + url + ':' + data + ':' + microTime,
digest = CryptoJS.HmacSHA256(content, $.get_global("token")).toString(CryptoJS.enc.Hex);
return digest;
},
headers = {};
headers['X-USER'] = $.get_global("user");
headers['X-MICRO-TIME'] = microTime;
headers['X-HMAC-HASH'] = digest(config["url"], config["type"]||"get", null, config["data"]||"", microTime);
config["headers"] = config["headers"] || {};
angular.extend(config["headers"], headers);
var result = $.ajax(config);
return result.responseText;
},
StatePathMapping = {},
extraPageJsonStr = securityAjax({url:cpadGlobal.WEB_APP_NAME+"/public/mainApp/privatePage.json", async:false});
extraPageJsonObj = angular.fromJson(extraPageJsonStr);
angular.forEach(extraPageJsonObj, function(config){
config.location = cpadGlobal.WEB_APP_NAME + config.location;
});
basestore.push.apply(basestore, extraPageJsonObj);
if(source){
for( var i=0,loopCounter=source.length; i<loopCounter; i++ ) {
var href = source[i]["location"];
href = href && href.substring(href.indexOf(cpadGlobal.WEB_APP_NAME,0)+cpadGlobal.WEB_APP_NAME.length+1, href.length);
StatePathMapping[source[i]["id"]] = {};
StatePathMapping[source[i]["id"]]["templateUrl"] = href;
}
angular.module('NUI_MainFrameWork').config([ '$stateProvider', function($stateProvider) {
$stateProvider.state('myapp',{
url : '',
views : StatePathMapping
});
} ]);
}
})(basestore);
if($('body').injector()){
}else{
angular.bootstrap($('body'),["NUI_MainFrameWork"]);
}
createRootMenuList();
$("#layLogin").fadeOut("slow");
$("#layUpdatePwd").fadeOut("slow");
//initStatePathMapping(basestore);
// var rows=menu.getRows();
// $.each(rows,function(){
//
// });
$("#loginUsrInfo").text("当前用户:"+dc.body.parameters.AccInfo.usrname);
if(saveConfig.option || saveConfig.flag)
alert("目前尚未开通保存功能权限,请联系省办开通。");
}
else {
alert("该用户授权菜单为空");
}
$('#loginButton').removeAttr("disabled");
}
});
};
|
|