石广澎
2025-11-30 80763662ffaefa7e49cf541201c689f61f5a3caa
common/http.interceptor.js
@@ -3,25 +3,6 @@
   config,
   DEBUG
} from '@/common/config.js';
function appType() {
   let appType = 0
   // #ifdef MP-WEIXIN
   appType = 3 // 微信小程序
   // #endif
   // #ifdef MP-ALIPAY
   appType = 1 // 支付宝小程序
   // #endif
   // #ifdef H5
   var ua = window.navigator.userAgent.toLowerCase();
   if (ua.match(/MicroMessenger/i) == 'micromessenger') {
      appType = 4; //是微信公众号
   }
   if (ua.match(/AlipayClient/i) == 'alipayclient') {
      appType = 2; //支付宝生活号
   }
   // #endif
   return appType
}
module.exports = (vm) => {
   uni.$u.http.setConfig((x) => {
      return x = {
@@ -43,9 +24,10 @@
      // 引用token
      const TOKEN = uni.getStorageSync(ACCESSTOKEN);
      if (TOKEN) {
         x.header[ACCESSTOKEN] = 'Bearer ' + TOKEN;
         x.header[ACCESSTOKEN] = TOKEN;
      } else {
         delete x.header[ACCESSTOKEN]
      }
      x.header['CLIENT-TYPE'] = appType()
      return x;
   }, x => {
      return Promise.reject(x)
@@ -76,4 +58,4 @@
      vm.$u.toast("请求异常!"); //错误提示信息
      return Promise.reject(response)
   })
}
}