1
This commit is contained in:
@@ -65,7 +65,10 @@ export const NO_AUTH_APIS = [
|
||||
* 这些接口在调用时如果未登录会自动跳转到登录页面
|
||||
*/
|
||||
export const AUTH_REQUIRED_APIS = [
|
||||
|
||||
// 微信小程序用户相关接口
|
||||
'/user/wechat/mini/userinfo', // 获取用户信息
|
||||
'/user/wechat/mini/phone-update', // 更新手机号
|
||||
'/user/wechat/mini/check-unionid', // 检查UnionID
|
||||
]
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,8 @@ import { HTTP_CONFIG, checkApiAuth, AUTH_REQUIRED_APIS } from './config.js'
|
||||
* 清理认证数据
|
||||
*/
|
||||
function clearAuthData() {
|
||||
console.log('HTTP拦截器: 清理认证数据被调用')
|
||||
console.trace('调用堆栈:')
|
||||
uni.removeStorageSync(HTTP_CONFIG.storageKeys.token)
|
||||
uni.removeStorageSync(HTTP_CONFIG.storageKeys.refreshToken)
|
||||
uni.removeStorageSync(HTTP_CONFIG.storageKeys.userInfo)
|
||||
@@ -188,8 +190,8 @@ export default (vm) => {
|
||||
|
||||
// 统一的响应数据处理
|
||||
if (data.code !== undefined) {
|
||||
// 如果服务端返回的状态码不等于200,则reject()
|
||||
if (data.code !== 200) {
|
||||
// 如果服务端返回的状态码不等于0(成功),则reject()
|
||||
if (data.code !== 0) {
|
||||
// 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示
|
||||
if (custom?.toast !== false) {
|
||||
uni.$u.toast(data.message || '请求失败')
|
||||
|
||||
Reference in New Issue
Block a user