Prechádzať zdrojové kódy

成功案例 时间线 和 幸福瞬间

YH_0525 1 mesiac pred
rodič
commit
989bb5033d

+ 26 - 11
LiangZhiYUMao/pages/index/index.vue

@@ -102,7 +102,7 @@
 							</view>
 							<view class="activity-info-static">
 								<view class="activity-name-static">{{ activity.name }}</view>
-								<view class="activity-time-static">{{ formatActivityTime(activity.startTime) }}</view>
+								<view class="activity-time-static">{{ formatActivityTime(activity.startTime, activity.endTime) }}</view>
 							</view>
 						</view>
 						<!-- 第二组活动(用于无缝滚动) -->
@@ -116,7 +116,7 @@
 							</view>
 							<view class="activity-info-static">
 								<view class="activity-name-static">{{ activity.name }}</view>
-								<view class="activity-time-static">{{ formatActivityTime(activity.startTime) }}</view>
+								<view class="activity-time-static">{{ formatActivityTime(activity.startTime, activity.endTime) }}</view>
 							</view>
 						</view>
 					</view>
@@ -459,6 +459,7 @@
 							coverImage: this.ensureRomanticCover(rawCover, index),
 							name: activity.name || activity.title || '',
 							startTime: activity.startTime || activity.start_time || activity.startDate || '',
+							endTime: activity.endTime || activity.end_time || activity.endDate || '',
 							status: activity.status || 0
 						}})
 					} else {
@@ -534,16 +535,30 @@
 				}
 			},
 
-			// 格式化活动时间
-			formatActivityTime(timeStr) {
-				if (!timeStr) return '时间待定'
+			// 格式化活动时间(支持开始和结束时间)
+			formatActivityTime(startTime, endTime) {
+				if (!startTime) return '时间待定'
 				try {
-					const date = new Date(timeStr)
-					const month = date.getMonth() + 1
-					const day = date.getDate()
-					const hour = date.getHours()
-					const minute = date.getMinutes()
-					return `${month}月${day}日 ${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`
+					const start = new Date(startTime)
+					const startMonth = start.getMonth() + 1
+					const startDay = start.getDate()
+					const startHour = start.getHours().toString().padStart(2, '0')
+					const startMinute = start.getMinutes().toString().padStart(2, '0')
+					
+					let timeStr = `${startMonth}月${startDay}日 ${startHour}:${startMinute}`
+					
+					// 如果有结束时间,添加结束时间
+					if (endTime) {
+						const end = new Date(endTime)
+						const endMonth = end.getMonth() + 1
+						const endDay = end.getDate()
+						const endHour = end.getHours().toString().padStart(2, '0')
+						const endMinute = end.getMinutes().toString().padStart(2, '0')
+						
+						timeStr += ` - ${endMonth}月${endDay}日 ${endHour}:${endMinute}`
+					}
+					
+					return timeStr
 				} catch (error) {
 					return '时间待定'
 				}

+ 43 - 8
LiangZhiYUMao/pages/success-case/detail.vue

@@ -99,7 +99,12 @@
 			if (options.caseNo) {
 				this.caseNo = options.caseNo
 				this.loadCaseDetail()
-				this.loadTimeline()
+			} else {
+				console.warn('未提供案例编号')
+				uni.showToast({
+					title: '参数错误',
+					icon: 'none'
+				})
 			}
 		},
 
@@ -109,11 +114,30 @@
 				try {
 					const data = await api.successCase.getDetail(this.caseNo)
 					if (data) {
-						this.caseDetail = data
-						// 如果有照片数据
-						if (data.images) {
-							this.images = data.images
+						// 处理字段映射,支持驼峰和下划线命名
+						this.caseDetail = {
+							...data,
+							maleUserNickname: data.maleUserNickname || data.male_user_nickname || '先生',
+							femaleUserNickname: data.femaleUserNickname || data.female_user_nickname || '女士',
+							imageUrl: data.imageUrl || data.image_url || DEFAULT_IMAGES.couple,
+							quote: data.quote || '我们的故事',
+							story: data.story || '这是一段美好的爱情故事...',
+							marriageDate: data.marriageDate || data.marriage_date || '',
+							matchmakerName: data.matchmakerName || data.matchmaker_name || ''
+						}
+						console.log('案例详情加载成功:', this.caseDetail)
+						
+						// 如果有照片数据,处理字段映射
+						if (data.images && data.images.length > 0) {
+							this.images = data.images.map(img => ({
+								...img,
+								imageUrl: img.imageUrl || img.image_url || DEFAULT_IMAGES.couple
+							}))
+							console.log('照片加载成功:', this.images)
 						}
+						
+						// 案例详情加载成功后,再加载时间线
+						this.loadTimeline()
 					}
 				} catch (error) {
 					console.error('加载案例详情失败:', error)
@@ -128,11 +152,22 @@
 			async loadTimeline() {
 				try {
 					const data = await api.successCase.getTimeline(this.caseNo)
-					if (data) {
-						this.timeline = data
+					if (data && data.length > 0) {
+						// 处理时间线数据的字段映射
+						this.timeline = data.map(item => ({
+							...item,
+							eventDate: item.eventDate || item.event_date || '',
+							eventDescription: item.eventDescription || item.event_description || ''
+						}))
+						console.log('时间线加载成功:', this.timeline)
+					} else {
+						console.log('该案例暂无时间线数据')
+						this.timeline = []
 					}
 				} catch (error) {
-					console.error('加载时间线失败:', error)
+					console.warn('加载时间线失败:', error)
+					// 时间线加载失败不影响主要内容展示,只记录日志
+					this.timeline = []
 				}
 			},