From 20b11236b4364034f52df294b9240776f539ede1 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期二, 16 七月 2024 14:49:01 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbomyoujia

---
 wechat_jiaxuan/utils/request.js |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/wechat_jiaxuan/utils/request.js b/wechat_jiaxuan/utils/request.js
new file mode 100644
index 0000000..7d34329
--- /dev/null
+++ b/wechat_jiaxuan/utils/request.js
@@ -0,0 +1,48 @@
+import { baseUrl } from "./config"
+
+export function request(options){
+  let loading = options.loading || '1' // 榛樿鍊�1鏄剧ず锛屽惁鍒欎笉鏄剧ず
+  if(loading == '1'){
+    wx.showLoading()
+  }
+  return new Promise(resolve => {
+    wx.request({
+      url: baseUrl + options.url,
+      data: options.data || {},
+      method: options.method || "GET",
+      header: {
+        'content-type': 'application/json;charset=utf-8',
+        'token': wx.getStorageSync('token') || ''
+      },
+      timeout: 12000,
+      success: (res) => {
+        if (res.data.code === 200) {
+          resolve(res.data || true)
+        } else {
+          if(res.data.code && res.data.code == 5112){
+            wx.navigateTo({
+              url: '/pages/auth/auth',
+            })
+          }
+          res.data.message && wx.showToast({
+            title: res.data.message || '鍙戠敓閿欒',
+            icon: 'none'
+          })
+        }
+      },
+      fail(err) {
+        console.log('err', err);
+        err.message && wx.showToast({
+          title: err.message || '鍙戠敓閿欒',
+          icon: 'none'
+        })
+      },
+      complete() {
+        if(loading == '1'){
+          wx.hideLoading()
+        }
+      }
+    })
+  } )
+}
+

--
Gitblit v1.9.3