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