Эх сурвалжийг харах

Merge remote-tracking branch 'origin/dev' into dev

heqinwei 7 жил өмнө
parent
commit
2cde3b82bf

+ 13 - 0
frontend/saas-portal-web/config/env.js

@@ -1,16 +1,29 @@
 if (process.env.NODE_ENV == 'production') {
     window.env = {
         profile: 'production',
+        frontend: {
+            // 前端地址
+            baseUrl: 'http://192.168.0.181'
+        },
         server: {
+            // 后端接口网关
             baseUrl: 'http://192.168.0.181:8560',
+            // 账户中心接口
             ssoUrl: 'http://192.168.253.12:32323'
         }
     }
 } else {
     window.env = {
         profile: 'development',
+        frontend: {
+            // 前端地址
+            baseUrl: 'http://192.168.0.181'
+            // baseUrl: 'http://127.0.0.1:1841'
+        },
         server: {
+            // 后端接口网关
             baseUrl: 'http://192.168.0.181:8560',
+            // 账户中心接口
             ssoUrl: 'http://192.168.253.12:32323'
         }
     }

+ 25 - 0
frontend/saas-portal-web/src/js/main.js

@@ -155,6 +155,25 @@ $(document).ready(function(){
             });
         });
     };
+    // 系统页面token
+    var Frontend = (function(){
+        var frame;
+        return {
+            init: function() {
+                $('body').append('<iframe id="frontend" hidden src="' + 
+                    env.frontend.baseUrl + '/set-token.html"></iframe>');
+                frame = window.frames[window.frames.length - 1];
+            },
+            set: function(session, callback) {
+                window.addEventListener('message', callback, false);
+                frame.postMessage(JSON.stringify(session), '*');
+            },
+            redirect: function() {
+                window.location.href = env.frontend.baseUrl;
+            }
+        };
+    })();
+    Frontend.init();
     // 关闭弹窗X
     $(".tc-on").click(function(){
         $('#box-zc').css('display','none');
@@ -172,11 +191,17 @@ $(document).ready(function(){
             $('#box').show();
             listenOnCallback(clientId, function(data){
                 var session = data.token, account = data.account;
+                account.companies = account.companies || [];
                 session.account = account;
                 Session.loadData(session);
                 setUserProfile(account);
                 $('#box').hide();
                 $(".zhezhao").css("display","none");
+                // 系统页面token设置
+                Frontend.set(session, function(){
+                    // TODO
+                    Frontend.redirect();
+                });
             });
         } else {
             $('#box').hide();

+ 10 - 0
frontend/saas-web/set-token.html

@@ -0,0 +1,10 @@
+<script>
+    // iframe接收消息
+	window.addEventListener('message', function(e) {
+		if (e.source != window.parent) {
+            return;
+        }
+        localStorage.setItem('app-state-session', e.data);
+        window.parent.postMessage("success", "*");
+    });
+</script>