Просмотр исходного кода

fix: 登录页面设置单点登录跳转

zhangying 3 месяцев назад
Родитель
Сommit
3c7b77a32b

+ 1 - 1
src/main/resources/application.yml

@@ -172,5 +172,5 @@ wx:
 portal:
   isPortalLogin: false
   oauthUrl: 'https://cas.gzws.edu.cn'
-  webUrl: ''
+  webUrl: 'http://localhost:8062/'
 

+ 39 - 0
src/main/resources/static/app/main/login-e.js

@@ -278,5 +278,44 @@
         };
 
         $loading.hide();
+
+        // 单点登录设置
+        $scope.toLogin = function () {
+            $http.get("../../api/oauth/getOAuthUrl", {}).then(function (res) {
+                if (res.data.success && res.data.item) {
+                    window.location.href = res.data.item;
+                } else {
+                    if (res.data.msg)
+                        $scope.showMsg('提示', res.data.msg);
+                    $state.go('login');
+                }
+            }, () => {
+                $state.go('login');
+            });
+        };
+        $scope.showMsg = function (title, content) {
+            $alert({
+                title: title + ':',
+                content: content,
+                placement: 'top',
+                type: 'info',
+                show: true,
+                duration: 5
+            });
+        };
+        //判断登录情况
+        if (AuthUser && AuthUser.getUser().Id && AuthUser.getUser().Id != 'null') {
+            $http.get("../../api/user/curloginuser", {params: {appkey: "appId"}}).then(function (res) {
+                if (res.data.success && res.data.item) {
+                    $state.go('homeTabs');
+                } else {
+                    $scope.toLogin();
+                }
+            }, () => {
+                $scope.toLogin();
+            });
+        } else {
+            $scope.toLogin();
+        }
     }]);
 })(angular, this);

+ 39 - 0
src/main/resources/static/app/main/login.js

@@ -278,5 +278,44 @@
         };
 
         $loading.hide();
+
+        // 单点登录设置
+        $scope.toLogin = function () {
+            $http.get("../../api/oauth/getOAuthUrl", {}).then(function (res) {
+                if (res.data.success && res.data.item) {
+                    window.location.href = res.data.item;
+                } else {
+                    if (res.data.msg)
+                        $scope.showMsg('提示', res.data.msg);
+                    $state.go('login');
+                }
+            }, () => {
+                $state.go('login');
+            });
+        };
+        $scope.showMsg = function (title, content) {
+            $alert({
+                title: title + ':',
+                content: content,
+                placement: 'top',
+                type: 'info',
+                show: true,
+                duration: 5
+            });
+        };
+        //判断登录情况
+        if (AuthUser && AuthUser.getUser().Id && AuthUser.getUser().Id != 'null') {
+            $http.get("../../api/user/curloginuser", {params: {appkey: "appId"}}).then(function (res) {
+                if (res.data.success && res.data.item) {
+                    $state.go('homeTabs');
+                } else {
+                    $scope.toLogin();
+                }
+            }, () => {
+                $scope.toLogin();
+            });
+        } else {
+            $scope.toLogin();
+        }
     }]);
 })(angular, this);