Forráskód Böngészése

发送请求添加不弹框

zhaoxiaohai 3 éve
szülő
commit
9a57249ddb
3 módosított fájl, 14 hozzáadás és 10 törlés
  1. 2 1
      pages/liveStreaming/index.js
  2. 8 7
      utils/Http.js
  3. 4 2
      utils/api.js

+ 2 - 1
pages/liveStreaming/index.js

@@ -44,7 +44,7 @@ Page({
         "pageSize": 20,
         "channelid": that.data.accountMsg.channelid
       }
-    }).then(res => {
+    }, false).then(res => {
       console.log(res)
     })
   },
@@ -106,6 +106,7 @@ Page({
       "method": method,
       "content": {}
     }).then(res => {
+      console.log("不显示")
       const isSy = (method == "getSYLiveInfo") ? true : false;
       this.setData({
         accountStatus: res.code,

+ 8 - 7
utils/Http.js

@@ -6,14 +6,15 @@ class HTTP {
         method = "POST",
         header = {
             'content-type': 'application/json'
-        }
+        },
+        loading = true
     }) {
         return new Promise((resolve, reject) => {
-            this._request(url, resolve, reject, data, method, header);
+            this._request(url, resolve, reject, data, method, header, loading);
         })
     }
-    _request(url, resolve, reject, data, method, header) {
-        wx.showLoading({
+    _request(url, resolve, reject, data, method, header, loading) {
+        if (loading) wx.showLoading({
             title: '加载中...',
             mask: true
         })
@@ -25,15 +26,15 @@ class HTTP {
             timeout: 20000,
             success: (res) => {
                 resolve(res.data);
-                wx.hideLoading()
+                if (loading) wx.hideLoading()
             },
             fial: (err) => {
                 reject(err);
-                wx.hideLoading();
+                if (loading) wx.hideLoading()
             },
             complete: (res) => {
                 if (res.errMsg != 'request:ok') {
-                    wx.hideLoading();
+                    wx.hideLoading()
                     wx.showToast({
                         title: '网络异常,请重新进入',
                         icon: "none"

+ 4 - 2
utils/api.js

@@ -17,10 +17,12 @@ class ApiModel extends HTTP {
         })
     }
     /* 基本通用 */
-    basic(data) {
+    basic(data, loading = true) {
+        console.log(loading,data)
         return this.request({
             url: "",
-            data
+            data,
+            loading
         })
     }
     /* 注销登录 */