doum
3 天以前 22881a4d6409c7d17867e1d40bf81a13578208df
h5/utils/service.js
@@ -1,4 +1,4 @@
import { baseUrl } from "./config.js"
import { baseUrl, app_url } from "./config.js"
export const http = function (options) {
   {
      return new Promise((resolve, reject) => {
@@ -18,7 +18,7 @@
            method: options.method || 'GET',
            header: options.header || {
               // 根据实际接口设计 key 取 token 或者 authorization
               dm_user_token: token,
               dm_user_token: token || '',
               "content-type": 'application/json'
            },
            success: (res) => {
@@ -33,14 +33,17 @@
                        icon: "none",
                        duration: 2000
                     })
                  })
                  },500)
                  if (data.code === 500) {
                     uni.clearStorageSync()
                     return uni.navigateTo({
                        url: '/pages/login/login'
                     uni.showToast({
                        'title': '服务器异常',icon:'none'
                     })
                  }
                  return
                  // if (data.code === 5112) {
                  //    uni.clearStorageSync()
                  //    window.location.href = app_url
                  // }
                  return resolve(data)
               }
               resolve(data)
               // return response.data
@@ -48,7 +51,8 @@
            fail: (err) => {
               // 页面中弹框显示失败
               uni.showToast({
                  title: '请求接口失败'
                  title: '请求接口失败',
                  icon:"none"
               })
               // 返回错误消息