kulley 7 years ago
parent
commit
22ec0c1fee
2 changed files with 33 additions and 5 deletions
  1. 15 4
      src/App.js
  2. 18 1
      src/config.js

+ 15 - 4
src/App.js

@@ -4,7 +4,7 @@ import './App.css';
 import Manage from "./page/manage/Manage";
 import Customer from './page/customer/Customer';
 import {getCookie} from "./cookie";
-// import {setCookie} from "./cookie";
+import {setCookie} from "./cookie";
 import {userbyprops, createuser, userbypropsNum} from "./gql";
 import {Query} from "react-apollo";
 import gql from "graphql-tag";
@@ -21,7 +21,9 @@ class App extends Component {
     }
 
     componentWillMount() {
-        // 本地开发
+        /*
+            本地开发版
+        */
         // 管理员
         // setCookie('openid', 'o2fcFvxE5nCQSb4BBHaB4kXcikSE');
         // 我
@@ -29,12 +31,21 @@ class App extends Component {
         // 用户
         // setCookie('openid', 'o2fcFv-h_CFKkNdEYgNkNp0Jt5TA');
 
-        // 微信版
+        /*
+            上线版
+        */
         let openid = getCookie("openid");
         console.log('get openid', openid);
 
         if (!openid) {
-            window.location.href = "/subscribe";
+            if(window.location.hostname.includes('apigateway.myqcloud.com')) {
+                // 未配域名,肯定没有配置
+                window.location.href = "/test/subscribe";
+                setCookie('openid', 'demo_openid');
+            } else {
+                // 已配域名,并且拥有配置
+                window.location.href = "/subscribe";
+            }
         }
     }
 

+ 18 - 1
src/config.js

@@ -1,5 +1,22 @@
-const graphqlFC = window.location.origin + '/graphql';
+/*
+    本地开发版
+*/
 // const graphqlFC = 'http://demo.ioobot.cn/graphql';
+
+
+/*
+    上线版
+*/
+let graphqlFC;
+
+if(window.location.hostname.includes('apigateway.myqcloud.com')) {
+    // 未配域名
+    graphqlFC = window.location.origin + '/test/graphql';
+} else {
+    // 已配域名
+    graphqlFC = window.location.origin + '/graphql';
+}
+
 const storeFile = 'http://deploy.ioobot.cn/api/store-file';
 
 export {graphqlFC, storeFile}