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