123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- sp.setCssSkin();////皮肤换色GlWorkPlatform-username
- var get_userid = $.cookie("GlWorkPlatform-userid"); //获取userid
- var get_username = $.cookie("GlWorkPlatform-username"); //获取中文名
- var get_chineseName = decodeURI($.cookie("GlWorkPlatform-chineseName")); //获取中文名
- var UserRole = "";
- if (get_userid == null || get_userid == "" || get_userid == "undefined") {
- window.location.href = "login.html";
- }
- //判断从哪里进来,只有从登录页进来才可以
- var get_sessionStorage = sessionStorage.getItem("GlWorkPlatform-LoginFrom");
- if (get_sessionStorage == null || get_sessionStorage == "" || get_sessionStorage == "undefined") {
- window.location.href = "login.html";
- } else {
- $("#spanAdminUserName").text(get_chineseName);
- }
- ////退出
- function btnLoginOut() {
- window.location.href = "login.html";
- $.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
- $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
- $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
- sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
- localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
- localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
- };
- ///判断是否是第一次进入这个系统,即是否为空库
- function checkIsEmptyDatabase() {
- $.ajax({
- type: "get",
- url: apiurljs.login + "connect/isemptydatabase",
- //data: { action: "fadetail", userid: userid, routeinfoid: routeinfoid },
- dataType: "json",
- ContentType: 'application/x-www-form-urlencoded',
- success: function (res) {
- //console.log(JSON.stringify(res.data));
- document.getElementsByTagName("title")[0].innerText = res.data.SYSNAME;
- $(".sp-wrapper-head-title span").html(res.data.SYSNAME);
- $.cookie("GlWorkPlatform-SYSNAME", res.data.SECTION, { path: '/', expires: 1 });
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log(errorThrown);
- }
- });
- };
- checkIsEmptyDatabase();
- ///////动态加载左侧菜单---重点
- function getAjaxLeftBar() {
- var get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- $.ajax({
- type: "post",
- url: apiurljs.login + "UserPower/Permissions",
- dataType: "json",
- ContentType: 'application/json',
- headers: { Authorization: "Bearer " + get_AccessToken }, ////请求头headers
- success: function (res) {
- // sp.dynamicLeftBar(JSON.stringify(res.data));
- //console.log(JSON.stringify(res));
- ////传提数据然后动态加载左侧菜单
- res.data.rows.unshift({
- "PKID": "FZ0",
- "CNAME": "工作桌面",
- "SORTID": "1",
- "FILEN": UserRole,
- "SRCIMG": "fa fa-home",
- "SRCIMG32": "fa fa-home",
- "OPENTYPE": "0",
- "C_H_I_L_D": [
- ]
- })
- sp.dynamicLeftMenu(JSON.stringify(res.data));
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log(errorThrown);
- window.location.href = "login.html";
- }
- });
- }
- //获取用户状态,判断工作桌面路径
- function getUserRole() {
- var get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- var test = { userid: get_userid }
- $.ajax({
- type: "post",
- url: apiurljs.login + "g2work/desktop/queryDesktopMark",
- dataType: "json",
- data: JSON.stringify(test),
- contentType: 'application/json',
- headers: { Authorization: "Bearer " + get_AccessToken }, ////请求头headers
- success: function (res) {
- if (res.success == true) {
- UserRole = res.data;
- }
- getAjaxLeftBar();
- },
- error: function (XMLHttpRequest, textStatus, errorThrown) {
- console.log(errorThrown);
- }
- });
- }
- getUserRole()
- /* 为保证页面显示效果,判断浏览器版本是否过低*/
- function checkIEVersion() {
- var getjson = sp.getExplorerInfo();
- if (getjson.type == "IE") {
- if (getjson.version == "8.0" || getjson.version == "7.0" || getjson.version == "6.0") {
- $("#checkIEVersionDiv").text("您当前使用的是" + getjson.type + "浏览器 版本:" + getjson.version + ",版本过低,请更新IE浏览器或使用其他浏览器");
- $("#checkIEVersionDiv").show();
- //然后跳到需要连接的下载网站
- //window.location.href="http://jiaoxueyun.com/download.jsp";
- }
- }
- }
- checkIEVersion();
|