获取用户自己的设备列表,获取用户数据,获取是否是代理人,通过是否登录判别是否发送请求
This commit is contained in:
parent
a013e0bf9e
commit
49eeab90e2
|
|
@ -171,7 +171,13 @@ export default {
|
|||
// 获取设备列表
|
||||
async fetchDeviceList() {
|
||||
try {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
console.log('暂无登录,不请求设备列表')
|
||||
return
|
||||
}
|
||||
const response = await getDeviceList()
|
||||
|
||||
if (response.code === 200 && response.data && Array.isArray(response.data)) {
|
||||
// 转换设备数据格式
|
||||
const devices = response.data.map(device => {
|
||||
|
|
|
|||
|
|
@ -174,6 +174,11 @@ export default {
|
|||
async fetchUserData() {
|
||||
this.loading = true
|
||||
try {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
console.log('暂无登录,不请求用户数据')
|
||||
return
|
||||
}
|
||||
// 并行获取所有数据
|
||||
const [userInfoRes, financialRes, statsRes] = await Promise.allSettled([
|
||||
this.fetchUserInfo(),
|
||||
|
|
@ -235,6 +240,11 @@ export default {
|
|||
|
||||
async getIsAgent() {
|
||||
try {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
console.log('暂无登录,不请求是否是代理人')
|
||||
return
|
||||
}
|
||||
const response = await isAgent()
|
||||
this.isAgent = response.data
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -139,13 +139,7 @@ function handleResponseError(res, reject, options = {}) {
|
|||
const errorMap = {
|
||||
401: {
|
||||
title: '登录已过期,请重新登录',
|
||||
action: () => {
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
}, 1500)
|
||||
},
|
||||
action: () => {},
|
||||
},
|
||||
403: {
|
||||
title: '权限不足',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user