完善登录、收藏、分享

This commit is contained in:
wangxiaowei
2025-10-20 17:34:50 +08:00
parent c3ffadfded
commit 820b445e9c
12 changed files with 228 additions and 78 deletions

View File

@ -7,6 +7,7 @@ import VueHook from 'alova/vue'
import { toast } from '@/utils/toast'
import { ContentTypeEnum, ResultEnum, ShowMessage } from './tools/enum'
import { useUserStore } from '@/store'
import { jump, SWITCH_TAB, NAVIGATE_TO } from '@/utils/tools'
// 配置动态Tag
export const API_DOMAINS = {
@ -67,14 +68,20 @@ const alovaInstance = createAlova({
// method.config.headers.token = token;
const userStore = useUserStore()
const { token } = userStore.userInfo as unknown as IUserInfo
const { token, mobile } = userStore.userInfo as unknown as IUserInfo
if (!token) {
toast.info('请先登录')
setTimeout(() => {
uni.switchTab({ url: '/pages/my/my' })
}, 500)
jump('/pages/my/my', SWITCH_TAB, 500)
throw new Error('[请求错误]:未登录')
}
if (!mobile) {
toast.info('请先绑定手机号')
jump('/pages/login/mobile', NAVIGATE_TO, 500)
throw new Error('[请求错误]:未绑定手机号')
}
method.config.headers.token = token;
}
@ -124,6 +131,12 @@ const alovaInstance = createAlova({
// throw new Error(`登录超时[${code}]${msg}`)
// }
if (code === ResultEnum.Success) {
if (config.meta?.toast !== false && msg) {
toast.info(msg)
}
}
if (code !== ResultEnum.Success) {
if (config.meta?.toast !== false) {
toast.warning(msg)