xiaohaizhao пре 2 година
родитељ
комит
f6675ecb2a
2 измењених фајлова са 54 додато и 54 уклоњено
  1. 1 1
      app.js
  2. 53 53
      utils/Http.js

+ 1 - 1
app.js

@@ -48,7 +48,7 @@ App({
     initSocket() {
         let that = this;
         this.globalData.SocketTask = wx.connectSocket({
-            url: 'wss://oms.idcgroup.com.cn:8079/yos/webSocket/' + wx.getStorageSync('userMsg').token,
+            url: (this.globalData.http.baseUrl + '/yos/webSocket/').replace("https", "wss").replace("http", "ws") + wx.getStorageSync('userMsg').token,
             complete: (res) => {
                 console.log(res)
             }

+ 53 - 53
utils/Http.js

@@ -1,59 +1,59 @@
-// const baseUrl = "http://61.164.207.46:8000/yos/rest/index";
-// const baseUrl = "http://192.168.3.13:8080/yos/rest/index";
-const baseUrl = "https://oms.idcgroup.com.cn:8079/yos/rest/index";
-
 let count = null;
 class HTTP {
-    request({
-        url,
-        data = {},
-        method = "POST",
-        header = {
-            'content-type': 'application/json'
-        },
-        loading = true
-    }) {
-        return new Promise((resolve, reject) => {
-            this._request(url, resolve, reject, data, method, header, loading);
-        })
-    }
-    _request(url, resolve, reject, data, method, header, loading) {
-        /* if (loading) wx.showLoading({
-            title: '加载中...',
+  constructor() {
+    this.baseUrl = "http://61.164.207.46:8000";
+    // this.baseUrl = "https://oms.idcgroup.com.cn:8079";
+  }
+  request({
+    url,
+    data = {},
+    method = "POST",
+    header = {
+      'content-type': 'application/json'
+    },
+    loading = true
+  }) {
+    return new Promise((resolve, reject) => {
+      this._request(url, resolve, reject, data, method, header, loading);
+    })
+  }
+  _request(url, resolve, reject, data, method, header, loading) {
+    /* if (loading) wx.showLoading({
+        title: '加载中...',
+        mask: true
+    }) */
+    wx.request({
+      url: this.baseUrl + '/yos/rest/index' + url,
+      data: data,
+      method: method,
+      header: header,
+      timeout: 60000,
+      success: res => resolve(res.data),
+      fial: err => reject(err),
+      complete: (res) => {
+        // if (loading) wx.hideLoading()
+        if (res.errMsg != 'request:ok') {
+          wx.showToast({
+            title: '网络异常,请重新进入',
+            icon: "none"
+          })
+        } else if (res.data.msg == '登陆状态已过期,请重新登陆!') {
+          wx.showToast({
+            title: '登陆状态已过期,请重新登陆!',
+            icon: "none",
             mask: true
-        }) */
-        wx.request({
-            url: baseUrl + url,
-            data: data,
-            method: method,
-            header: header,
-            timeout: 60000,
-            success: res => resolve(res.data),
-            fial: err => reject(err),
-            complete: (res) => {
-                // if (loading) wx.hideLoading()
-                if (res.errMsg != 'request:ok') {
-                    wx.showToast({
-                        title: '网络异常,请重新进入',
-                        icon: "none"
-                    })
-                } else if (res.data.msg == '登陆状态已过期,请重新登陆!') {
-                    wx.showToast({
-                        title: '登陆状态已过期,请重新登陆!',
-                        icon: "none",
-                        mask: true
-                    })
-                    getApp().globalData.LaunchOptions = wx.getLaunchOptionsSync();
-                    count = setTimeout(() => {
-                        wx.reLaunch({
-                            url: '/pages/login/phone',
-                        });
-                    }, 1000)
-                }
-            }
-        })
-    }
+          })
+          getApp().globalData.LaunchOptions = wx.getLaunchOptionsSync();
+          count = setTimeout(() => {
+            wx.reLaunch({
+              url: '/pages/login/phone',
+            });
+          }, 1000)
+        }
+      }
+    })
+  }
 }
 export {
-    HTTP
+  HTTP
 }