doum
2026-04-29 59b1f0e9967902aa10f5e017d5a0bdfd1b60c9ea
app/utils/http.interceptor.js
@@ -1,6 +1,9 @@
const install = (Vue, vm) => {
   // 请求拦截器
   uni.$u.http.interceptors.request.use((config) => {
      if (!['web/driverInfo/updateLocation'].includes(config.url)) {
         uni.showLoading({ title: '加载中' });
      }
      const Headtoken = vm.$store.state.token
      // 判断有无token,有则加入请求头中
      if (Headtoken) {
@@ -13,11 +16,15 @@
   
   // 响应拦截器
   uni.$u.http.interceptors.response.use((response) => {
      if (response.data.code === 5113) {
         uni.navigateTo({
      if (!['web/driverInfo/updateLocation'].includes(response.config.url)) {
         uni.hideLoading();
      }
      // 未登录/登录过期
      if ([5112, 5113].includes(response.data.code)) {
         vm.$store.commit('clearAll')
         uni.reLaunch({
            url: '/pages/login/login'
         });
         return
         })
      }
      if (response.data.code !== 200) {
         uni.showToast({
@@ -26,6 +33,7 @@
            duration: 2000
         });
      }
      // console.log(response.data)
      return response.data
   }, (response) => {
      return Promise.reject(response)