detail.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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="images[0].imageUrl" 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. // 如果有照片数据,处理字段映射
  117. if (data.images && data.images.length > 0) {
  118. this.images = data.images.map(img => ({
  119. ...img,
  120. imageUrl: img.imageUrl || img.image_url || DEFAULT_IMAGES.couple
  121. }))
  122. }
  123. // 案例详情加载成功后,再加载时间线
  124. this.loadTimeline()
  125. }
  126. } catch (error) {
  127. console.error('加载案例详情失败:', error)
  128. uni.showToast({
  129. title: '加载失败',
  130. icon: 'none'
  131. })
  132. }
  133. },
  134. // 加载时间线
  135. async loadTimeline() {
  136. try {
  137. const data = await api.successCase.getTimeline(this.caseNo)
  138. if (data && data.length > 0) {
  139. // 处理时间线数据的字段映射
  140. this.timeline = data.map(item => ({
  141. ...item,
  142. eventDate: item.eventDate || item.event_date || '',
  143. eventDescription: item.eventDescription || item.event_description || ''
  144. }))
  145. } else {
  146. this.timeline = []
  147. }
  148. } catch (error) {
  149. console.warn('加载时间线失败:', error)
  150. // 时间线加载失败不影响主要内容展示,只记录日志
  151. this.timeline = []
  152. }
  153. },
  154. // 格式化日期
  155. formatDate(dateStr) {
  156. if (!dateStr) return '未知日期'
  157. const date = this.$util && this.$util.parseDate ? this.$util.parseDate(dateStr) : new Date(String(dateStr).replace(/-/g,'/'))
  158. const year = date.getFullYear()
  159. const month = date.getMonth() + 1
  160. const day = date.getDate()
  161. return `${year}年${month}月${day}日`
  162. },
  163. // 预览图片
  164. previewImage(index) {
  165. const urls = this.images.map(img => img.imageUrl)
  166. uni.previewImage({
  167. urls: urls,
  168. current: index
  169. })
  170. },
  171. // 返回
  172. goBack() {
  173. uni.navigateBack()
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. .case-detail-page {
  180. min-height: 100vh;
  181. background-color: #FFF9F9;
  182. padding-top: 90rpx;
  183. padding-bottom: 40rpx;
  184. }
  185. /* 自定义导航栏 */
  186. .custom-navbar {
  187. position: fixed;
  188. top: 0;
  189. left: 0;
  190. right: 0;
  191. height: 90rpx;
  192. display: flex;
  193. align-items: center;
  194. justify-content: space-between;
  195. padding: 0 20rpx;
  196. background-color: #E91E63;
  197. z-index: 999;
  198. .navbar-left,
  199. .navbar-right {
  200. width: 80rpx;
  201. }
  202. .back-icon {
  203. font-size: 40rpx;
  204. color: #FFFFFF;
  205. font-weight: bold;
  206. }
  207. .navbar-title {
  208. flex: 1;
  209. text-align: center;
  210. font-size: 32rpx;
  211. font-weight: bold;
  212. color: #FFFFFF;
  213. }
  214. }
  215. /* 案例封面 */
  216. .case-cover {
  217. position: relative;
  218. width: 100%;
  219. height: 500rpx;
  220. .cover-image {
  221. width: 100%;
  222. height: 100%;
  223. }
  224. .cover-mask {
  225. position: absolute;
  226. top: 0;
  227. left: 0;
  228. right: 0;
  229. bottom: 0;
  230. background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent);
  231. .success-badge {
  232. position: absolute;
  233. top: 30rpx;
  234. right: 30rpx;
  235. width: 70rpx;
  236. height: 70rpx;
  237. background-color: #4CAF50;
  238. border-radius: 50%;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.3);
  243. .badge-icon {
  244. color: #FFFFFF;
  245. font-size: 40rpx;
  246. font-weight: bold;
  247. }
  248. }
  249. }
  250. }
  251. /* 案例内容 */
  252. .case-content {
  253. padding: 30rpx;
  254. background-color: #FFFFFF;
  255. margin: 20rpx;
  256. border-radius: 20rpx;
  257. .couple-names {
  258. font-size: 40rpx;
  259. font-weight: bold;
  260. color: #333333;
  261. text-align: center;
  262. margin-bottom: 30rpx;
  263. }
  264. .quote-section {
  265. background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
  266. padding: 30rpx;
  267. border-radius: 15rpx;
  268. margin-bottom: 30rpx;
  269. text-align: center;
  270. position: relative;
  271. .quote-icon {
  272. font-size: 50rpx;
  273. color: #E91E63;
  274. opacity: 0.3;
  275. }
  276. .quote-text {
  277. font-size: 28rpx;
  278. color: #666666;
  279. line-height: 1.8;
  280. font-style: italic;
  281. padding: 0 20rpx;
  282. }
  283. }
  284. .info-section {
  285. .info-item {
  286. display: flex;
  287. align-items: center;
  288. margin-bottom: 20rpx;
  289. font-size: 28rpx;
  290. .info-icon {
  291. font-size: 32rpx;
  292. margin-right: 10rpx;
  293. }
  294. .info-label {
  295. color: #666666;
  296. }
  297. .info-value {
  298. color: #333333;
  299. flex: 1;
  300. }
  301. }
  302. }
  303. .divider {
  304. height: 1rpx;
  305. background-color: #F0F0F0;
  306. margin: 30rpx 0;
  307. }
  308. .section-title {
  309. font-size: 32rpx;
  310. font-weight: bold;
  311. color: #333333;
  312. margin-bottom: 20rpx;
  313. }
  314. .story-text {
  315. font-size: 28rpx;
  316. color: #666666;
  317. line-height: 2;
  318. white-space: pre-wrap;
  319. }
  320. /* 时间线 */
  321. .timeline-section {
  322. .timeline-list {
  323. padding-left: 20rpx;
  324. .timeline-item {
  325. position: relative;
  326. padding-left: 50rpx;
  327. padding-bottom: 40rpx;
  328. &:last-child {
  329. padding-bottom: 0;
  330. }
  331. &:not(:last-child)::before {
  332. content: '';
  333. position: absolute;
  334. left: 15rpx;
  335. top: 30rpx;
  336. bottom: 0;
  337. width: 2rpx;
  338. background-color: #FFD4E5;
  339. }
  340. .timeline-dot {
  341. position: absolute;
  342. left: 0;
  343. top: 5rpx;
  344. width: 30rpx;
  345. height: 30rpx;
  346. background-color: #E91E63;
  347. border-radius: 50%;
  348. border: 5rpx solid #FFE5EE;
  349. }
  350. .timeline-content {
  351. .timeline-date {
  352. font-size: 24rpx;
  353. color: #999999;
  354. margin-bottom: 10rpx;
  355. }
  356. .timeline-event {
  357. font-size: 28rpx;
  358. color: #333333;
  359. line-height: 1.6;
  360. }
  361. }
  362. }
  363. }
  364. }
  365. /* 照片墙 */
  366. .photos-section {
  367. .photos-grid {
  368. display: grid;
  369. grid-template-columns: repeat(3, 1fr);
  370. gap: 15rpx;
  371. .photo-item {
  372. width: 100%;
  373. height: 200rpx;
  374. border-radius: 10rpx;
  375. background-color: #F5F5F5;
  376. }
  377. }
  378. }
  379. }
  380. </style>