谢杰标 2 年之前
父節點
當前提交
5028bb4494
共有 2 個文件被更改,包括 11 次插入4 次删除
  1. 5 0
      common/methodTool.js
  2. 6 4
      common/request.js

+ 5 - 0
common/methodTool.js

@@ -637,4 +637,9 @@ export default {
       totalQuestionNum,
     };
   },
+  checkDomain(str) {
+    let domain =
+      /^([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)|   (io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))$/;
+    return domain.test(str);
+  },
 };

+ 6 - 4
common/request.js

@@ -1,5 +1,6 @@
 import store from "@/store/index.js";
 import config from "@/common/config";
+import method from "@/common/methodTool";
 var num = 1;
 //接口api
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
@@ -8,10 +9,7 @@ export const BASE_URL = config.BASE_URL;
 export let tenantId = config.tenantId; // 祥粤云学堂:867735392558919680,祥粤学堂:667735392758919630, 中建云学堂-567735392758918520
 // #endif
 // #ifdef H5
-export const host =
-  process.env.NODE_ENV === "production"
-    ? window.location.host
-    : "120.79.166.78:19012";
+export const host = setHost();
 export let tenantId = uni.getStorageSync(host) || "";
 // #endif
 export const myRequest = (options) => {
@@ -160,3 +158,7 @@ function getTenantId() {
     });
   });
 }
+function setHost() {
+  let host = window.location.host;
+  return method.checkDomain(host) ? host : "120.79.166.78:19012";
+}