From 01d42cce4abdbd5d232d241b1b6b662314cf3999 Mon Sep 17 00:00:00 2001
From: zhaoxiaohao <279049017@qq.com>
Date: Sat, 06 Feb 2021 16:27:33 +0800
Subject: [PATCH] xigai筛查的问题

---
 kidgrow-web/kidgrow-web-manager/src/main/resources/static/module/index.js |   67 ++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/kidgrow-web/kidgrow-web-manager/src/main/resources/static/module/index.js b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/module/index.js
index 0362fed..4b04179 100644
--- a/kidgrow-web/kidgrow-web-manager/src/main/resources/static/module/index.js
+++ b/kidgrow-web/kidgrow-web-manager/src/main/resources/static/module/index.js
@@ -1,13 +1,13 @@
 //add by owen 修复 path 无法引用http://页面的问题 begin
-String.prototype.startWith = function(str) {
-	if (str == null || str == "" || this.length == 0
-			|| str.length > this.length)
-		return false;
-	if (this.substr(0, str.length) == str)
-		return true;
-	else
-		return false;
-	return true;
+String.prototype.startWith = function (str) {
+    if (str == null || str == "" || this.length == 0
+        || str.length > this.length)
+        return false;
+    if (this.substr(0, str.length) == str)
+        return true;
+    else
+        return false;
+    return true;
 }
 
 
@@ -18,9 +18,9 @@
         return;
     }
     if ($parent.hasClass('layui-tab-item')) {
-        $parent.css({'padding': '0', 'overflow-y': 'hidden'});
+        $parent.css({ 'padding': '0', 'overflow-y': 'hidden' });
     } else {
-        $parent.css({'width': '100%', 'height': '100%'});
+        $parent.css({ 'width': '100%', 'height': '100%' });
     }
 }
 //add by owen 修复 path 无法引用http://页面的问题 end
@@ -33,15 +33,12 @@
     var laytpl = layui.laytpl;
     var element = layui.element;
     var form = layui.form;
-    
+
     var index = {
         // 渲染左侧菜单栏
         initLeftNav: function () {
             admin.req('api-user/menus/current', {}, function (data) {
-                //data = data[1];
-                // console.log(data);
-                // debugger;
-                admin.putTempData("menus",data.data);
+                admin.putTempData("menus", data.data);
                 var menus = data.data;
                 // 判断权限
                 for (var i = menus.length - 1; i >= 0; i--) {
@@ -123,7 +120,7 @@
                             window.open(data.path);
                         } else {
                             //临时保存url
-                            data.path.startWith("http://") ?  admin.putTempData("params",data.path) : null ;
+                            data.path.startWith("http://") ? admin.putTempData("params", data.path) : null;
 
                             var menuId = data.url.substring(2);
                             //add by owen 修复 path 无法引用http://页面的问题
@@ -142,7 +139,7 @@
             var contentDom = '.layui-layout-admin .layui-body';
             admin.showLoading('.layui-layout-admin .layui-body');
             var flag;  // 选项卡是否添加
-            flag =   menuPath.startWith("http://") ? false : flag ;
+            flag = menuPath.startWith("http://") ? false : flag;
             // 判断是否开启了选项卡功能
             if (config.pageTabs) {
                 $('.layui-layout-admin .layui-body .layui-tab .layui-tab-title>li').each(function (index) {
@@ -153,8 +150,8 @@
                 if (!flag) {
                     element.tabAdd('admin-pagetabs', {
                         title: menuName,
-                      //add by owen 修复 path 无法引用http://页面的问题
-                        content:  menuPath.startWith("http://") ? '<div id="admin-iframe" style="width: 100%; height: 100%;"><iframe id="' + menuId + '" src="' + menuPath + '" marginwidth="0"  marginheight="0" width="100%" height="100%"  frameborder="0" onload="initIFrame()"></iframe> </div>'   :  '<div id="' + menuId + '"></div>' ,
+                        //add by owen 修复 path 无法引用http://页面的问题
+                        content: menuPath.startWith("http://") ? '<div id="admin-iframe" style="width: 100%; height: 100%;"><iframe id="' + menuId + '" src="' + menuPath + '" marginwidth="0"  marginheight="0" width="100%" height="100%"  frameborder="0" onload="initIFrame()"></iframe> </div>' : '<div id="' + menuId + '"></div>',
                         id: menuId
                     });
                 }
@@ -192,26 +189,34 @@
             layer.load(2);
             admin.req('api-user/users/current', {}, function (data) {
                 layer.closeAll('loading');
-                // console.log(data.code);
-                // debugger;
                 if (data && data.code === 0) {
                     let user = data.data;
-                    // console.log(user);
-                    // debugger;
                     config.putUser(user);
-                    admin.putTempData("permissions",user.permissions);
+                    admin.putTempData("permissions", user.permissions);
+                    admin.putTempData("organization",user.organizations[user.organizations.length-1]);
                     success(user);
                 } else {
-                    layer.msg('获取用户失败', {icon: 2});
-                    config.removeToken();
-                    location.replace('login.html');
+                    if (data.code === 1000) {
+                        layer.msg(data.msg, { icon: 2, time: 4 * 1000 }, function () {
+                            //回调
+                            config.removeToken();
+                            location.replace('login.html');
+                        })
+
+                    } else {
+                        layer.msg('获取用户失败,请联系管理员', { icon: 2, time: 4 * 1000 }, function () {
+                            //回调
+                            config.removeToken();
+                            location.replace('login.html');
+                        })
+                    }
                 }
             }, 'GET');
         },
         //获取菜单
         getMenus: function () {
             admin.req('api-user/menus/current', {}, function (data) {
-                admin.putTempData("menus",data);
+                admin.putTempData("menus", data);
             }, 'GET');
         },
         // 页面元素绑定事件监听
@@ -221,8 +226,8 @@
                 layer.confirm('确定退出登录?', function () {
                     //通过认证中心 tuic
                     admin.req('api-uaa/oauth/remove/token', {}, function (data) {
-                            config.removeToken();
-                            location.replace('login.html');
+                        config.removeToken();
+                        location.replace('login.html');
                     }, 'POST');
                 });
             });

--
Gitblit v1.8.0