detail.vue 8.2 KB

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