|
|
@@ -1,5 +1,8 @@
|
|
|
<template>
|
|
|
+
|
|
|
+
|
|
|
<view class="my-resources">
|
|
|
+
|
|
|
<view class="status-bar-placeholder" :style="{height: statusBarHeight + 'px', backgroundColor: '#FFFFFF'}"></view>
|
|
|
<!-- 顶部导航栏 -->
|
|
|
<view class="header">
|
|
|
@@ -20,18 +23,18 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 资源/线索切换标签 -->
|
|
|
- <view class="tab-switcher">
|
|
|
- <view class="tab-item" :class="{ active: currentTab === 'resource' }" @click="switchToResource">
|
|
|
- <text class="tab-text">资源</text>
|
|
|
- <text class="tab-count">({{ registeredTotal }})</text>
|
|
|
- </view>
|
|
|
- <view class="tab-item" :class="{ active: currentTab === 'clue' }" @click="switchToClue">
|
|
|
- <text class="tab-text">线索</text>
|
|
|
- <text class="tab-count">({{ unregisteredTotal }})</text>
|
|
|
+ <!-- 资源/线索切换标签 -->
|
|
|
+ <view class="tab-switcher">
|
|
|
+ <view class="tab-item" :class="{ active: currentTab === 'resource' }" @click="switchToResource">
|
|
|
+ <text class="tab-text">资源</text>
|
|
|
+ <text class="tab-count">({{ registeredTotal }})</text>
|
|
|
+ </view>
|
|
|
+ <view class="tab-item" :class="{ active: currentTab === 'clue' }" @click="switchToClue">
|
|
|
+ <text class="tab-text">线索</text>
|
|
|
+ <text class="tab-count">({{ unregisteredTotal }})</text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
-
|
|
|
+
|
|
|
<scroll-view scroll-y class="content" @scrolltolower="handleScrollToLower" :lower-threshold="50" :enable-back-to-top="true" :scroll-with-animation="true">
|
|
|
<!-- 资源部分(已注册用户) -->
|
|
|
<view class="resource-section" v-if="currentTab === 'resource'">
|
|
|
@@ -431,6 +434,11 @@ export default {
|
|
|
const userId = uni.getStorageSync('userId')
|
|
|
let currentUserId = userInfo.userId || userId || null
|
|
|
|
|
|
+ console.log('=== loadRegisteredPage 调试信息 ===')
|
|
|
+ console.log('userInfo:', JSON.stringify(userInfo))
|
|
|
+ console.log('userId from storage:', userId)
|
|
|
+ console.log('currentUserId:', currentUserId)
|
|
|
+
|
|
|
if (currentUserId !== null && currentUserId !== undefined) {
|
|
|
currentUserId = parseInt(currentUserId)
|
|
|
if (isNaN(currentUserId) || currentUserId <= 0) {
|
|
|
@@ -439,7 +447,11 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (!currentUserId) {
|
|
|
-
|
|
|
+ console.log('❌ 未获取到有效的用户ID,无法加载资源')
|
|
|
+ uni.showToast({
|
|
|
+ title: '请先登录',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
this.registeredResources = []
|
|
|
this.registeredLoading = false
|
|
|
return
|
|
|
@@ -453,13 +465,24 @@ export default {
|
|
|
url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
|
|
|
}
|
|
|
|
|
|
+ console.log('请求URL:', url)
|
|
|
+
|
|
|
const [error, res] = await uni.request({
|
|
|
url: url,
|
|
|
- method: 'GET'
|
|
|
+ method: 'GET',
|
|
|
+ timeout: 15000
|
|
|
})
|
|
|
|
|
|
+ console.log('请求结果 - error:', error)
|
|
|
+ console.log('请求结果 - res.statusCode:', res ? res.statusCode : 'null')
|
|
|
+ console.log('请求结果 - res.data:', res ? JSON.stringify(res.data) : 'null')
|
|
|
+
|
|
|
if (error) {
|
|
|
-
|
|
|
+ console.log('❌ 请求失败:', JSON.stringify(error))
|
|
|
+ uni.showToast({
|
|
|
+ title: '网络请求失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
this.registeredResources = []
|
|
|
this.registeredLoading = false
|
|
|
return
|
|
|
@@ -467,9 +490,12 @@ export default {
|
|
|
|
|
|
if (res.statusCode === 200 && res.data && res.data.code === 200) {
|
|
|
const pageData = res.data.data
|
|
|
+ console.log('pageData:', JSON.stringify(pageData))
|
|
|
if (pageData && pageData.records) {
|
|
|
+ console.log('records数量:', pageData.records.length)
|
|
|
// 转换数据格式,并过滤掉无效数据(null值)
|
|
|
const resources = this.convertResourceData(pageData.records).filter(item => item !== null && item !== undefined)
|
|
|
+ console.log('转换后资源数量:', resources.length)
|
|
|
|
|
|
// 如果是第一页,直接替换;否则追加
|
|
|
if (pageNum === 1) {
|
|
|
@@ -480,19 +506,24 @@ export default {
|
|
|
|
|
|
// 更新总数(使用后端返回的total)
|
|
|
this.registeredTotal = pageData.total || 0
|
|
|
-
|
|
|
+ console.log('资源总数:', this.registeredTotal)
|
|
|
|
|
|
} else {
|
|
|
+ console.log('⚠️ pageData或records为空')
|
|
|
if (pageNum === 1) {
|
|
|
this.registeredResources = []
|
|
|
this.registeredTotal = 0
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
-
|
|
|
+ console.log('❌ 响应状态异常:', res.statusCode, res.data)
|
|
|
+ uni.showToast({
|
|
|
+ title: res.data?.message || '加载失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
}
|
|
|
} catch (e) {
|
|
|
-
|
|
|
+ console.log('❌ 加载资源异常:', e)
|
|
|
if (this.registeredPageNum === 1) {
|
|
|
this.registeredResources = []
|
|
|
}
|
|
|
@@ -515,6 +546,11 @@ export default {
|
|
|
const userId = uni.getStorageSync('userId')
|
|
|
let currentUserId = userInfo.userId || userId || null
|
|
|
|
|
|
+ console.log('=== loadUnregisteredPage 调试信息 ===')
|
|
|
+ console.log('userInfo:', JSON.stringify(userInfo))
|
|
|
+ console.log('userId from storage:', userId)
|
|
|
+ console.log('currentUserId:', currentUserId)
|
|
|
+
|
|
|
if (currentUserId !== null && currentUserId !== undefined) {
|
|
|
currentUserId = parseInt(currentUserId)
|
|
|
if (isNaN(currentUserId) || currentUserId <= 0) {
|
|
|
@@ -523,6 +559,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
if (!currentUserId) {
|
|
|
+ console.log('❌ 未获取到有效的用户ID,无法加载线索')
|
|
|
this.unregisteredResources = []
|
|
|
this.unregisteredLoading = false
|
|
|
return
|
|
|
@@ -536,12 +573,23 @@ export default {
|
|
|
url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
|
|
|
}
|
|
|
|
|
|
+ console.log('请求URL:', url)
|
|
|
+
|
|
|
const [error, res] = await uni.request({
|
|
|
url: url,
|
|
|
- method: 'GET'
|
|
|
+ method: 'GET',
|
|
|
+ timeout: 15000
|
|
|
})
|
|
|
|
|
|
+ console.log('请求结果 - error:', error)
|
|
|
+ console.log('请求结果 - res.statusCode:', res ? res.statusCode : 'null')
|
|
|
+
|
|
|
if (error) {
|
|
|
+ console.log('❌ 请求失败:', JSON.stringify(error))
|
|
|
+ uni.showToast({
|
|
|
+ title: '网络请求失败',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
this.unregisteredResources = []
|
|
|
this.unregisteredLoading = false
|
|
|
return
|
|
|
@@ -549,10 +597,13 @@ export default {
|
|
|
|
|
|
if (res.statusCode === 200 && res.data && res.data.code === 200) {
|
|
|
const pageData = res.data.data
|
|
|
+ console.log('pageData:', JSON.stringify(pageData))
|
|
|
|
|
|
if (pageData && pageData.records) {
|
|
|
+ console.log('records数量:', pageData.records.length)
|
|
|
// 转换数据格式,并过滤掉无效数据(null值)
|
|
|
const resources = this.convertResourceData(pageData.records).filter(item => item !== null && item !== undefined)
|
|
|
+ console.log('转换后线索数量:', resources.length)
|
|
|
|
|
|
// 如果是第一页,直接替换;否则追加
|
|
|
if (pageNum === 1) {
|
|
|
@@ -563,15 +614,20 @@ export default {
|
|
|
|
|
|
// 更新总数(使用后端返回的total)
|
|
|
this.unregisteredTotal = pageData.total || 0
|
|
|
+ console.log('线索总数:', this.unregisteredTotal)
|
|
|
|
|
|
} else {
|
|
|
+ console.log('⚠️ pageData或records为空')
|
|
|
if (pageNum === 1) {
|
|
|
this.unregisteredResources = []
|
|
|
this.unregisteredTotal = 0
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ console.log('❌ 响应状态异常:', res.statusCode, res.data)
|
|
|
}
|
|
|
} catch (e) {
|
|
|
+ console.log('❌ 加载线索异常:', e)
|
|
|
if (this.unregisteredPageNum === 1) {
|
|
|
this.unregisteredResources = []
|
|
|
}
|