xuxueyang
2024-09-11 999c2811465079edb5f1337ab593f93a5915d525
plugins/http.js
@@ -52,7 +52,7 @@
            dataType: options.dataType ? options.dataType : 'json',
            data: options.data || null,
            header,
            success: (res) => {
            success: async (res) => {
               if (!options.ignore) {
                  message.hideLoading()
               }
@@ -107,13 +107,10 @@
                     } else if (res.data.code === '401' || res.data && res.data.code &&
                        res.data.code.startsWith('401')) {
                        console.log('resp', res)
                        // storage.removeItem('token')
                        await store.dispatch('logout')
                        message.showToast('登录信息失效')
                        storage.removeItem('token')
                        reject({
                           data: null,
                           code: 401,
                           msg: 'Unauthorized'
                        })
                        // #ifdef PUB_CUSTOMER
                        uni.reLaunch({
                           url: '/pages/user/supplier-user'
@@ -124,6 +121,11 @@
                           url: '/pages/login/supplier-login'
                        })
                        // #endif
                        reject({
                           data: null,
                           code: 401,
                           msg: 'Unauthorized'
                        })
                     } else {
                        if (res.data.data && typeof res.data.data === 'string') {
@@ -148,13 +150,11 @@
                  // commit('updat')
                  // store.commit('updateLogin', false)
                  console.log('401', res)
                  message.showToast('登录信息失效')
                  storage.removeItem('token')
                  reject({
                     data: null,
                     code: 401,
                     msg: 'Unauthorized'
                  })
                  await store.dispatch('logout')
                  message.showToast('登录信息失效')
                  // #ifdef PUB_CUSTOMER
                  uni.reLaunch({
                     url: '/pages/user/supplier-user'
@@ -165,6 +165,11 @@
                     url: '/pages/login/supplier-login'
                  })
                  // #endif
                  reject({
                     data: null,
                     code: 401,
                     msg: 'Unauthorized'
                  })
               } else if (res.statusCode === 403) {
                  message.showToast('请求被拒绝')