fix: 我的报告页未登录引导登录,uid获取增加storage兜底
- 修复进入我的报告页即提示加载失败:未登录时云函数返回未登录被reject - 新增getUid:vuex优先、uni_id_user_info storage兜底 - 未登录时不再发请求,弹窗引导去登录
This commit is contained in:
+26
-2
@@ -81,12 +81,35 @@ export default {
|
||||
this.queryReports()
|
||||
},
|
||||
methods: {
|
||||
// 获取当前登录用户uid(vuex优先,storage兜底)
|
||||
getUid() {
|
||||
let uid = (typeof vk.getVuex === 'function' && vk.getVuex('$user.userInfo._id')) || ''
|
||||
if (!uid) {
|
||||
const cache = vk.getStorageSync('uni_id_user_info') || {}
|
||||
uid = cache._id || cache.uid || ''
|
||||
}
|
||||
return uid
|
||||
},
|
||||
// 未登录引导
|
||||
checkLogin() {
|
||||
if (this.getUid()) return true
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '请先登录后查看报告',
|
||||
confirmText: '去登录',
|
||||
success: (res) => {
|
||||
if (res.confirm) uni.navigateTo({ url: '/pages/login/login' })
|
||||
}
|
||||
})
|
||||
return false
|
||||
},
|
||||
async queryReports() {
|
||||
if (!this.checkLogin()) return
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await vk.callFunction({
|
||||
url: 'client/ai/pub/getMyReports',
|
||||
data: { pageIndex: 1, pageSize: 50, uid: vk.getVuex('$user.userInfo._id') || '' }
|
||||
data: { pageIndex: 1, pageSize: 50, uid: this.getUid() }
|
||||
})
|
||||
if (res.code === 0 && res.data && res.data.rows) {
|
||||
this.reportList = res.data.rows.map(r => ({
|
||||
@@ -115,6 +138,7 @@ export default {
|
||||
},
|
||||
// 待审查记录 → 重新发起审查
|
||||
async reReview(r) {
|
||||
if (!this.checkLogin()) return
|
||||
if (!r.fileId) {
|
||||
uni.showToast({ title: '该记录缺少文件信息', icon: 'none' })
|
||||
return
|
||||
@@ -147,7 +171,7 @@ export default {
|
||||
file_id: r.fileId,
|
||||
file_name: r.fileName,
|
||||
file_size: r.fileSize || 0,
|
||||
uid: vk.getVuex('$user.userInfo._id') || ''
|
||||
uid: this.getUid()
|
||||
}
|
||||
})
|
||||
uni.hideLoading()
|
||||
|
||||
+10
-1
@@ -84,6 +84,15 @@ export default {
|
||||
this.getPointsBalance()
|
||||
},
|
||||
methods: {
|
||||
// 获取当前登录用户uid(vuex优先,storage兜底)
|
||||
getUid() {
|
||||
let uid = (typeof vk.getVuex === 'function' && vk.getVuex('$user.userInfo._id')) || ''
|
||||
if (!uid) {
|
||||
const cache = vk.getStorageSync('uni_id_user_info') || {}
|
||||
uid = cache._id || cache.uid || ''
|
||||
}
|
||||
return uid
|
||||
},
|
||||
async getPointsBalance() {
|
||||
const res = await vk.callFunction({ url: 'client/points/kh/getBalance' })
|
||||
if (res.code === 0 && res.data) {
|
||||
@@ -122,7 +131,7 @@ export default {
|
||||
file_base64: base64,
|
||||
file_name: fileName,
|
||||
file_size: fileSize,
|
||||
uid: vk.getVuex('$user.userInfo._id') || '',
|
||||
uid: this.getUid(),
|
||||
upload_only: true
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user