detail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <view class="case-detail-page">
  3. <!-- 自定义导航栏 -->
  4. <view class="custom-navbar">
  5. <view class="navbar-left" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <view class="navbar-title">成功案例详情</view>
  9. <view class="navbar-right"></view>
  10. </view>
  11. <!-- 案例封面 -->
  12. <view class="case-cover">
  13. <image src="https://img.zcool.cn/community/01c8f15cd8e8c6a801219c779e8c84.jpg" class="cover-image" mode="aspectFill"></image>
  14. <view class="cover-mask">
  15. <view class="success-badge">
  16. <text class="badge-icon">✓</text>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 案例信息 -->
  21. <view class="case-content">
  22. <view class="couple-names">{{ caseDetail.maleUserNickname }} & {{ caseDetail.femaleUserNickname }}</view>
  23. <view class="quote-section">
  24. <text class="quote-icon">"</text>
  25. <text class="quote-text">{{ caseDetail.quote || '我们的故事' }}</text>
  26. <text class="quote-icon">"</text>
  27. </view>
  28. <view class="info-section">
  29. <view class="info-item">
  30. <text class="info-icon">💑</text>
  31. <text class="info-label">结婚日期:</text>
  32. <text class="info-value">{{ formatDate(caseDetail.marriageDate) }}</text>
  33. </view>
  34. <view class="info-item" v-if="caseDetail.matchmakerName">
  35. <text class="info-icon">👩‍❤️‍👨</text>
  36. <text class="info-label">红娘:</text>
  37. <text class="info-value">{{ caseDetail.matchmakerName }}</text>
  38. </view>
  39. </view>
  40. <view class="divider"></view>
  41. <view class="story-section">
  42. <view class="section-title">💕 他们的爱情故事</view>
  43. <view class="story-text">{{ caseDetail.story || '这是一段美好的爱情故事...' }}</view>
  44. </view>
  45. <!-- 时间线 -->
  46. <view class="divider"></view>
  47. <view class="timeline-section" v-if="timeline && timeline.length > 0">
  48. <view class="section-title">📅 爱情时间线</view>
  49. <view class="timeline-list">
  50. <view class="timeline-item" v-for="(item, index) in timeline" :key="index">
  51. <view class="timeline-dot"></view>
  52. <view class="timeline-content">
  53. <view class="timeline-date">{{ formatDate(item.eventDate) }}</view>
  54. <view class="timeline-event">{{ item.eventDescription }}</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- 照片墙 -->
  60. <view class="divider" v-if="images && images.length > 0"></view>
  61. <view class="photos-section" v-if="images && images.length > 0">
  62. <view class="section-title">📷 幸福瞬间</view>
  63. <view class="photos-grid">
  64. <image v-for="(img, index) in images" :key="index" :src="img.imageUrl"
  65. class="photo-item" mode="aspectFill" @click="previewImage(index)"></image>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import api from '@/utils/api.js'
  73. import { DEFAULT_IMAGES } from '@/config/index.js'
  74. export default {
  75. data() {
  76. return {
  77. caseNo: null,
  78. caseDetail: {
  79. maleUserNickname: '加载中',
  80. femaleUserNickname: '...'
  81. },
  82. timeline: [],
  83. images: [],
  84. DEFAULT_IMAGES
  85. }
  86. },
  87. onLoad(options) {
  88. if (options.caseNo) {
  89. this.caseNo = options.caseNo
  90. this.loadCaseDetail()
  91. } else {
  92. console.warn('未提供案例编号')
  93. uni.showToast({
  94. title: '参数错误',
  95. icon: 'none'
  96. })
  97. }
  98. },
  99. methods: {
  100. // 加载案例详情
  101. async loadCaseDetail() {
  102. try {
  103. const data = await api.successCase.getDetail(this.caseNo)
  104. if (data) {
  105. // 处理字段映射,支持驼峰和下划线命名
  106. this.caseDetail = {
  107. ...data,
  108. maleUserNickname: data.maleUserNickname || data.male_user_nickname || '先生',
  109. femaleUserNickname: data.femaleUserNickname || data.female_user_nickname || '女士',
  110. imageUrl: data.imageUrl || data.image_url || DEFAULT_IMAGES.couple,
  111. quote: data.quote || '我们的故事',
  112. story: data.story || '这是一段美好的爱情故事...',
  113. marriageDate: data.marriageDate || data.marriage_date || '',
  114. matchmakerName: data.matchmakerName || data.matchmaker_name || ''
  115. }
  116. console.log('案例详情加载成功:', this.caseDetail)
  117. // 如果有照片数据,处理字段映射
  118. if (data.images && data.images.length > 0) {
  119. this.images = data.images.map(img => ({
  120. ...img,
  121. imageUrl: img.imageUrl || img.image_url || DEFAULT_IMAGES.couple
  122. }))
  123. console.log('照片加载成功:', this.images)
  124. }
  125. // 案例详情加载成功后,再加载时间线
  126. this.loadTimeline()
  127. }
  128. } catch (error) {
  129. console.error('加载案例详情失败:', error)
  130. uni.showToast({
  131. title: '加载失败',
  132. icon: 'none'
  133. })
  134. }
  135. },
  136. // 加载时间线
  137. async loadTimeline() {
  138. try {
  139. const data = await api.successCase.getTimeline(this.caseNo)
  140. if (data && data.length > 0) {
  141. // 处理时间线数据的字段映射
  142. this.timeline = data.map(item => ({
  143. ...item,
  144. eventDate: item.eventDate || item.event_date || '',
  145. eventDescription: item.eventDescription || item.event_description || ''
  146. }))
  147. console.log('时间线加载成功:', this.timeline)
  148. } else {
  149. console.log('该案例暂无时间线数据')
  150. this.timeline = []
  151. }
  152. } catch (error) {
  153. console.warn('加载时间线失败:', error)
  154. // 时间线加载失败不影响主要内容展示,只记录日志
  155. this.timeline = []
  156. }
  157. },
  158. // 格式化日期
  159. formatDate(dateStr) {
  160. if (!dateStr) return '未知日期'
  161. const date = this.$util && this.$util.parseDate ? this.$util.parseDate(dateStr) : new Date(String(dateStr).replace(/-/g,'/'))
  162. const year = date.getFullYear()
  163. const month = date.getMonth() + 1
  164. const day = date.getDate()
  165. return `${year}年${month}月${day}日`
  166. },
  167. // 预览图片
  168. previewImage(index) {
  169. const urls = this.images.map(img => img.imageUrl)
  170. uni.previewImage({
  171. urls: urls,
  172. current: index
  173. })
  174. },
  175. // 返回
  176. goBack() {
  177. uni.navigateBack()
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. .case-detail-page {
  184. min-height: 100vh;
  185. background-color: #FFF9F9;
  186. padding-top: 90rpx;
  187. padding-bottom: 40rpx;
  188. }
  189. /* 自定义导航栏 */
  190. .custom-navbar {
  191. position: fixed;
  192. top: 0;
  193. left: 0;
  194. right: 0;
  195. height: 90rpx;
  196. display: flex;
  197. align-items: center;
  198. justify-content: space-between;
  199. padding: 0 20rpx;
  200. background-color: #E91E63;
  201. z-index: 999;
  202. .navbar-left,
  203. .navbar-right {
  204. width: 80rpx;
  205. }
  206. .back-icon {
  207. font-size: 40rpx;
  208. color: #FFFFFF;
  209. font-weight: bold;
  210. }
  211. .navbar-title {
  212. flex: 1;
  213. text-align: center;
  214. font-size: 32rpx;
  215. font-weight: bold;
  216. color: #FFFFFF;
  217. }
  218. }
  219. /* 案例封面 */
  220. .case-cover {
  221. position: relative;
  222. width: 100%;
  223. height: 500rpx;
  224. .cover-image {
  225. width: 100%;
  226. height: 100%;
  227. }
  228. .cover-mask {
  229. position: absolute;
  230. top: 0;
  231. left: 0;
  232. right: 0;
  233. bottom: 0;
  234. background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent);
  235. .success-badge {
  236. position: absolute;
  237. top: 30rpx;
  238. right: 30rpx;
  239. width: 70rpx;
  240. height: 70rpx;
  241. background-color: #4CAF50;
  242. border-radius: 50%;
  243. display: flex;
  244. align-items: center;
  245. justify-content: center;
  246. box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.3);
  247. .badge-icon {
  248. color: #FFFFFF;
  249. font-size: 40rpx;
  250. font-weight: bold;
  251. }
  252. }
  253. }
  254. }
  255. /* 案例内容 */
  256. .case-content {
  257. padding: 30rpx;
  258. background-color: #FFFFFF;
  259. margin: 20rpx;
  260. border-radius: 20rpx;
  261. .couple-names {
  262. font-size: 40rpx;
  263. font-weight: bold;
  264. color: #333333;
  265. text-align: center;
  266. margin-bottom: 30rpx;
  267. }
  268. .quote-section {
  269. background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
  270. padding: 30rpx;
  271. border-radius: 15rpx;
  272. margin-bottom: 30rpx;
  273. text-align: center;
  274. position: relative;
  275. .quote-icon {
  276. font-size: 50rpx;
  277. color: #E91E63;
  278. opacity: 0.3;
  279. }
  280. .quote-text {
  281. font-size: 28rpx;
  282. color: #666666;
  283. line-height: 1.8;
  284. font-style: italic;
  285. padding: 0 20rpx;
  286. }
  287. }
  288. .info-section {
  289. .info-item {
  290. display: flex;
  291. align-items: center;
  292. margin-bottom: 20rpx;
  293. font-size: 28rpx;
  294. .info-icon {
  295. font-size: 32rpx;
  296. margin-right: 10rpx;
  297. }
  298. .info-label {
  299. color: #666666;
  300. }
  301. .info-value {
  302. color: #333333;
  303. flex: 1;
  304. }
  305. }
  306. }
  307. .divider {
  308. height: 1rpx;
  309. background-color: #F0F0F0;
  310. margin: 30rpx 0;
  311. }
  312. .section-title {
  313. font-size: 32rpx;
  314. font-weight: bold;
  315. color: #333333;
  316. margin-bottom: 20rpx;
  317. }
  318. .story-text {
  319. font-size: 28rpx;
  320. color: #666666;
  321. line-height: 2;
  322. white-space: pre-wrap;
  323. }
  324. /* 时间线 */
  325. .timeline-section {
  326. .timeline-list {
  327. padding-left: 20rpx;
  328. .timeline-item {
  329. position: relative;
  330. padding-left: 50rpx;
  331. padding-bottom: 40rpx;
  332. &:last-child {
  333. padding-bottom: 0;
  334. }
  335. &:not(:last-child)::before {
  336. content: '';
  337. position: absolute;
  338. left: 15rpx;
  339. top: 30rpx;
  340. bottom: 0;
  341. width: 2rpx;
  342. background-color: #FFD4E5;
  343. }
  344. .timeline-dot {
  345. position: absolute;
  346. left: 0;
  347. top: 5rpx;
  348. width: 30rpx;
  349. height: 30rpx;
  350. background-color: #E91E63;
  351. border-radius: 50%;
  352. border: 5rpx solid #FFE5EE;
  353. }
  354. .timeline-content {
  355. .timeline-date {
  356. font-size: 24rpx;
  357. color: #999999;
  358. margin-bottom: 10rpx;
  359. }
  360. .timeline-event {
  361. font-size: 28rpx;
  362. color: #333333;
  363. line-height: 1.6;
  364. }
  365. }
  366. }
  367. }
  368. }
  369. /* 照片墙 */
  370. .photos-section {
  371. .photos-grid {
  372. display: grid;
  373. grid-template-columns: repeat(3, 1fr);
  374. gap: 15rpx;
  375. .photo-item {
  376. width: 100%;
  377. height: 200rpx;
  378. border-radius: 10rpx;
  379. background-color: #F5F5F5;
  380. }
  381. }
  382. }
  383. }
  384. </style>