guhongwei 2 years ago
parent
commit
aeac2afc1f
1 changed files with 7 additions and 6 deletions
  1. 7 6
      utils/httpUtil.js

+ 7 - 6
utils/httpUtil.js

@@ -2,9 +2,10 @@ let serverUrl = "https://broadcast.waityou24.cn";//http://120.48.146.1    https:
 let wechatUrl = 'https://broadcast.waityou24.cn';
 
 const getDomain = (uri, type) => {
-    if (uri.startsWith('/wechat/api')) return wechatUrl;
-    else if (type) return serverUrl + `/newCourt/${type}/v2/api`;
-    return serverUrl + '/newCourt/v2/api';
+    if (uri.includes('http')) return uri;
+    if (uri.startsWith('/wechat/api')) return wechatUrl + uri;
+    else if (type) return serverUrl + `/newCourt/${type}/v2/api` + uri;
+    return serverUrl + '/newCourt/v2/api' + uri;
 }
 
 const $get = (uri, data, type) => {
@@ -12,7 +13,7 @@ const $get = (uri, data, type) => {
     let baseUrl = getDomain(uri, type);
     return new Promise((resolve, reject) => {
         wx.request({
-            url: `${baseUrl}${uri}`,
+            url: `${baseUrl}`,
             method: "get",
             data,
             header: {},
@@ -26,7 +27,7 @@ const $post = (uri, data, type) => {
     let baseUrl = getDomain(uri, type);
     return new Promise((resolve, reject) => {
         wx.request({
-            url: `${baseUrl}${uri}`,
+            url: `${baseUrl}`,
             method: "post",
             data,
             header: {},
@@ -40,7 +41,7 @@ const $delete = (uri, data, type) => {
     let baseUrl = getDomain(uri, type);
     return new Promise((resolve, reject) => {
         wx.request({
-            url: `${baseUrl}${uri}`,
+            url: `${baseUrl}`,
             method: "delete",
             data,
             success: (res) => toResolve(resolve, res),