indexTwo.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. sp.setCssSkin();////皮肤换色GlWorkPlatform-username
  2. var get_userid = $.cookie("GlWorkPlatform-userid"); //获取userid
  3. var get_username = $.cookie("GlWorkPlatform-username"); //获取中文名
  4. var get_chineseName = decodeURI($.cookie("GlWorkPlatform-chineseName")); //获取中文名
  5. var UserRole = "";
  6. if (get_userid == null || get_userid == "" || get_userid == "undefined") {
  7. window.location.href = "login.html";
  8. }
  9. //判断从哪里进来,只有从登录页进来才可以
  10. var get_sessionStorage = sessionStorage.getItem("GlWorkPlatform-LoginFrom");
  11. if (get_sessionStorage == null || get_sessionStorage == "" || get_sessionStorage == "undefined") {
  12. window.location.href = "login.html";
  13. } else {
  14. $("#spanAdminUserName").text(get_chineseName);
  15. }
  16. ////退出
  17. function btnLoginOut() {
  18. window.location.href = "login.html";
  19. $.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
  20. $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
  21. $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
  22. sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
  23. localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
  24. localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  25. };
  26. ///判断是否是第一次进入这个系统,即是否为空库
  27. function checkIsEmptyDatabase() {
  28. $.ajax({
  29. type: "get",
  30. url: apiurljs.login + "connect/isemptydatabase",
  31. //data: { action: "fadetail", userid: userid, routeinfoid: routeinfoid },
  32. dataType: "json",
  33. ContentType: 'application/x-www-form-urlencoded',
  34. success: function (res) {
  35. //console.log(JSON.stringify(res.data));
  36. document.getElementsByTagName("title")[0].innerText = res.data.SYSNAME;
  37. $(".sp-wrapper-head-title span").html(res.data.SYSNAME);
  38. $.cookie("GlWorkPlatform-SYSNAME", res.data.SECTION, { path: '/', expires: 1 });
  39. },
  40. error: function (XMLHttpRequest, textStatus, errorThrown) {
  41. console.log(errorThrown);
  42. }
  43. });
  44. };
  45. checkIsEmptyDatabase();
  46. ///////动态加载左侧菜单---重点
  47. function getAjaxLeftBar() {
  48. var get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  49. $.ajax({
  50. type: "post",
  51. url: apiurljs.login + "UserPower/Permissions",
  52. dataType: "json",
  53. ContentType: 'application/json',
  54. headers: { Authorization: "Bearer " + get_AccessToken }, ////请求头headers
  55. success: function (res) {
  56. // sp.dynamicLeftBar(JSON.stringify(res.data));
  57. //console.log(JSON.stringify(res));
  58. ////传提数据然后动态加载左侧菜单
  59. res.data.rows.unshift({
  60. "PKID": "FZ0",
  61. "CNAME": "工作桌面",
  62. "SORTID": "1",
  63. "FILEN": UserRole,
  64. "SRCIMG": "fa fa-home",
  65. "SRCIMG32": "fa fa-home",
  66. "OPENTYPE": "0",
  67. "C_H_I_L_D": [
  68. ]
  69. })
  70. sp.dynamicLeftMenu(JSON.stringify(res.data));
  71. },
  72. error: function (XMLHttpRequest, textStatus, errorThrown) {
  73. console.log(errorThrown);
  74. window.location.href = "login.html";
  75. }
  76. });
  77. }
  78. //获取用户状态,判断工作桌面路径
  79. function getUserRole() {
  80. var get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  81. var test = { userid: get_userid }
  82. $.ajax({
  83. type: "post",
  84. url: apiurljs.login + "g2work/desktop/queryDesktopMark",
  85. dataType: "json",
  86. data: JSON.stringify(test),
  87. contentType: 'application/json',
  88. headers: { Authorization: "Bearer " + get_AccessToken }, ////请求头headers
  89. success: function (res) {
  90. if (res.success == true) {
  91. UserRole = res.data;
  92. }
  93. getAjaxLeftBar();
  94. },
  95. error: function (XMLHttpRequest, textStatus, errorThrown) {
  96. console.log(errorThrown);
  97. }
  98. });
  99. }
  100. getUserRole()
  101. /* 为保证页面显示效果,判断浏览器版本是否过低*/
  102. function checkIEVersion() {
  103. var getjson = sp.getExplorerInfo();
  104. if (getjson.type == "IE") {
  105. if (getjson.version == "8.0" || getjson.version == "7.0" || getjson.version == "6.0") {
  106. $("#checkIEVersionDiv").text("您当前使用的是" + getjson.type + "浏览器 版本:" + getjson.version + ",版本过低,请更新IE浏览器或使用其他浏览器");
  107. $("#checkIEVersionDiv").show();
  108. //然后跳到需要连接的下载网站
  109. //window.location.href="http://jiaoxueyun.com/download.jsp";
  110. }
  111. }
  112. }
  113. checkIEVersion();