detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <view class="matchmaker-detail-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="nav-bar">
  5. <view class="nav-left" @click="goBack">
  6. <text class="back-icon">←</text>
  7. </view>
  8. <view class="nav-title">红娘详情</view>
  9. <view class="nav-right"></view>
  10. </view>
  11. <scroll-view class="content-scroll" scroll-y v-if="matchmaker">
  12. <!-- 头部卡片 -->
  13. <view class="header-card">
  14. <view class="avatar-wrapper">
  15. <image :src="getAvatarUrl(matchmaker.avatarUrl)"
  16. class="avatar"
  17. mode="aspectFill"
  18. @error="handleImageError"
  19. @load="handleImageLoad">
  20. </image>
  21. <view class="avatar-placeholder" v-if="shouldShowPlaceholder()">
  22. <text class="placeholder-icon">👤</text>
  23. </view>
  24. <view class="level-badge" :class="'level-' + (matchmaker.level || 1)">
  25. {{ matchmaker.levelName || '青铜红娘' }}
  26. </view>
  27. </view>
  28. <view class="basic-info">
  29. <view class="name-row">
  30. <text class="name">{{ matchmaker.realName }}</text>
  31. <view class="gender-icon">
  32. {{ matchmaker.gender === 1 ? '♂' : '♀' }}
  33. </view>
  34. </view>
  35. <view class="type-tag" :class="matchmaker.matchmakerType === 2 ? 'formal' : 'parttime'">
  36. {{ matchmaker.typeName || '兼职红娘' }}
  37. </view>
  38. <view class="stats-grid">
  39. <view class="stats-item">
  40. <text class="stats-value">{{ matchmaker.successCouples || 0 }}</text>
  41. <text class="stats-label">成功撮合</text>
  42. </view>
  43. <view class="stats-divider"></view>
  44. <view class="stats-item">
  45. <text class="stats-value">{{ matchmaker.age || '--' }}</text>
  46. <text class="stats-label">年龄</text>
  47. </view>
  48. <view class="stats-divider"></view>
  49. <view class="stats-item">
  50. <text class="stats-value">{{ getLevelText(matchmaker.level) }}</text>
  51. <text class="stats-label">等级</text>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 联系方式卡片 -->
  57. <view class="section-card">
  58. <view class="section-title">
  59. <text class="title-icon">📞</text>
  60. <text class="title-text">联系方式</text>
  61. </view>
  62. <view class="contact-list">
  63. <view class="contact-item" @click="callPhone(matchmaker.phone)">
  64. <view class="contact-left">
  65. <text class="contact-icon">📱</text>
  66. <text class="contact-label">手机号码</text>
  67. </view>
  68. <view class="contact-right">
  69. <text class="contact-value">{{ matchmaker.phone }}</text>
  70. <text class="contact-arrow">→</text>
  71. </view>
  72. </view>
  73. <view class="contact-item" v-if="matchmaker.email">
  74. <view class="contact-left">
  75. <text class="contact-icon">📧</text>
  76. <text class="contact-label">电子邮箱</text>
  77. </view>
  78. <view class="contact-right">
  79. <text class="contact-value">{{ matchmaker.email }}</text>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- 地址信息卡片 -->
  85. <view class="section-card" v-if="matchmaker.fullAddress">
  86. <view class="section-title">
  87. <text class="title-icon">📍</text>
  88. <text class="title-text">服务地区</text>
  89. </view>
  90. <view class="address-content">
  91. <text class="address-text">{{ matchmaker.fullAddress }}</text>
  92. </view>
  93. </view>
  94. <!-- 个人简介卡片 -->
  95. <view class="section-card" v-if="matchmaker.profile">
  96. <view class="section-title">
  97. <text class="title-icon">✏️</text>
  98. <text class="title-text">个人简介</text>
  99. </view>
  100. <view class="profile-content">
  101. <text class="profile-text">{{ matchmaker.profile }}</text>
  102. </view>
  103. </view>
  104. <!-- 服务优势卡片 -->
  105. <view class="section-card">
  106. <view class="section-title">
  107. <text class="title-icon">⭐</text>
  108. <text class="title-text">服务优势</text>
  109. </view>
  110. <view class="advantage-list">
  111. <view class="advantage-item">
  112. <text class="advantage-icon">✓</text>
  113. <text class="advantage-text">专业婚恋指导</text>
  114. </view>
  115. <view class="advantage-item">
  116. <text class="advantage-icon">✓</text>
  117. <text class="advantage-text">海量优质资源</text>
  118. </view>
  119. <view class="advantage-item">
  120. <text class="advantage-icon">✓</text>
  121. <text class="advantage-text">一对一贴心服务</text>
  122. </view>
  123. <view class="advantage-item">
  124. <text class="advantage-icon">✓</text>
  125. <text class="advantage-text">高效精准匹配</text>
  126. </view>
  127. </view>
  128. </view>
  129. <!-- 成功案例展示 -->
  130. <view class="section-card">
  131. <view class="section-title">
  132. <text class="title-icon">💑</text>
  133. <text class="title-text">成功案例</text>
  134. </view>
  135. <view class="success-tip">
  136. <text class="tip-text">已成功撮合 {{ matchmaker.successCouples || 0 }} 对佳偶</text>
  137. </view>
  138. </view>
  139. <!-- 底部占位 -->
  140. <view class="bottom-placeholder"></view>
  141. </scroll-view>
  142. <!-- 加载中 -->
  143. <view class="loading-container" v-if="loading">
  144. <text class="loading-text">加载中...</text>
  145. </view>
  146. <!-- 底部操作栏 -->
  147. <view class="bottom-bar" v-if="matchmaker">
  148. <view class="action-btn call-btn" @click="callPhone(matchmaker.phone)">
  149. <text class="btn-icon">📞</text>
  150. <text class="btn-text">拨打电话</text>
  151. </view>
  152. <view class="action-btn consult-btn" @click="consultMatchmaker">
  153. <text class="btn-icon">💬</text>
  154. <text class="btn-text">在线咨询</text>
  155. </view>
  156. </view>
  157. </view>
  158. </template>
  159. <script>
  160. import api from '@/utils/api.js'
  161. import { DEFAULT_IMAGES } from '@/config/index.js'
  162. export default {
  163. data() {
  164. return {
  165. // 红娘ID
  166. matchmakerId: null,
  167. // 红娘详情
  168. matchmaker: null,
  169. // 加载状态
  170. loading: false,
  171. // 图片加载错误状态
  172. imageLoadError: false,
  173. // 默认头像
  174. defaultAvatar: DEFAULT_IMAGES.avatar
  175. }
  176. },
  177. onLoad(options) {
  178. console.log('红娘详情页接收到的参数:', options)
  179. if (options.id) {
  180. const parsedId = parseInt(options.id)
  181. console.log('解析后的红娘ID:', parsedId)
  182. // 检查解析后的ID是否有效
  183. if (isNaN(parsedId)) {
  184. console.error('红娘ID解析失败,原始值:', options.id)
  185. uni.showToast({
  186. title: 'ID参数无效',
  187. icon: 'none'
  188. })
  189. setTimeout(() => {
  190. uni.navigateBack()
  191. }, 1500)
  192. return
  193. }
  194. this.matchmakerId = parsedId
  195. this.loadMatchmakerDetail()
  196. } else {
  197. console.error('未接收到红娘ID参数')
  198. uni.showToast({
  199. title: '参数错误',
  200. icon: 'none'
  201. })
  202. setTimeout(() => {
  203. uni.navigateBack()
  204. }, 1500)
  205. }
  206. },
  207. methods: {
  208. /**
  209. * 加载红娘详情
  210. */
  211. async loadMatchmakerDetail() {
  212. this.loading = true
  213. try {
  214. const result = await api.matchmaker.getDetail(this.matchmakerId)
  215. this.matchmaker = result
  216. } catch (error) {
  217. console.error('加载红娘详情失败:', error)
  218. uni.showToast({
  219. title: '加载失败,请重试',
  220. icon: 'none'
  221. })
  222. setTimeout(() => {
  223. uni.navigateBack()
  224. }, 1500)
  225. } finally {
  226. this.loading = false
  227. }
  228. },
  229. /**
  230. * 获取等级文本
  231. */
  232. getLevelText(level) {
  233. const levelMap = {
  234. 1: '青铜',
  235. 2: '白银',
  236. 3: '黄金',
  237. 4: '铂金',
  238. 5: '钻石'
  239. }
  240. return levelMap[level] || '青铜'
  241. },
  242. /**
  243. * 拨打电话
  244. */
  245. callPhone(phone) {
  246. uni.showModal({
  247. title: '拨打电话',
  248. content: `是否拨打 ${phone}?`,
  249. success: (res) => {
  250. if (res.confirm) {
  251. uni.makePhoneCall({
  252. phoneNumber: phone,
  253. fail: () => {
  254. uni.showToast({
  255. title: '拨号失败',
  256. icon: 'none'
  257. })
  258. }
  259. })
  260. }
  261. }
  262. })
  263. },
  264. /**
  265. * 在线咨询
  266. */
  267. consultMatchmaker() {
  268. uni.showToast({
  269. title: '功能开发中',
  270. icon: 'none'
  271. })
  272. },
  273. /**
  274. * 获取头像URL
  275. */
  276. getAvatarUrl(avatarUrl) {
  277. if (avatarUrl) {
  278. // 如果是完整URL(MinIO生成的预签名URL或其他有效URL)
  279. if (avatarUrl.startsWith('http')) {
  280. // 检查是否是无效的placeholder URL
  281. if (avatarUrl.includes('placeholder')) {
  282. console.log('检测到placeholder URL,使用默认头像')
  283. return this.defaultAvatar
  284. }
  285. return avatarUrl
  286. }
  287. // 如果是相对路径,添加基础路径
  288. if (!avatarUrl.startsWith('/')) {
  289. return `/static/${avatarUrl}`
  290. }
  291. return avatarUrl
  292. }
  293. // 无头像URL时使用默认头像
  294. return this.defaultAvatar
  295. },
  296. /**
  297. * 判断是否显示占位符
  298. */
  299. shouldShowPlaceholder() {
  300. if (!this.matchmaker) return false
  301. // 如果没有头像URL,或头像加载失败,显示占位符
  302. return !this.matchmaker.avatarUrl || this.imageLoadError ||
  303. (this.matchmaker.avatarUrl && this.matchmaker.avatarUrl.includes('placeholder'))
  304. },
  305. /**
  306. * 图片加载成功处理
  307. */
  308. handleImageLoad() {
  309. this.imageLoadError = false
  310. },
  311. /**
  312. * 图片加载错误处理
  313. */
  314. handleImageError() {
  315. console.log('头像加载失败:', this.matchmaker?.realName, this.matchmaker?.avatarUrl)
  316. this.imageLoadError = true
  317. },
  318. /**
  319. * 返回
  320. */
  321. goBack() {
  322. uni.navigateBack()
  323. }
  324. }
  325. }
  326. </script>
  327. <style lang="scss" scoped>
  328. .matchmaker-detail-page {
  329. min-height: 100vh;
  330. background-color: #F5F5F5;
  331. padding-bottom: 120rpx;
  332. }
  333. /* 导航栏 */
  334. .nav-bar {
  335. display: flex;
  336. justify-content: space-between;
  337. align-items: center;
  338. height: 88rpx;
  339. padding: 0 30rpx;
  340. background-color: #FFFFFF;
  341. border-bottom: 1rpx solid #F0F0F0;
  342. position: sticky;
  343. top: 0;
  344. z-index: 999;
  345. .nav-left {
  346. width: 60rpx;
  347. height: 60rpx;
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. .back-icon {
  352. font-size: 48rpx;
  353. color: #333333;
  354. }
  355. }
  356. .nav-title {
  357. flex: 1;
  358. text-align: center;
  359. font-size: 36rpx;
  360. font-weight: bold;
  361. color: #333333;
  362. }
  363. .nav-right {
  364. width: 60rpx;
  365. }
  366. }
  367. /* 内容滚动区 */
  368. .content-scroll {
  369. height: calc(100vh - 88rpx - 120rpx);
  370. }
  371. /* 头部卡片 */
  372. .header-card {
  373. margin: 20rpx 30rpx;
  374. padding: 40rpx;
  375. background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
  376. border-radius: 20rpx;
  377. box-shadow: 0 4rpx 12rpx rgba(233, 30, 99, 0.1);
  378. .avatar-wrapper {
  379. position: relative;
  380. width: 200rpx;
  381. height: 200rpx;
  382. margin: 0 auto 30rpx;
  383. .avatar {
  384. width: 100%;
  385. height: 100%;
  386. border-radius: 50%;
  387. border: 6rpx solid #FFFFFF;
  388. background: linear-gradient(135deg, #F5F5F5 0%, #E0E0E0 100%);
  389. }
  390. .avatar-placeholder {
  391. position: absolute;
  392. top: 6rpx;
  393. left: 6rpx;
  394. width: calc(100% - 12rpx);
  395. height: calc(100% - 12rpx);
  396. border-radius: 50%;
  397. background: linear-gradient(135deg, #FFE5F1 0%, #FFECF3 100%);
  398. display: flex;
  399. align-items: center;
  400. justify-content: center;
  401. border: 2rpx solid rgba(233, 30, 99, 0.1);
  402. .placeholder-icon {
  403. font-size: 100rpx;
  404. color: rgba(233, 30, 99, 0.4);
  405. }
  406. }
  407. .level-badge {
  408. position: absolute;
  409. bottom: 0;
  410. left: 50%;
  411. transform: translateX(-50%);
  412. padding: 8rpx 20rpx;
  413. border-radius: 20rpx;
  414. font-size: 24rpx;
  415. color: #FFFFFF;
  416. white-space: nowrap;
  417. &.level-1 {
  418. background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
  419. }
  420. &.level-2 {
  421. background: linear-gradient(135deg, #C0C0C0 0%, #808080 100%);
  422. }
  423. &.level-3 {
  424. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  425. }
  426. &.level-4 {
  427. background: linear-gradient(135deg, #00CED1 0%, #4682B4 100%);
  428. }
  429. &.level-5 {
  430. background: linear-gradient(135deg, #9370DB 0%, #8A2BE2 100%);
  431. }
  432. }
  433. }
  434. .basic-info {
  435. text-align: center;
  436. .name-row {
  437. display: flex;
  438. align-items: center;
  439. justify-content: center;
  440. gap: 15rpx;
  441. margin-bottom: 15rpx;
  442. .name {
  443. font-size: 40rpx;
  444. font-weight: bold;
  445. color: #333333;
  446. }
  447. .gender-icon {
  448. font-size: 36rpx;
  449. color: #E91E63;
  450. }
  451. }
  452. .type-tag {
  453. display: inline-block;
  454. padding: 8rpx 20rpx;
  455. border-radius: 20rpx;
  456. font-size: 24rpx;
  457. color: #FFFFFF;
  458. margin-bottom: 30rpx;
  459. &.formal {
  460. background-color: #E91E63;
  461. }
  462. &.parttime {
  463. background-color: #FF9800;
  464. }
  465. }
  466. .stats-grid {
  467. display: flex;
  468. justify-content: space-around;
  469. align-items: center;
  470. .stats-item {
  471. display: flex;
  472. flex-direction: column;
  473. align-items: center;
  474. gap: 10rpx;
  475. .stats-value {
  476. font-size: 36rpx;
  477. font-weight: bold;
  478. color: #E91E63;
  479. }
  480. .stats-label {
  481. font-size: 24rpx;
  482. color: #666666;
  483. }
  484. }
  485. .stats-divider {
  486. width: 2rpx;
  487. height: 60rpx;
  488. background-color: #E0E0E0;
  489. }
  490. }
  491. }
  492. }
  493. /* 区块卡片 */
  494. .section-card {
  495. margin: 20rpx 30rpx;
  496. padding: 30rpx;
  497. background-color: #FFFFFF;
  498. border-radius: 20rpx;
  499. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  500. .section-title {
  501. display: flex;
  502. align-items: center;
  503. gap: 15rpx;
  504. margin-bottom: 30rpx;
  505. padding-bottom: 20rpx;
  506. border-bottom: 1rpx solid #F0F0F0;
  507. .title-icon {
  508. font-size: 36rpx;
  509. }
  510. .title-text {
  511. font-size: 32rpx;
  512. font-weight: bold;
  513. color: #333333;
  514. }
  515. }
  516. }
  517. /* 联系方式列表 */
  518. .contact-list {
  519. .contact-item {
  520. display: flex;
  521. justify-content: space-between;
  522. align-items: center;
  523. padding: 25rpx 0;
  524. border-bottom: 1rpx solid #F5F5F5;
  525. &:last-child {
  526. border-bottom: none;
  527. }
  528. .contact-left {
  529. display: flex;
  530. align-items: center;
  531. gap: 15rpx;
  532. .contact-icon {
  533. font-size: 32rpx;
  534. }
  535. .contact-label {
  536. font-size: 28rpx;
  537. color: #666666;
  538. }
  539. }
  540. .contact-right {
  541. display: flex;
  542. align-items: center;
  543. gap: 10rpx;
  544. .contact-value {
  545. font-size: 28rpx;
  546. color: #333333;
  547. }
  548. .contact-arrow {
  549. font-size: 28rpx;
  550. color: #999999;
  551. }
  552. }
  553. }
  554. }
  555. /* 地址内容 */
  556. .address-content {
  557. .address-text {
  558. font-size: 28rpx;
  559. color: #666666;
  560. line-height: 1.6;
  561. }
  562. }
  563. /* 个人简介 */
  564. .profile-content {
  565. .profile-text {
  566. font-size: 28rpx;
  567. color: #666666;
  568. line-height: 1.8;
  569. white-space: pre-wrap;
  570. }
  571. }
  572. /* 服务优势列表 */
  573. .advantage-list {
  574. display: grid;
  575. grid-template-columns: repeat(2, 1fr);
  576. gap: 20rpx;
  577. .advantage-item {
  578. display: flex;
  579. align-items: center;
  580. gap: 10rpx;
  581. padding: 20rpx;
  582. background-color: #F9F9F9;
  583. border-radius: 10rpx;
  584. .advantage-icon {
  585. font-size: 28rpx;
  586. color: #4CAF50;
  587. }
  588. .advantage-text {
  589. font-size: 26rpx;
  590. color: #666666;
  591. }
  592. }
  593. }
  594. /* 成功案例提示 */
  595. .success-tip {
  596. padding: 20rpx;
  597. background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
  598. border-radius: 10rpx;
  599. text-align: center;
  600. .tip-text {
  601. font-size: 28rpx;
  602. color: #E91E63;
  603. }
  604. }
  605. /* 加载中 */
  606. .loading-container {
  607. display: flex;
  608. justify-content: center;
  609. align-items: center;
  610. height: 80vh;
  611. .loading-text {
  612. font-size: 28rpx;
  613. color: #999999;
  614. }
  615. }
  616. /* 底部操作栏 */
  617. .bottom-bar {
  618. position: fixed;
  619. bottom: 0;
  620. left: 0;
  621. right: 0;
  622. display: flex;
  623. gap: 20rpx;
  624. padding: 20rpx 30rpx;
  625. background-color: #FFFFFF;
  626. border-top: 1rpx solid #F0F0F0;
  627. box-shadow: 0 -4rpx 12rpx rgba(0, 0, 0, 0.05);
  628. padding-bottom: constant(safe-area-inset-bottom);
  629. padding-bottom: env(safe-area-inset-bottom);
  630. .action-btn {
  631. flex: 1;
  632. display: flex;
  633. align-items: center;
  634. justify-content: center;
  635. gap: 10rpx;
  636. padding: 25rpx 0;
  637. border-radius: 50rpx;
  638. font-size: 28rpx;
  639. font-weight: bold;
  640. color: #FFFFFF;
  641. transition: transform 0.2s;
  642. &:active {
  643. transform: scale(0.95);
  644. }
  645. .btn-icon {
  646. font-size: 32rpx;
  647. }
  648. &.call-btn {
  649. background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  650. }
  651. &.consult-btn {
  652. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  653. }
  654. }
  655. }
  656. /* 底部占位 */
  657. .bottom-placeholder {
  658. height: 40rpx;
  659. }
  660. </style>