Ver Fonte

fix: 康保大数据页面未登录时退回登录页

zhangying há 5 dias atrás
pai
commit
b70e24683f

+ 1 - 1
src/main/resources/static/app/main/bigdata/kbxy/dwdt.js

@@ -1,7 +1,7 @@
 (function ($app) {
     'use strict';
     $app.module('gtPartyApp').controller('showKBDjdsj_dwdtCtrl', function ($scope, $state, $alert, AuthUser, flowaudit, $http, $ocLazyLoad, $loading, $timeout) {
-        if (AuthUser.getUser().Id == null || AuthUser.getUser().Id == '') {
+        if (!AuthUser || !AuthUser.getUser().Id || AuthUser.getUser().Id == null || AuthUser.getUser().Id == "null") {
             window.location.href = "/app/main/index.html#!/loginkb";
             return false;
         }

+ 2 - 1
src/main/resources/static/app/main/bigdata/kbxy/home.js

@@ -1,10 +1,11 @@
 (function ($app) {
     'use strict';
     $app.module('gtPartyApp').controller('showKBDjdsjCtrl', function ($scope, $state, $alert, AuthUser, flowaudit, $http, $ocLazyLoad, $loading, $filter) {
-        if (AuthUser.getUser().Id == null || AuthUser.getUser().Id == '') {
+        if (!AuthUser || !AuthUser.getUser().Id || AuthUser.getUser().Id == null || AuthUser.getUser().Id == "null") {
             window.location.href = "/app/main/index.html#!/loginkb";
             return false;
         }
+
         $scope.id = $state.params.id;
         //初始化查询参数
         $scope.selectparams = {

+ 52 - 5
src/main/resources/static/app/main/login-e.js

@@ -246,7 +246,7 @@
             });
         };
         $loading.hide();
-    }]).controller("loginECtrl", ['$scope', '$state', '$http', '$loading', '$alert', '$desData', 'AuthUser', function ($scope, $state, $http, $loading, $alert, $desData, AuthUser) {
+    }]).controller("loginECtrl", ['$scope', '$state', '$http', '$loading', '$alert', '$desData', 'AuthUser', '$bsRouterState', function ($scope, $state, $http, $loading, $alert, $desData, AuthUser, $bsRouterState) {
         $scope.loginuser = {uid: '', pwd: ''};
         $scope.sysName = window.sysCompanyName;
 
@@ -255,22 +255,69 @@
             $scope.loginuser.pwd = '';
         };
 
-        $scope.login = function () {
+        //站点ID
+        $scope.menudatas = {
+            appkey: "appId",
+            defrolekey: "DefaultRoleId",
+            getMenuUrl: '../../api/user/getmenubyuid',
+            toggle: true
+        };
+
+        $scope.userOnlineActivityFun = function () {
+            //判断是否已经退出登陆
+            if ($scope.userOnlineIsOut) {
+                return;
+            }
+            if (AuthUser.getUser().Id) {
+                $http.post("../../api/home/setOnlineUser", {
+                    uid: AuthUser.getUser().Id
+                }).then(function (res) {
+                    if (res.data.success) {
+                        $timeout($scope.userOnlineActivityFun, 60 * 1000);
+                    } else {
+                        $scope.loginOutCookie();
+                    }
 
+                });
+            }
+        };
+
+        $scope.login = async function () {
             var tk = $scope.loginuser.uid + '|' + $scope.loginuser.pwd;
             $loading.show();
             AuthUser.clearUser();
-            $http.post('../../api/home/locallogin', $desData.GetToken(tk)).then(function (req) {
+            await $http.post('../../api/home/locallogin', $desData.GetToken(tk)).then(function (req) {
                 $loading.hide();
                 if (req.data.success) {
-                    window.location.href = '../main/index-kbdsj.html#!/kb/showDjdsj';
+                    $http.get("../../api/user/curloginuser", {params: {appkey: $scope.menudatas.appkey}}).then(function (res) {
+                        if (res.data.success) {
+                            if (res.data.item) {
+                                angular.extend(res.data.item, {gddwdm: res.data.extdata.gddwdm});
+                                angular.extend(res.data.item, {userType: res.data.extdata.userType});
+                                angular.extend(res.data.item, {dwId: res.data.extdata.dwId});
+                                angular.extend(res.data.item, {dwName: res.data.extdata.dwName});
+                                angular.extend(res.data.item, {oaUserId: res.data.extdata.oaUserId});
+                                angular.extend(res.data.item, {oaIdCard: res.data.extdata.oaIdCard});
+                                angular.extend(res.data.item, {generalPartyCode: res.data.extdata.generalPartyCode});
+
+                                $bsRouterState.loadTabMenu();
+                                AuthUser.clearExtData();
+                                $scope.User = res.data.item;
+                                $scope.User.isServerMan = res.data.extdata != null ? res.data.extdata.isServerMan : false;
+                                AuthUser.setUser($scope.User);
+                                //开始心跳查询是否超时
+                                $scope.userOnlineActivityFun();
+
+                                window.location.href = '../main/index-kbdsj.html#!/kb/showDjdsj';
+                            }
+                        }
+                    });
                 } else {
                     $scope.errorMsg = req.data.msg;
                 }
             }, function (reason) {
                 $loading.hide();
             });
-
         };
 
         $scope.apply = function () {