detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  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.avatar_url)"
  16. class="avatar"
  17. mode="aspectFill"
  18. @error="handleImageError(item)"
  19. @load="handleImageLoad(item)">
  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.level_name || '青铜红娘' }}
  26. </view>
  27. </view>
  28. <view class="basic-info">
  29. <view class="name-row">
  30. <text class="name">{{ matchmaker.real_name }}</text>
  31. <view class="gender-icon">
  32. {{ matchmaker.gender === 1 ? '♂' : '♀' }}
  33. </view>
  34. </view>
  35. <view class="type-tag" :class="matchmaker.matchmaker_type === 2 ? 'formal' : 'parttime'">
  36. {{ matchmaker.type_name || '兼职红娘' }}
  37. </view>
  38. <view class="stats-grid">
  39. <view class="stats-item">
  40. <text class="stats-value">{{ matchmaker.success_couples || 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.full_address">
  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.full_address }}</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.success_couples || 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. if (options.id) {
  179. const parsedId = parseInt(options.id)
  180. // 检查解析后的ID是否有效
  181. if (isNaN(parsedId)) {
  182. uni.showToast({
  183. title: 'ID参数无效',
  184. icon: 'none'
  185. })
  186. setTimeout(() => {
  187. uni.navigateBack()
  188. }, 1500)
  189. return
  190. }
  191. this.matchmakerId = parsedId
  192. this.loadMatchmakerDetail()
  193. } else {
  194. uni.showToast({
  195. title: '参数错误',
  196. icon: 'none'
  197. })
  198. setTimeout(() => {
  199. uni.navigateBack()
  200. }, 1500)
  201. }
  202. },
  203. methods: {
  204. /**
  205. * 加载红娘详情
  206. */
  207. async loadMatchmakerDetail() {
  208. this.loading = true
  209. try {
  210. const result = await api.matchmaker.getDetail(this.matchmakerId)
  211. this.matchmaker = result
  212. } catch (error) {
  213. uni.showToast({
  214. title: '加载失败,请重试',
  215. icon: 'none'
  216. })
  217. setTimeout(() => {
  218. uni.navigateBack()
  219. }, 1500)
  220. } finally {
  221. this.loading = false
  222. }
  223. },
  224. /**
  225. * 图片加载成功处理
  226. */
  227. handleImageLoad(item) {
  228. // 防御性检查:确保item存在且是对象
  229. if (!item || typeof item !== 'object') {
  230. return
  231. }
  232. this.$set(item, 'imageLoadError', false)
  233. this.$set(item, 'imageLoaded', true)
  234. },
  235. /**
  236. * 获取等级文本
  237. */
  238. getLevelText(level) {
  239. const levelMap = {
  240. 1: '青铜',
  241. 2: '白银',
  242. 3: '黄金',
  243. 4: '铂金',
  244. 5: '钻石'
  245. }
  246. return levelMap[level] || '青铜'
  247. },
  248. /**
  249. * 拨打电话
  250. */
  251. callPhone(phone) {
  252. uni.showModal({
  253. title: '拨打电话',
  254. content: `是否拨打 ${phone}?`,
  255. success: (res) => {
  256. if (res.confirm) {
  257. uni.makePhoneCall({
  258. phoneNumber: phone,
  259. fail: () => {
  260. uni.showToast({
  261. title: '拨号失败',
  262. icon: 'none'
  263. })
  264. }
  265. })
  266. }
  267. }
  268. })
  269. },
  270. /**
  271. * 在线咨询
  272. */
  273. consultMatchmaker() {
  274. if (!this.matchmaker) {
  275. uni.showToast({
  276. title: '红娘信息未加载',
  277. icon: 'none'
  278. })
  279. return
  280. }
  281. // 目标用户信息(红娘)
  282. // 给红娘 ID 加上 m_ 前缀,避免与普通用户 ID 冲突
  283. const matchmakerId = this.matchmaker.id || this.matchmakerId
  284. const targetUserId = 'm_' + matchmakerId
  285. const targetUserName = this.matchmaker.real_name || '红娘'
  286. const targetUserAvatar = this.getAvatarUrl(this.matchmaker.avatar_url)
  287. if (!targetUserId) {
  288. uni.showToast({
  289. title: '缺少红娘ID',
  290. icon: 'none'
  291. })
  292. return
  293. }
  294. // 跳转到聊天页面,携带对方用户信息和红娘标记
  295. uni.navigateTo({
  296. url: `/pages/message/chat?targetUserId=${encodeURIComponent(targetUserId)}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}&fromMatchmaker=1`
  297. })
  298. },
  299. /**
  300. * 获取头像URL
  301. */
  302. getAvatarUrl(avatarUrl) {
  303. if (avatarUrl) {
  304. // 如果是完整URL(MinIO生成的预签名URL或其他有效URL)
  305. if (avatarUrl.startsWith('http')) {
  306. // 检查是否是无效的placeholder URL
  307. if (avatarUrl.includes('placeholder')) {
  308. return this.defaultAvatar
  309. }
  310. return avatarUrl
  311. }
  312. // 如果是相对路径,添加基础路径
  313. if (!avatarUrl.startsWith('/')) {
  314. return `/static/${avatarUrl}`
  315. }
  316. return avatarUrl
  317. }
  318. // 无头像URL时使用默认头像
  319. return this.defaultAvatar
  320. },
  321. /**
  322. * 判断是否显示占位符
  323. */
  324. shouldShowPlaceholder() {
  325. if (!this.matchmaker) return false
  326. // 如果没有头像URL,或头像加载失败,显示占位符
  327. return !this.matchmaker.avatar_url || this.imageLoadError ||
  328. (this.matchmaker.avatar_url && this.matchmaker.avatar_url.includes('placeholder'))
  329. },
  330. /**
  331. * 图片加载错误处理
  332. */
  333. handleImageError(item) {
  334. // 防御性检查:确保item存在且是对象
  335. if (!item || typeof item !== 'object') {
  336. return
  337. }
  338. this.$set(item, 'imageLoadError', true)
  339. this.$set(item, 'imageLoaded', false)
  340. },
  341. /**
  342. * 返回
  343. */
  344. goBack() {
  345. uni.navigateBack()
  346. }
  347. }
  348. }
  349. </script>
  350. <style lang="scss" scoped>
  351. .matchmaker-detail-page {
  352. min-height: 100vh;
  353. background-color: #F5F5F5;
  354. padding-bottom: 120rpx;
  355. }
  356. /* 导航栏 */
  357. .nav-bar {
  358. display: flex;
  359. justify-content: space-between;
  360. align-items: center;
  361. height: 88rpx;
  362. padding: 0 30rpx;
  363. background-color: #FFFFFF;
  364. border-bottom: 1rpx solid #F0F0F0;
  365. position: sticky;
  366. top: 0;
  367. z-index: 999;
  368. .nav-left {
  369. width: 60rpx;
  370. height: 60rpx;
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. .back-icon {
  375. font-size: 48rpx;
  376. color: #333333;
  377. }
  378. }
  379. .nav-title {
  380. flex: 1;
  381. text-align: center;
  382. font-size: 36rpx;
  383. font-weight: bold;
  384. color: #333333;
  385. }
  386. .nav-right {
  387. width: 60rpx;
  388. }
  389. }
  390. /* 内容滚动区 */
  391. .content-scroll {
  392. height: calc(100vh - 88rpx - 120rpx);
  393. }
  394. /* 头部卡片 */
  395. .header-card {
  396. margin: 20rpx 30rpx;
  397. padding: 40rpx;
  398. background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
  399. border-radius: 20rpx;
  400. box-shadow: 0 4rpx 12rpx rgba(233, 30, 99, 0.1);
  401. .avatar-wrapper {
  402. position: relative;
  403. width: 200rpx;
  404. height: 200rpx;
  405. margin: 0 auto 30rpx;
  406. .avatar {
  407. width: 100%;
  408. height: 100%;
  409. border-radius: 50%;
  410. border: 6rpx solid #FFFFFF;
  411. background: linear-gradient(135deg, #F5F5F5 0%, #E0E0E0 100%);
  412. }
  413. .avatar-placeholder {
  414. position: absolute;
  415. top: 6rpx;
  416. left: 6rpx;
  417. width: calc(100% - 12rpx);
  418. height: calc(100% - 12rpx);
  419. border-radius: 50%;
  420. background: linear-gradient(135deg, #FFE5F1 0%, #FFECF3 100%);
  421. display: flex;
  422. align-items: center;
  423. justify-content: center;
  424. border: 2rpx solid rgba(233, 30, 99, 0.1);
  425. .placeholder-icon {
  426. font-size: 100rpx;
  427. color: rgba(233, 30, 99, 0.4);
  428. }
  429. }
  430. .level-badge {
  431. position: absolute;
  432. bottom: 0;
  433. left: 50%;
  434. transform: translateX(-50%);
  435. padding: 8rpx 20rpx;
  436. border-radius: 20rpx;
  437. font-size: 24rpx;
  438. color: #FFFFFF;
  439. white-space: nowrap;
  440. &.level-1 {
  441. background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
  442. }
  443. &.level-2 {
  444. background: linear-gradient(135deg, #C0C0C0 0%, #808080 100%);
  445. }
  446. &.level-3 {
  447. background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  448. }
  449. &.level-4 {
  450. background: linear-gradient(135deg, #00CED1 0%, #4682B4 100%);
  451. }
  452. &.level-5 {
  453. background: linear-gradient(135deg, #9370DB 0%, #8A2BE2 100%);
  454. }
  455. }
  456. }
  457. .basic-info {
  458. text-align: center;
  459. .name-row {
  460. display: flex;
  461. align-items: center;
  462. justify-content: center;
  463. gap: 15rpx;
  464. margin-bottom: 15rpx;
  465. .name {
  466. font-size: 40rpx;
  467. font-weight: bold;
  468. color: #333333;
  469. }
  470. .gender-icon {
  471. font-size: 36rpx;
  472. color: #E91E63;
  473. }
  474. }
  475. .type-tag {
  476. display: inline-block;
  477. padding: 8rpx 20rpx;
  478. border-radius: 20rpx;
  479. font-size: 24rpx;
  480. color: #FFFFFF;
  481. margin-bottom: 30rpx;
  482. &.formal {
  483. background-color: #E91E63;
  484. }
  485. &.parttime {
  486. background-color: #FF9800;
  487. }
  488. }
  489. .stats-grid {
  490. display: flex;
  491. justify-content: space-around;
  492. align-items: center;
  493. .stats-item {
  494. display: flex;
  495. flex-direction: column;
  496. align-items: center;
  497. gap: 10rpx;
  498. .stats-value {
  499. font-size: 36rpx;
  500. font-weight: bold;
  501. color: #E91E63;
  502. }
  503. .stats-label {
  504. font-size: 24rpx;
  505. color: #666666;
  506. }
  507. }
  508. .stats-divider {
  509. width: 2rpx;
  510. height: 60rpx;
  511. background-color: #E0E0E0;
  512. }
  513. }
  514. }
  515. }
  516. /* 区块卡片 */
  517. .section-card {
  518. margin: 20rpx 30rpx;
  519. padding: 30rpx;
  520. background-color: #FFFFFF;
  521. border-radius: 20rpx;
  522. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  523. .section-title {
  524. display: flex;
  525. align-items: center;
  526. gap: 15rpx;
  527. margin-bottom: 30rpx;
  528. padding-bottom: 20rpx;
  529. border-bottom: 1rpx solid #F0F0F0;
  530. .title-icon {
  531. font-size: 36rpx;
  532. }
  533. .title-text {
  534. font-size: 32rpx;
  535. font-weight: bold;
  536. color: #333333;
  537. }
  538. }
  539. }
  540. /* 联系方式列表 */
  541. .contact-list {
  542. .contact-item {
  543. display: flex;
  544. justify-content: space-between;
  545. align-items: center;
  546. padding: 25rpx 0;
  547. border-bottom: 1rpx solid #F5F5F5;
  548. &:last-child {
  549. border-bottom: none;
  550. }
  551. .contact-left {
  552. display: flex;
  553. align-items: center;
  554. gap: 15rpx;
  555. .contact-icon {
  556. font-size: 32rpx;
  557. }
  558. .contact-label {
  559. font-size: 28rpx;
  560. color: #666666;
  561. }
  562. }
  563. .contact-right {
  564. display: flex;
  565. align-items: center;
  566. gap: 10rpx;
  567. .contact-value {
  568. font-size: 28rpx;
  569. color: #333333;
  570. }
  571. .contact-arrow {
  572. font-size: 28rpx;
  573. color: #999999;
  574. }
  575. }
  576. }
  577. }
  578. /* 地址内容 */
  579. .address-content {
  580. .address-text {
  581. font-size: 28rpx;
  582. color: #666666;
  583. line-height: 1.6;
  584. }
  585. }
  586. /* 个人简介 */
  587. .profile-content {
  588. .profile-text {
  589. font-size: 28rpx;
  590. color: #666666;
  591. line-height: 1.8;
  592. white-space: pre-wrap;
  593. }
  594. }
  595. /* 服务优势列表 */
  596. .advantage-list {
  597. display: grid;
  598. grid-template-columns: repeat(2, 1fr);
  599. gap: 20rpx;
  600. .advantage-item {
  601. display: flex;
  602. align-items: center;
  603. gap: 10rpx;
  604. padding: 20rpx;
  605. background-color: #F9F9F9;
  606. border-radius: 10rpx;
  607. .advantage-icon {
  608. font-size: 28rpx;
  609. color: #4CAF50;
  610. }
  611. .advantage-text {
  612. font-size: 26rpx;
  613. color: #666666;
  614. }
  615. }
  616. }
  617. /* 成功案例提示 */
  618. .success-tip {
  619. padding: 20rpx;
  620. background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
  621. border-radius: 10rpx;
  622. text-align: center;
  623. .tip-text {
  624. font-size: 28rpx;
  625. color: #E91E63;
  626. }
  627. }
  628. /* 加载中 */
  629. .loading-container {
  630. display: flex;
  631. justify-content: center;
  632. align-items: center;
  633. height: 80vh;
  634. .loading-text {
  635. font-size: 28rpx;
  636. color: #999999;
  637. }
  638. }
  639. /* 底部操作栏 */
  640. .bottom-bar {
  641. position: fixed;
  642. bottom: 0;
  643. left: 0;
  644. right: 0;
  645. display: flex;
  646. gap: 20rpx;
  647. padding: 20rpx 30rpx;
  648. background-color: #FFFFFF;
  649. border-top: 1rpx solid #F0F0F0;
  650. box-shadow: 0 -4rpx 12rpx rgba(0, 0, 0, 0.05);
  651. padding-bottom: constant(safe-area-inset-bottom);
  652. padding-bottom: env(safe-area-inset-bottom);
  653. .action-btn {
  654. flex: 1;
  655. display: flex;
  656. align-items: center;
  657. justify-content: center;
  658. gap: 10rpx;
  659. padding: 25rpx 0;
  660. border-radius: 50rpx;
  661. font-size: 28rpx;
  662. font-weight: bold;
  663. color: #FFFFFF;
  664. transition: transform 0.2s;
  665. &:active {
  666. transform: scale(0.95);
  667. }
  668. .btn-icon {
  669. font-size: 32rpx;
  670. }
  671. &.call-btn {
  672. background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  673. }
  674. &.consult-btn {
  675. background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
  676. }
  677. }
  678. }
  679. /* 底部占位 */
  680. .bottom-placeholder {
  681. height: 40rpx;
  682. }
  683. </style>