陶杰
2024-09-11 8840efb29d8818afcfd2176914bcf4811d9c60fe
plugins/http.js
@@ -73,16 +73,29 @@
                        })
                     } else if (res.data.code === '3000' || res.data && res.data.code &&
                        res.data.code.startsWith('3000')) {
                        let validmsg = ''
                        if (Array.isArray(res.data.data)) {
                           if (res.data.data.length > 0 && res.data.data[0]
                              .msg) {
                              message.showToast(res.data.data[0].msg)
                              validmsg = res.data.data[0].msg
                              // message.showToast(res.data.data[0].msg)
                           }
                        } else if (res.data && res.data.msg) {
                           message.showToast(res.data.msg)
                           validmsg = res.data.msg
                           // message.showToast(res.data.msg)
                        } else if (res.data.data && typeof res.data.data === 'string') {
                           validmsg = res.data.msg
                           message.showToast(res.data.data)
                        }
                        if(validmsg){
                           //兼容安卓手机提醒过快问题
                           setTimeout(() => {
                              message.showToast(validmsg)
                           }, 200)
                        }
                        reject({
                           data: null,
                           code: parseInt(res.data.code),
@@ -93,6 +106,7 @@
                        message.showToast('系统异常')
                     } else if (res.data.code === '401' || res.data && res.data.code &&
                        res.data.code.startsWith('401')) {
                        console.log('resp', res)
                        message.showToast('登录信息失效')
                        storage.removeItem('token')
                        reject({
@@ -109,6 +123,7 @@
                        uni.reLaunch({
                           url: '/pages/login/supplier-login'
                        })
                        // #endif
                     } else {
                        if (res.data.data && typeof res.data.data === 'string') {
@@ -132,20 +147,22 @@
                  // store.dispatch('/clearUserInfo')
                  // commit('updat')
                  // store.commit('updateLogin', false)
                  console.log('401', res)
                  message.showToast('登录信息失效')
                  storage.removeItem('token')
                  reject({
                     data: null,
                     code: 401,
                     msg: 'Unauthorized'
                  })
                  // #ifdef H5
                  // #ifdef PUB_CUSTOMER
                  uni.reLaunch({
                     url: '/views/pc/login.vue'
                     url: '/pages/user/supplier-user'
                  })
                  // #endif
                  // #ifndef H5
                  // #ifndef PUB_CUSTOMER
                  uni.reLaunch({
                     url: '/'
                     url: '/pages/login/supplier-login'
                  })
                  // #endif
@@ -156,6 +173,13 @@
                     code: 403,
                     msg: 'Forbidden'
                  })
               } else if (res.statusCode === 429) {
                  message.showToast('系统操作太频繁,请稍后再试!')
                  reject({
                     data: null,
                     code: 429,
                     msg: 'Forbidden'
                  })
               } else if (res.statusCode === 404) {
                  message.showToast('api不存在')
                  reject({
@@ -164,11 +188,18 @@
                     msg: 'Not Found'
                  })
               } else if (res.statusCode === 500) {
                  message.showToast('服务器内部错误')
                  message.showToast('服务更新升级中,请稍等一分钟左右')
                  reject({
                     data: null,
                     code: 500,
                     msg: 'Internal Server Error'
                     msg: '服务更新升级中,请稍等一分钟左右'
                  })
               } else if (res.statusCode === 502) {
                  message.showToast('服务更新升级中,请稍等一分钟左右')
                  reject({
                     data: null,
                     code: 502,
                     msg: '服务更新升级中,请稍等一分钟左右'
                  })
               } else {
                  message.showToast('其他错误')