Browse Source

客户详情页修改

yuxy 1 tháng trước cách đây
mục cha
commit
caefe0d646
1 tập tin đã thay đổi với 48 bổ sung6 xóa
  1. 48 6
      LiangZhiYUMao/pages/matchmaker-workbench/my-resources.vue

+ 48 - 6
LiangZhiYUMao/pages/matchmaker-workbench/my-resources.vue

@@ -36,7 +36,7 @@
 				<text class="section-count">({{ registeredTotal }})</text>
 			</view>
 			<view class="resource-list-container">
-				<view class="resource-item" v-for="(item, index) in getRegisteredDisplayData" :key="getRegisteredItemKey(item, index)" @click="handleResourceClick(item)">
+				<view class="resource-item" v-for="(item, index) in getRegisteredDisplayData" :key="getRegisteredItemKey(item, index)" @click="handleResourceClickSafe(item, index)">
 				<!-- 右上角选中图标 -->
 				<view class="select-icon">✓-</view>
 				
@@ -109,7 +109,7 @@
 				<text class="section-count">({{ unregisteredTotal }})</text>
 			</view>
 			<view class="resource-list-container">
-				<view class="resource-item" v-for="(item, index) in getUnregisteredDisplayData" :key="getUnregisteredItemKey(item, index)" @click="handleResourceClick(item)">
+				<view class="resource-item" v-for="(item, index) in getUnregisteredDisplayData" :key="getUnregisteredItemKey(item, index)" @click="handleResourceClickSafe(item, index)">
 				<!-- 右上角选中图标 -->
 				<view class="select-icon">✓-</view>
 				
@@ -467,8 +467,8 @@ export default {
 					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)
+							// 转换数据格式,并过滤掉无效数据(null值)
+							const resources = this.convertResourceData(pageData.records).filter(item => item !== null && item !== undefined)
 							
 							// 如果是第一页,直接替换;否则追加
 							if (pageNum === 1) {
@@ -557,8 +557,8 @@ export default {
 					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)
+							// 转换数据格式,并过滤掉无效数据(null值)
+							const resources = this.convertResourceData(pageData.records).filter(item => item !== null && item !== undefined)
 							
 							// 如果是第一页,直接替换;否则追加
 							if (pageNum === 1) {
@@ -875,13 +875,51 @@ export default {
 				url: `/pages/matchmaker-workbench/client-detail?resourceId=${id}`
 			})
 		},
+		// 资源项点击事件(安全包装方法)
+		handleResourceClickSafe(item, index) {
+			// 如果 item 无效,尝试从数组中获取
+			if (!item || item === null || item === undefined) {
+				console.warn('handleResourceClickSafe: item 为空,尝试从数组中获取, index:', index)
+				// 根据当前标签获取对应的数据数组
+				const dataArray = this.currentTab === 'resource' ? this.getRegisteredDisplayData : this.getUnregisteredDisplayData
+				if (dataArray && Array.isArray(dataArray) && index >= 0 && index < dataArray.length) {
+					item = dataArray[index]
+				}
+			}
+			
+			// 如果仍然无效,直接返回
+			if (!item || item === null || item === undefined) {
+				console.error('handleResourceClickSafe: 无法获取有效的 item, index:', index)
+				return
+			}
+			
+			// 调用实际的点击处理方法
+			this.handleResourceClick(item)
+		},
 		// 资源项点击事件
 		handleResourceClick(item) {
+			// 检查 item 是否存在
+			if (!item || item === null || item === undefined) {
+				console.error('handleResourceClick: item 为空', item)
+				return
+			}
+			
 			console.log('=== 点击资源项 ===')
 			console.log('item对象:', JSON.stringify(item, null, 2))
 			console.log('item.id:', item.id)
 			console.log('item.isUser:', item.isUser)
 			
+			// 检查 item.id 是否存在
+			if (!item.id && item.id !== 0) {
+				console.error('handleResourceClick: item.id 无效', item)
+				uni.showToast({
+					title: '资源ID无效',
+					icon: 'none',
+					duration: 2000
+				})
+				return
+			}
+			
 			// 判断是否为已注册用户(isUser === 1 且 userId !== null)
 			if (item.isUser === 1 && item.userId !== null && item.userId !== undefined) {
 				// 已注册,跳转到客户详情页面
@@ -894,6 +932,10 @@ export default {
 					},
 					fail: (err) => {
 						console.error('跳转失败:', err)
+						uni.showToast({
+							title: '跳转失败,请重试',
+							icon: 'none'
+						})
 					}
 				})
 			} else {