|
@@ -28,7 +28,7 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <scroll-view scroll-y class="content" @scrolltolower="handleScrollToLower" :lower-threshold="100">
|
|
|
|
|
|
|
+ <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'">
|
|
<view class="resource-section" v-if="currentTab === 'resource'">
|
|
|
<view class="section-header" v-if="registeredResources.length > 0">
|
|
<view class="section-header" v-if="registeredResources.length > 0">
|
|
@@ -232,12 +232,12 @@ export default {
|
|
|
refreshTimer: null, // 定时刷新器
|
|
refreshTimer: null, // 定时刷新器
|
|
|
// 资源分页
|
|
// 资源分页
|
|
|
registeredPageNum: 1, // 资源当前页码
|
|
registeredPageNum: 1, // 资源当前页码
|
|
|
- registeredPageSize: 5, // 资源每页显示数量
|
|
|
|
|
|
|
+ registeredPageSize: 3, // 资源每页显示数量
|
|
|
registeredTotal: 0, // 资源总数
|
|
registeredTotal: 0, // 资源总数
|
|
|
registeredLoading: false, // 资源加载中标志
|
|
registeredLoading: false, // 资源加载中标志
|
|
|
// 线索分页
|
|
// 线索分页
|
|
|
unregisteredPageNum: 1, // 线索当前页码
|
|
unregisteredPageNum: 1, // 线索当前页码
|
|
|
- unregisteredPageSize: 5, // 线索每页显示数量
|
|
|
|
|
|
|
+ unregisteredPageSize: 3, // 线索每页显示数量
|
|
|
unregisteredTotal: 0, // 线索总数
|
|
unregisteredTotal: 0, // 线索总数
|
|
|
unregisteredLoading: false // 线索加载中标志
|
|
unregisteredLoading: false // 线索加载中标志
|
|
|
}
|
|
}
|
|
@@ -365,78 +365,69 @@ export default {
|
|
|
this.loadUnregisteredPage(1)
|
|
this.loadUnregisteredPage(1)
|
|
|
},
|
|
},
|
|
|
// 滚动到底部触发加载更多
|
|
// 滚动到底部触发加载更多
|
|
|
- handleScrollToLower() {
|
|
|
|
|
|
|
+ handleScrollToLower(e) {
|
|
|
|
|
+ console.log('=== 触发滚动到底部事件 ===', e)
|
|
|
if (this.currentTab === 'resource') {
|
|
if (this.currentTab === 'resource') {
|
|
|
// 资源列表加载更多
|
|
// 资源列表加载更多
|
|
|
- if (!this.registeredLoading && this.registeredResources.length < this.registeredTotal) {
|
|
|
|
|
- this.loadMoreRegistered()
|
|
|
|
|
|
|
+ console.log('资源列表状态:', {
|
|
|
|
|
+ registeredLoading: this.registeredLoading,
|
|
|
|
|
+ registeredResourcesLength: this.registeredResources.length,
|
|
|
|
|
+ registeredTotal: this.registeredTotal,
|
|
|
|
|
+ canLoadMore: this.registeredResources.length < this.registeredTotal
|
|
|
|
|
+ })
|
|
|
|
|
+ if (!this.registeredLoading) {
|
|
|
|
|
+ // 如果已加载数量小于总数,继续加载
|
|
|
|
|
+ if (this.registeredTotal > 0 && this.registeredResources.length < this.registeredTotal) {
|
|
|
|
|
+ console.log('✅ 开始加载更多资源...')
|
|
|
|
|
+ this.loadMoreRegistered()
|
|
|
|
|
+ } else if (this.registeredTotal === 0) {
|
|
|
|
|
+ console.log('⚠️ 资源总数未知,尝试加载...')
|
|
|
|
|
+ // 如果总数未知,也尝试加载(可能是第一页加载失败)
|
|
|
|
|
+ this.loadMoreRegistered()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('❌ 资源列表已加载全部数据,不再加载')
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('⏳ 资源列表正在加载中,跳过...')
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 线索列表加载更多
|
|
// 线索列表加载更多
|
|
|
- if (!this.unregisteredLoading && this.unregisteredResources.length < this.unregisteredTotal) {
|
|
|
|
|
- this.loadMoreUnregistered()
|
|
|
|
|
|
|
+ console.log('线索列表状态:', {
|
|
|
|
|
+ unregisteredLoading: this.unregisteredLoading,
|
|
|
|
|
+ unregisteredResourcesLength: this.unregisteredResources.length,
|
|
|
|
|
+ unregisteredTotal: this.unregisteredTotal,
|
|
|
|
|
+ canLoadMore: this.unregisteredResources.length < this.unregisteredTotal
|
|
|
|
|
+ })
|
|
|
|
|
+ if (!this.unregisteredLoading) {
|
|
|
|
|
+ // 如果已加载数量小于总数,继续加载
|
|
|
|
|
+ if (this.unregisteredTotal > 0 && this.unregisteredResources.length < this.unregisteredTotal) {
|
|
|
|
|
+ console.log('✅ 开始加载更多线索...')
|
|
|
|
|
+ this.loadMoreUnregistered()
|
|
|
|
|
+ } else if (this.unregisteredTotal === 0) {
|
|
|
|
|
+ console.log('⚠️ 线索总数未知,尝试加载...')
|
|
|
|
|
+ // 如果总数未知,也尝试加载(可能是第一页加载失败)
|
|
|
|
|
+ this.loadMoreUnregistered()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('❌ 线索列表已加载全部数据,不再加载')
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('⏳ 线索列表正在加载中,跳过...')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- // 加载资源指定页数据
|
|
|
|
|
- loadRegisteredPage(pageNum) {
|
|
|
|
|
- if (!this.allRegisteredResources || this.allRegisteredResources.length === 0) {
|
|
|
|
|
- console.warn('loadRegisteredPage: allRegisteredResources为空')
|
|
|
|
|
- this.registeredResources = []
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- const start = (pageNum - 1) * this.registeredPageSize
|
|
|
|
|
- const end = start + this.registeredPageSize
|
|
|
|
|
- this.registeredResources = this.allRegisteredResources.slice(0, end)
|
|
|
|
|
- console.log('loadRegisteredPage - pageNum:', pageNum, 'start:', start, 'end:', end, 'loaded:', this.registeredResources.length, 'total:', this.allRegisteredResources.length)
|
|
|
|
|
- },
|
|
|
|
|
- // 加载线索指定页数据
|
|
|
|
|
- loadUnregisteredPage(pageNum) {
|
|
|
|
|
- if (!this.allUnregisteredResources || this.allUnregisteredResources.length === 0) {
|
|
|
|
|
- console.warn('loadUnregisteredPage: allUnregisteredResources为空')
|
|
|
|
|
- this.unregisteredResources = []
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- const start = (pageNum - 1) * this.unregisteredPageSize
|
|
|
|
|
- const end = start + this.unregisteredPageSize
|
|
|
|
|
- this.unregisteredResources = this.allUnregisteredResources.slice(0, end)
|
|
|
|
|
- console.log('loadUnregisteredPage - pageNum:', pageNum, 'start:', start, 'end:', end, 'loaded:', this.unregisteredResources.length, 'total:', this.allUnregisteredResources.length)
|
|
|
|
|
- },
|
|
|
|
|
- // 加载更多资源
|
|
|
|
|
- loadMoreRegistered() {
|
|
|
|
|
|
|
+ // 加载资源指定页数据(从后端加载,使用isUser参数过滤已注册用户)
|
|
|
|
|
+ async loadRegisteredPage(pageNum) {
|
|
|
if (this.registeredLoading) return
|
|
if (this.registeredLoading) return
|
|
|
- if (this.registeredResources.length >= this.registeredTotal) return
|
|
|
|
|
|
|
|
|
|
this.registeredLoading = true
|
|
this.registeredLoading = true
|
|
|
- this.registeredPageNum++
|
|
|
|
|
- const start = (this.registeredPageNum - 1) * this.registeredPageSize
|
|
|
|
|
- const end = start + this.registeredPageSize
|
|
|
|
|
- const newData = this.allRegisteredResources.slice(start, end)
|
|
|
|
|
- this.registeredResources = [...this.registeredResources, ...newData]
|
|
|
|
|
- this.registeredLoading = false
|
|
|
|
|
- },
|
|
|
|
|
- // 加载更多线索
|
|
|
|
|
- loadMoreUnregistered() {
|
|
|
|
|
- if (this.unregisteredLoading) return
|
|
|
|
|
- if (this.unregisteredResources.length >= this.unregisteredTotal) return
|
|
|
|
|
|
|
+ this.registeredPageNum = pageNum
|
|
|
|
|
|
|
|
- this.unregisteredLoading = true
|
|
|
|
|
- this.unregisteredPageNum++
|
|
|
|
|
- const start = (this.unregisteredPageNum - 1) * this.unregisteredPageSize
|
|
|
|
|
- const end = start + this.unregisteredPageSize
|
|
|
|
|
- const newData = this.allUnregisteredResources.slice(start, end)
|
|
|
|
|
- this.unregisteredResources = [...this.unregisteredResources, ...newData]
|
|
|
|
|
- this.unregisteredLoading = false
|
|
|
|
|
- },
|
|
|
|
|
- // 加载我的资源数据
|
|
|
|
|
- async loadMyResources() {
|
|
|
|
|
try {
|
|
try {
|
|
|
// 获取当前登录用户ID
|
|
// 获取当前登录用户ID
|
|
|
const userInfo = uni.getStorageSync('userInfo') || {}
|
|
const userInfo = uni.getStorageSync('userInfo') || {}
|
|
|
const userId = uni.getStorageSync('userId')
|
|
const userId = uni.getStorageSync('userId')
|
|
|
let currentUserId = userInfo.userId || userId || null
|
|
let currentUserId = userInfo.userId || userId || null
|
|
|
|
|
|
|
|
- // 验证并转换currentUserId为有效的整数
|
|
|
|
|
if (currentUserId !== null && currentUserId !== undefined) {
|
|
if (currentUserId !== null && currentUserId !== undefined) {
|
|
|
currentUserId = parseInt(currentUserId)
|
|
currentUserId = parseInt(currentUserId)
|
|
|
if (isNaN(currentUserId) || currentUserId <= 0) {
|
|
if (isNaN(currentUserId) || currentUserId <= 0) {
|
|
@@ -446,20 +437,17 @@ export default {
|
|
|
|
|
|
|
|
if (!currentUserId) {
|
|
if (!currentUserId) {
|
|
|
console.error('无法获取当前登录用户ID')
|
|
console.error('无法获取当前登录用户ID')
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '请先登录',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.registeredResources = []
|
|
|
|
|
+ this.registeredLoading = false
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 调用后端接口,传递当前用户ID作为matchmakerId
|
|
|
|
|
const baseUrl = process.env.NODE_ENV === 'development'
|
|
const baseUrl = process.env.NODE_ENV === 'development'
|
|
|
- ? 'http://localhost:8083/api' // 开发环境 - 通过网关
|
|
|
|
|
- : 'https://your-domain.com/api' // 生产环境
|
|
|
|
|
|
|
+ ? 'http://localhost:8083/api'
|
|
|
|
|
+ : 'https://your-domain.com/api'
|
|
|
|
|
|
|
|
- // 构建查询参数,确保currentUserId是有效的整数
|
|
|
|
|
- let url = `${baseUrl}/my-resource/list?currentUserId=${currentUserId}&pageNum=1&pageSize=100`
|
|
|
|
|
|
|
+ // 构建查询参数,使用isUser=1参数只获取已注册用户
|
|
|
|
|
+ let url = `${baseUrl}/my-resource/list?currentUserId=${currentUserId}&pageNum=${pageNum}&pageSize=${this.registeredPageSize}&isUser=1`
|
|
|
if (this.searchKeyword && this.searchKeyword.trim()) {
|
|
if (this.searchKeyword && this.searchKeyword.trim()) {
|
|
|
url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
|
|
url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
|
|
|
}
|
|
}
|
|
@@ -471,204 +459,249 @@ export default {
|
|
|
|
|
|
|
|
if (error) {
|
|
if (error) {
|
|
|
console.error('加载资源数据失败:', error)
|
|
console.error('加载资源数据失败:', error)
|
|
|
|
|
+ this.registeredResources = []
|
|
|
|
|
+ this.registeredLoading = false
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (res.statusCode === 200 && res.data && res.data.code === 200) {
|
|
if (res.statusCode === 200 && res.data && res.data.code === 200) {
|
|
|
- // 处理返回的数据
|
|
|
|
|
const pageData = res.data.data
|
|
const pageData = res.data.data
|
|
|
- console.log('=== 后端返回的完整数据 ===')
|
|
|
|
|
- console.log('pageData:', JSON.stringify(pageData, null, 2))
|
|
|
|
|
if (pageData && pageData.records) {
|
|
if (pageData && pageData.records) {
|
|
|
- console.log('records数量:', pageData.records.length)
|
|
|
|
|
- if (pageData.records.length > 0) {
|
|
|
|
|
- console.log('第一条记录的完整数据:', JSON.stringify(pageData.records[0], null, 2))
|
|
|
|
|
- }
|
|
|
|
|
- // 将后端数据转换为前端需要的格式
|
|
|
|
|
- const allResources = pageData.records.map(item => {
|
|
|
|
|
- // 直接使用mate_selection_criteria字段作为择偶要求
|
|
|
|
|
- // 支持多种可能的字段名(mateSelectionCriteria或mate_selection_criteria)
|
|
|
|
|
- let requirement = item.mateSelectionCriteria || item.mate_selection_criteria || ''
|
|
|
|
|
- // 去除首尾空格,如果为空则显示"暂无要求"
|
|
|
|
|
- if (requirement) {
|
|
|
|
|
- requirement = requirement.trim()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 处理标签(可以根据实际需求扩展)
|
|
|
|
|
- const labels = []
|
|
|
|
|
- if (item.constellation) {
|
|
|
|
|
- labels.push(item.constellation)
|
|
|
|
|
- }
|
|
|
|
|
- if (item.occupation) {
|
|
|
|
|
- labels.push(item.occupation)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 处理头像URL:确保使用完整的URL
|
|
|
|
|
- // 尝试多种可能的字段名
|
|
|
|
|
- let avatarUrl = item.avatarUrl || item.avatar_url || item.avatar || ''
|
|
|
|
|
-
|
|
|
|
|
- console.log('=== 头像URL处理 ===')
|
|
|
|
|
- console.log('资源ID:', item.resourceId, '姓名:', item.name)
|
|
|
|
|
- console.log('原始数据字段:', {
|
|
|
|
|
- avatarUrl: item.avatarUrl,
|
|
|
|
|
- avatar_url: item.avatar_url,
|
|
|
|
|
- avatar: item.avatar,
|
|
|
|
|
- 'item完整对象': item
|
|
|
|
|
- })
|
|
|
|
|
- console.log('提取的avatarUrl值:', avatarUrl, '类型:', typeof avatarUrl, '是否为空:', !avatarUrl)
|
|
|
|
|
-
|
|
|
|
|
- // 如果头像URL为空或null,设置为空字符串(让CSS背景图显示)
|
|
|
|
|
- if (!avatarUrl || avatarUrl.trim() === '' || avatarUrl === 'null' || avatarUrl === null || avatarUrl === undefined) {
|
|
|
|
|
- avatarUrl = '' // 设置为空,让CSS默认背景显示
|
|
|
|
|
- console.log('⚠️ 头像URL为空,设置为空字符串,将显示CSS默认背景')
|
|
|
|
|
- } else {
|
|
|
|
|
- // 确保URL是完整的(如果已经是完整URL则直接使用)
|
|
|
|
|
- avatarUrl = avatarUrl.trim()
|
|
|
|
|
-
|
|
|
|
|
- // 如果URL不是以http开头,可能需要拼接基础URL(根据实际情况调整)
|
|
|
|
|
- if (!avatarUrl.startsWith('http://') && !avatarUrl.startsWith('https://')) {
|
|
|
|
|
- console.warn('⚠️ 头像URL不是完整URL,可能需要拼接:', avatarUrl)
|
|
|
|
|
- // 如果是相对路径,可以尝试拼接MinIO基础URL
|
|
|
|
|
- // avatarUrl = 'http://115.190.125.125:9000/' + avatarUrl
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 确保MinIO URL可以正常访问(可能需要处理跨域)
|
|
|
|
|
- // 如果MinIO配置了公共访问,直接使用URL即可
|
|
|
|
|
- console.log('✅ 使用用户头像URL:', avatarUrl)
|
|
|
|
|
-
|
|
|
|
|
- // 验证URL格式
|
|
|
|
|
- if (avatarUrl.includes('115.190.125.125:9000')) {
|
|
|
|
|
- console.log('✅ 检测到MinIO URL,URL格式:', avatarUrl)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- console.log('最终设置的avatarUrl:', avatarUrl)
|
|
|
|
|
- console.log('=== 头像URL处理结束 ===')
|
|
|
|
|
-
|
|
|
|
|
- // 确保resourceId是有效的整数
|
|
|
|
|
- let resourceId = item.resourceId || item.resource_id
|
|
|
|
|
-
|
|
|
|
|
- // 调试日志:检查resourceId的来源
|
|
|
|
|
- console.log('=== resourceId处理 ===')
|
|
|
|
|
- console.log('原始item.resourceId:', item.resourceId, '类型:', typeof item.resourceId)
|
|
|
|
|
- console.log('原始item.resource_id:', item.resource_id, '类型:', typeof item.resource_id)
|
|
|
|
|
- console.log('提取的resourceId:', resourceId, '类型:', typeof resourceId)
|
|
|
|
|
-
|
|
|
|
|
- if (resourceId === null || resourceId === undefined || resourceId === 'undefined' || resourceId === 'null') {
|
|
|
|
|
- console.warn('资源ID无效,跳过该资源:', item)
|
|
|
|
|
- return null // 返回null,后续会被filter过滤掉
|
|
|
|
|
- }
|
|
|
|
|
- resourceId = parseInt(resourceId)
|
|
|
|
|
- if (isNaN(resourceId) || resourceId <= 0) {
|
|
|
|
|
- console.warn('资源ID格式错误,跳过该资源:', item)
|
|
|
|
|
- return null // 返回null,后续会被filter过滤掉
|
|
|
|
|
- }
|
|
|
|
|
- console.log('处理后的resourceId:', resourceId, '类型:', typeof resourceId)
|
|
|
|
|
- console.log('=== resourceId处理结束 ===')
|
|
|
|
|
-
|
|
|
|
|
- // 处理isUser字段,支持多种可能的字段名(isUser或is_user)
|
|
|
|
|
- let isUser = item.isUser !== null && item.isUser !== undefined ? item.isUser :
|
|
|
|
|
- (item.is_user !== null && item.is_user !== undefined ? item.is_user : 0)
|
|
|
|
|
- // 确保isUser是数字类型
|
|
|
|
|
- isUser = parseInt(isUser) || 0
|
|
|
|
|
-
|
|
|
|
|
- // 处理userId字段,支持多种可能的字段名(userId或user_id)
|
|
|
|
|
- let userId = item.userId !== null && item.userId !== undefined ? item.userId :
|
|
|
|
|
- (item.user_id !== null && item.user_id !== undefined ? item.user_id : null)
|
|
|
|
|
- // 确保userId是数字类型或null
|
|
|
|
|
- if (userId !== null && userId !== undefined) {
|
|
|
|
|
- userId = parseInt(userId)
|
|
|
|
|
- if (isNaN(userId) || userId <= 0) {
|
|
|
|
|
- userId = null
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 处理isMatch字段
|
|
|
|
|
- let isMatch = item.isMatch !== null && item.isMatch !== undefined ? item.isMatch :
|
|
|
|
|
- (item.is_match !== null && item.is_match !== undefined ? item.is_match : 0)
|
|
|
|
|
- isMatch = parseInt(isMatch) || 0
|
|
|
|
|
-
|
|
|
|
|
- // 调试日志:检查isUser和userId字段
|
|
|
|
|
- console.log('=== isUser和userId字段处理 ===')
|
|
|
|
|
- console.log('资源ID:', resourceId, '姓名:', item.name)
|
|
|
|
|
- console.log('原始数据:', {
|
|
|
|
|
- isUser: item.isUser,
|
|
|
|
|
- is_user: item.is_user,
|
|
|
|
|
- userId: item.userId,
|
|
|
|
|
- user_id: item.user_id,
|
|
|
|
|
- 'item完整对象': item
|
|
|
|
|
- })
|
|
|
|
|
- console.log('处理后的isUser值:', isUser, '类型:', typeof isUser)
|
|
|
|
|
- console.log('处理后的userId值:', userId, '类型:', typeof userId)
|
|
|
|
|
- console.log('=== isUser和userId字段处理结束 ===')
|
|
|
|
|
-
|
|
|
|
|
- // 处理标签(从后端返回的tags字段,如果没有则使用原有的labels)
|
|
|
|
|
- let resourceTags = []
|
|
|
|
|
- if (item.tags && Array.isArray(item.tags) && item.tags.length > 0) {
|
|
|
|
|
- // 使用后端返回的标签
|
|
|
|
|
- resourceTags = item.tags
|
|
|
|
|
- } else if (labels && labels.length > 0) {
|
|
|
|
|
- // 如果没有tags,使用原有的labels(星座、职业等)
|
|
|
|
|
- resourceTags = labels
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const resourceObj = {
|
|
|
|
|
- id: resourceId, // 主要使用的ID字段
|
|
|
|
|
- resourceId: resourceId, // 备用ID字段,确保兼容性
|
|
|
|
|
- resource_id: resourceId, // 备用ID字段,确保兼容性
|
|
|
|
|
- avatar: avatarUrl, // 使用处理后的头像URL
|
|
|
|
|
- name: item.name || '',
|
|
|
|
|
- gender: item.gender === 1 ? '男' : item.gender === 2 ? '女' : '未知',
|
|
|
|
|
- status: item.status !== undefined && item.status !== null ? item.status : 0, // 审核状态,默认为0(待审核)
|
|
|
|
|
- isUser: isUser, // 添加isUser字段,默认为0
|
|
|
|
|
- userId: userId, // 添加userId字段,可能为null
|
|
|
|
|
- isMatch: isMatch, // 添加isMatch字段,默认为0
|
|
|
|
|
- isPlus: false,
|
|
|
|
|
- labels: resourceTags, // 使用处理后的标签列表
|
|
|
|
|
- requirement: requirement || '暂无要求',
|
|
|
|
|
- contact: item.phone ? item.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') : '',
|
|
|
|
|
- originalPhone: item.phone || '', // 保存原始完整手机号用于复制
|
|
|
|
|
- isQuality: false
|
|
|
|
|
- }
|
|
|
|
|
- console.log('创建资源对象 - ID:', resourceObj.id, '名称:', resourceObj.name, 'isUser:', resourceObj.isUser, 'userId:', resourceObj.userId)
|
|
|
|
|
- return resourceObj
|
|
|
|
|
- }).filter(item => item !== null) // 过滤掉无效的资源(resourceId无效的)
|
|
|
|
|
|
|
+ // 转换数据格式
|
|
|
|
|
+ const resources = this.convertResourceData(pageData.records)
|
|
|
|
|
|
|
|
- // 将资源分为两部分:已注册和未注册(保存全部数据)
|
|
|
|
|
- // 已注册用户条件:isUser === 1 且 userId !== null 且 userId !== undefined
|
|
|
|
|
- this.allRegisteredResources = allResources.filter(item => {
|
|
|
|
|
- const isRegistered = item.isUser === 1 && item.userId !== null && item.userId !== undefined
|
|
|
|
|
- return isRegistered
|
|
|
|
|
- })
|
|
|
|
|
- // 未注册用户(线索):isUser !== 1 或 userId === null 或 userId === undefined
|
|
|
|
|
- this.allUnregisteredResources = allResources.filter(item => {
|
|
|
|
|
- const isUnregistered = item.isUser !== 1 || item.userId === null || item.userId === undefined
|
|
|
|
|
- return isUnregistered
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // 如果是第一页,直接替换;否则追加
|
|
|
|
|
+ if (pageNum === 1) {
|
|
|
|
|
+ this.registeredResources = resources
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.registeredResources = [...this.registeredResources, ...resources]
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 设置总数
|
|
|
|
|
- this.registeredTotal = this.allRegisteredResources.length
|
|
|
|
|
- this.unregisteredTotal = this.allUnregisteredResources.length
|
|
|
|
|
|
|
+ // 更新总数(使用后端返回的total)
|
|
|
|
|
+ this.registeredTotal = pageData.total || 0
|
|
|
|
|
|
|
|
- console.log('数据分类完成 - 全部资源:', allResources.length, '已注册:', this.allRegisteredResources.length, '未注册:', this.allUnregisteredResources.length)
|
|
|
|
|
|
|
+ console.log('loadRegisteredPage - pageNum:', pageNum, 'loaded:', this.registeredResources.length, 'total:', this.registeredTotal, 'pageData:', {
|
|
|
|
|
+ total: pageData.total,
|
|
|
|
|
+ size: pageData.size,
|
|
|
|
|
+ current: pageData.current,
|
|
|
|
|
+ pages: pageData.pages,
|
|
|
|
|
+ recordsLength: pageData.records.length
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (pageNum === 1) {
|
|
|
|
|
+ this.registeredResources = []
|
|
|
|
|
+ this.registeredTotal = 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.error('加载资源数据失败,响应:', res.data)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('加载资源数据异常:', e)
|
|
|
|
|
+ if (this.registeredPageNum === 1) {
|
|
|
|
|
+ this.registeredResources = []
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ this.registeredLoading = false
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 加载线索指定页数据(从后端加载,使用isUser参数过滤未注册用户)
|
|
|
|
|
+ async loadUnregisteredPage(pageNum) {
|
|
|
|
|
+ if (this.unregisteredLoading) return
|
|
|
|
|
+
|
|
|
|
|
+ this.unregisteredLoading = true
|
|
|
|
|
+ this.unregisteredPageNum = pageNum
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取当前登录用户ID
|
|
|
|
|
+ const userInfo = uni.getStorageSync('userInfo') || {}
|
|
|
|
|
+ const userId = uni.getStorageSync('userId')
|
|
|
|
|
+ let currentUserId = userInfo.userId || userId || null
|
|
|
|
|
+
|
|
|
|
|
+ if (currentUserId !== null && currentUserId !== undefined) {
|
|
|
|
|
+ currentUserId = parseInt(currentUserId)
|
|
|
|
|
+ if (isNaN(currentUserId) || currentUserId <= 0) {
|
|
|
|
|
+ currentUserId = null
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!currentUserId) {
|
|
|
|
|
+ console.error('无法获取当前登录用户ID')
|
|
|
|
|
+ this.unregisteredResources = []
|
|
|
|
|
+ this.unregisteredLoading = false
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const baseUrl = process.env.NODE_ENV === 'development'
|
|
|
|
|
+ ? 'http://localhost:8083/api'
|
|
|
|
|
+ : 'https://your-domain.com/api'
|
|
|
|
|
+
|
|
|
|
|
+ // 构建查询参数,使用isUser=0参数只获取未注册用户(线索)
|
|
|
|
|
+ let url = `${baseUrl}/my-resource/list?currentUserId=${currentUserId}&pageNum=${pageNum}&pageSize=${this.unregisteredPageSize}&isUser=0`
|
|
|
|
|
+ if (this.searchKeyword && this.searchKeyword.trim()) {
|
|
|
|
|
+ url += `&keyword=${encodeURIComponent(this.searchKeyword.trim())}`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const [error, res] = await uni.request({
|
|
|
|
|
+ url: url,
|
|
|
|
|
+ method: 'GET'
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ console.error('加载线索数据失败:', error)
|
|
|
|
|
+ this.unregisteredResources = []
|
|
|
|
|
+ this.unregisteredLoading = false
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (res.statusCode === 200 && res.data && res.data.code === 200) {
|
|
|
|
|
+ const pageData = res.data.data
|
|
|
|
|
+ if (pageData && pageData.records) {
|
|
|
|
|
+ // 转换数据格式
|
|
|
|
|
+ const resources = this.convertResourceData(pageData.records)
|
|
|
|
|
|
|
|
- // 根据当前标签加载第一页数据
|
|
|
|
|
- if (this.currentTab === 'resource') {
|
|
|
|
|
- this.registeredPageNum = 1
|
|
|
|
|
- this.loadRegisteredPage(1)
|
|
|
|
|
- console.log('加载资源第一页后 - registeredResources.length:', this.registeredResources.length)
|
|
|
|
|
|
|
+ // 如果是第一页,直接替换;否则追加
|
|
|
|
|
+ if (pageNum === 1) {
|
|
|
|
|
+ this.unregisteredResources = resources
|
|
|
} else {
|
|
} else {
|
|
|
- this.unregisteredPageNum = 1
|
|
|
|
|
- this.loadUnregisteredPage(1)
|
|
|
|
|
- console.log('加载线索第一页后 - unregisteredResources.length:', this.unregisteredResources.length)
|
|
|
|
|
|
|
+ this.unregisteredResources = [...this.unregisteredResources, ...resources]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 保留resources用于兼容(包含所有资源)
|
|
|
|
|
- this.resources = allResources
|
|
|
|
|
|
|
+ // 更新总数(使用后端返回的total)
|
|
|
|
|
+ this.unregisteredTotal = pageData.total || 0
|
|
|
|
|
|
|
|
- console.log('处理后的资源列表 - 已注册:', this.registeredResources.length, '未注册:', this.unregisteredResources.length)
|
|
|
|
|
|
|
+ console.log('loadUnregisteredPage - pageNum:', pageNum, 'loaded:', this.unregisteredResources.length, 'total:', this.unregisteredTotal, 'pageData:', {
|
|
|
|
|
+ total: pageData.total,
|
|
|
|
|
+ size: pageData.size,
|
|
|
|
|
+ current: pageData.current,
|
|
|
|
|
+ pages: pageData.pages,
|
|
|
|
|
+ recordsLength: pageData.records.length
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (pageNum === 1) {
|
|
|
|
|
+ this.unregisteredResources = []
|
|
|
|
|
+ this.unregisteredTotal = 0
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.error('加载线索数据失败,响应:', res.data)
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('加载线索数据异常:', e)
|
|
|
|
|
+ if (this.unregisteredPageNum === 1) {
|
|
|
|
|
+ this.unregisteredResources = []
|
|
|
|
|
+ }
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ this.unregisteredLoading = false
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 加载更多资源(从后端分页加载)
|
|
|
|
|
+ async loadMoreRegistered() {
|
|
|
|
|
+ if (this.registeredLoading) return
|
|
|
|
|
+ // 如果已加载的数据已经达到或超过估算的总数,不再加载
|
|
|
|
|
+ if (this.registeredResources.length >= this.registeredTotal && this.registeredTotal > 0) return
|
|
|
|
|
+
|
|
|
|
|
+ this.registeredPageNum++
|
|
|
|
|
+ await this.loadRegisteredPage(this.registeredPageNum)
|
|
|
|
|
+ },
|
|
|
|
|
+ // 加载更多线索(从后端分页加载)
|
|
|
|
|
+ async loadMoreUnregistered() {
|
|
|
|
|
+ if (this.unregisteredLoading) return
|
|
|
|
|
+ // 如果已加载的数据已经达到或超过估算的总数,不再加载
|
|
|
|
|
+ if (this.unregisteredResources.length >= this.unregisteredTotal && this.unregisteredTotal > 0) return
|
|
|
|
|
+
|
|
|
|
|
+ this.unregisteredPageNum++
|
|
|
|
|
+ await this.loadUnregisteredPage(this.unregisteredPageNum)
|
|
|
|
|
+ },
|
|
|
|
|
+ // 转换资源数据格式(提取公共方法)
|
|
|
|
|
+ convertResourceData(records) {
|
|
|
|
|
+ return records.map(item => {
|
|
|
|
|
+ let requirement = item.mateSelectionCriteria || item.mate_selection_criteria || ''
|
|
|
|
|
+ if (requirement) {
|
|
|
|
|
+ requirement = requirement.trim()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const labels = []
|
|
|
|
|
+ if (item.constellation) {
|
|
|
|
|
+ labels.push(item.constellation)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (item.occupation) {
|
|
|
|
|
+ labels.push(item.occupation)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let avatarUrl = item.avatarUrl || item.avatar_url || item.avatar || ''
|
|
|
|
|
+ if (!avatarUrl || avatarUrl.trim() === '' || avatarUrl === 'null' || avatarUrl === null || avatarUrl === undefined) {
|
|
|
|
|
+ avatarUrl = ''
|
|
|
|
|
+ } else {
|
|
|
|
|
+ avatarUrl = avatarUrl.trim()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let resourceId = item.resourceId || item.resource_id
|
|
|
|
|
+ if (resourceId === null || resourceId === undefined || resourceId === 'undefined' || resourceId === 'null') {
|
|
|
|
|
+ return null
|
|
|
|
|
+ }
|
|
|
|
|
+ resourceId = parseInt(resourceId)
|
|
|
|
|
+ if (isNaN(resourceId) || resourceId <= 0) {
|
|
|
|
|
+ return null
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let isUser = item.isUser !== null && item.isUser !== undefined ? item.isUser :
|
|
|
|
|
+ (item.is_user !== null && item.is_user !== undefined ? item.is_user : 0)
|
|
|
|
|
+ isUser = parseInt(isUser) || 0
|
|
|
|
|
+
|
|
|
|
|
+ let userId = item.userId !== null && item.userId !== undefined ? item.userId :
|
|
|
|
|
+ (item.user_id !== null && item.user_id !== undefined ? item.user_id : null)
|
|
|
|
|
+ if (userId !== null && userId !== undefined) {
|
|
|
|
|
+ userId = parseInt(userId)
|
|
|
|
|
+ if (isNaN(userId) || userId <= 0) {
|
|
|
|
|
+ userId = null
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ let isMatch = item.isMatch !== null && item.isMatch !== undefined ? item.isMatch :
|
|
|
|
|
+ (item.is_match !== null && item.is_match !== undefined ? item.is_match : 0)
|
|
|
|
|
+ isMatch = parseInt(isMatch) || 0
|
|
|
|
|
+
|
|
|
|
|
+ let resourceTags = []
|
|
|
|
|
+ if (item.tags && Array.isArray(item.tags) && item.tags.length > 0) {
|
|
|
|
|
+ resourceTags = item.tags
|
|
|
|
|
+ } else if (labels && labels.length > 0) {
|
|
|
|
|
+ resourceTags = labels
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: resourceId,
|
|
|
|
|
+ resourceId: resourceId,
|
|
|
|
|
+ resource_id: resourceId,
|
|
|
|
|
+ avatar: avatarUrl,
|
|
|
|
|
+ name: item.name || '',
|
|
|
|
|
+ gender: item.gender === 1 ? '男' : item.gender === 2 ? '女' : '未知',
|
|
|
|
|
+ status: item.status !== undefined && item.status !== null ? item.status : 0,
|
|
|
|
|
+ isUser: isUser,
|
|
|
|
|
+ userId: userId,
|
|
|
|
|
+ isMatch: isMatch,
|
|
|
|
|
+ isPlus: false,
|
|
|
|
|
+ labels: resourceTags,
|
|
|
|
|
+ requirement: requirement || '暂无要求',
|
|
|
|
|
+ contact: item.phone ? item.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') : '',
|
|
|
|
|
+ originalPhone: item.phone || '',
|
|
|
|
|
+ isQuality: false
|
|
|
|
|
+ }
|
|
|
|
|
+ }).filter(item => item !== null)
|
|
|
|
|
+ },
|
|
|
|
|
+ // 加载我的资源数据(改为分页加载)
|
|
|
|
|
+ async loadMyResources() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 根据当前标签加载对应数据
|
|
|
|
|
+ if (this.currentTab === 'resource') {
|
|
|
|
|
+ // 重置资源列表
|
|
|
|
|
+ this.registeredPageNum = 1
|
|
|
|
|
+ await this.loadRegisteredPage(1)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 重置线索列表
|
|
|
|
|
+ this.unregisteredPageNum = 1
|
|
|
|
|
+ await this.loadUnregisteredPage(1)
|
|
|
|
|
+ }
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error('加载资源数据失败:', e)
|
|
console.error('加载资源数据失败:', e)
|
|
|
}
|
|
}
|
|
@@ -1038,25 +1071,15 @@ export default {
|
|
|
!originalUrl.includes('placeholder') &&
|
|
!originalUrl.includes('placeholder') &&
|
|
|
!originalUrl.includes('default') &&
|
|
!originalUrl.includes('default') &&
|
|
|
!originalUrl.includes('via.placeholder')) {
|
|
!originalUrl.includes('via.placeholder')) {
|
|
|
- // 根据resourceId在全部数据中找到对应的资源并更新
|
|
|
|
|
|
|
+ // 根据resourceId在当前显示数据中找到对应的资源并更新
|
|
|
console.log('图片加载失败,将URL设置为空,显示CSS默认背景')
|
|
console.log('图片加载失败,将URL设置为空,显示CSS默认背景')
|
|
|
if (type === 'registered') {
|
|
if (type === 'registered') {
|
|
|
- // 更新全部数据
|
|
|
|
|
- const allListIndex = this.allRegisteredResources.findIndex(item => item.id === resourceId)
|
|
|
|
|
- if (allListIndex !== -1) {
|
|
|
|
|
- this.$set(this.allRegisteredResources[allListIndex], 'avatar', '')
|
|
|
|
|
- }
|
|
|
|
|
// 更新显示数据
|
|
// 更新显示数据
|
|
|
const displayListIndex = this.registeredResources.findIndex(item => item.id === resourceId)
|
|
const displayListIndex = this.registeredResources.findIndex(item => item.id === resourceId)
|
|
|
if (displayListIndex !== -1) {
|
|
if (displayListIndex !== -1) {
|
|
|
this.$set(this.registeredResources[displayListIndex], 'avatar', '')
|
|
this.$set(this.registeredResources[displayListIndex], 'avatar', '')
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- // 更新全部数据
|
|
|
|
|
- const allListIndex = this.allUnregisteredResources.findIndex(item => item.id === resourceId)
|
|
|
|
|
- if (allListIndex !== -1) {
|
|
|
|
|
- this.$set(this.allUnregisteredResources[allListIndex], 'avatar', '')
|
|
|
|
|
- }
|
|
|
|
|
// 更新显示数据
|
|
// 更新显示数据
|
|
|
const displayListIndex = this.unregisteredResources.findIndex(item => item.id === resourceId)
|
|
const displayListIndex = this.unregisteredResources.findIndex(item => item.id === resourceId)
|
|
|
if (displayListIndex !== -1) {
|
|
if (displayListIndex !== -1) {
|
|
@@ -1223,7 +1246,9 @@ export default {
|
|
|
|
|
|
|
|
.content {
|
|
.content {
|
|
|
flex: 1;
|
|
flex: 1;
|
|
|
|
|
+ height: 0; /* 配合 flex: 1 使用,确保 scroll-view 有明确高度 */
|
|
|
padding: 0 20rpx 140rpx;
|
|
padding: 0 20rpx 140rpx;
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* 资源分组 */
|
|
/* 资源分组 */
|