| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791 |
- <template>
- <view class="matchmaker-detail-page">
- <!-- 顶部导航栏 -->
- <view class="nav-bar">
- <view class="nav-left" @click="goBack">
- <text class="back-icon">←</text>
- </view>
- <view class="nav-title">红娘详情</view>
- <view class="nav-right"></view>
- </view>
- <scroll-view class="content-scroll" scroll-y v-if="matchmaker">
- <!-- 头部卡片 -->
- <view class="header-card">
- <view class="avatar-wrapper">
- <image :src="getAvatarUrl(matchmaker.avatar_url)"
- class="avatar"
- mode="aspectFill"
- @error="handleImageError(item)"
- @load="handleImageLoad(item)">
- </image>
- <view class="avatar-placeholder" v-if="shouldShowPlaceholder()">
- <text class="placeholder-icon">👤</text>
- </view>
- <view class="level-badge" :class="'level-' + (matchmaker.level || 1)">
- {{ matchmaker.level_name || '青铜红娘' }}
- </view>
- </view>
- <view class="basic-info">
- <view class="name-row">
- <text class="name">{{ matchmaker.real_name }}</text>
- <view class="gender-icon">
- {{ matchmaker.gender === 1 ? '♂' : '♀' }}
- </view>
- </view>
- <view class="type-tag" :class="matchmaker.matchmaker_type === 2 ? 'formal' : 'parttime'">
- {{ matchmaker.type_name || '兼职红娘' }}
- </view>
- <view class="stats-grid">
- <view class="stats-item">
- <text class="stats-value">{{ matchmaker.success_couples || 0 }}</text>
- <text class="stats-label">成功撮合</text>
- </view>
- <view class="stats-divider"></view>
- <view class="stats-item">
- <text class="stats-value">{{ matchmaker.age || '--' }}</text>
- <text class="stats-label">年龄</text>
- </view>
- <view class="stats-divider"></view>
- <view class="stats-item">
- <text class="stats-value">{{ getLevelText(matchmaker.level) }}</text>
- <text class="stats-label">等级</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 联系方式卡片 -->
- <view class="section-card">
- <view class="section-title">
- <text class="title-icon">📞</text>
- <text class="title-text">联系方式</text>
- </view>
- <view class="contact-list">
- <view class="contact-item" @click="callPhone(matchmaker.phone)">
- <view class="contact-left">
- <text class="contact-icon">📱</text>
- <text class="contact-label">手机号码</text>
- </view>
- <view class="contact-right">
- <text class="contact-value">{{ matchmaker.phone }}</text>
- <text class="contact-arrow">→</text>
- </view>
- </view>
- <view class="contact-item" v-if="matchmaker.email">
- <view class="contact-left">
- <text class="contact-icon">📧</text>
- <text class="contact-label">电子邮箱</text>
- </view>
- <view class="contact-right">
- <text class="contact-value">{{ matchmaker.email }}</text>
- </view>
- </view>
- </view>
- </view>
- <!-- 地址信息卡片 -->
- <view class="section-card" v-if="matchmaker.full_address">
- <view class="section-title">
- <text class="title-icon">📍</text>
- <text class="title-text">服务地区</text>
- </view>
- <view class="address-content">
- <text class="address-text">{{ matchmaker.full_address }}</text>
- </view>
- </view>
- <!-- 个人简介卡片 -->
- <view class="section-card" v-if="matchmaker.profile">
- <view class="section-title">
- <text class="title-icon">✏️</text>
- <text class="title-text">个人简介</text>
- </view>
- <view class="profile-content">
- <text class="profile-text">{{ matchmaker.profile }}</text>
- </view>
- </view>
- <!-- 服务优势卡片 -->
- <view class="section-card">
- <view class="section-title">
- <text class="title-icon">⭐</text>
- <text class="title-text">服务优势</text>
- </view>
- <view class="advantage-list">
- <view class="advantage-item">
- <text class="advantage-icon">✓</text>
- <text class="advantage-text">专业婚恋指导</text>
- </view>
- <view class="advantage-item">
- <text class="advantage-icon">✓</text>
- <text class="advantage-text">海量优质资源</text>
- </view>
- <view class="advantage-item">
- <text class="advantage-icon">✓</text>
- <text class="advantage-text">一对一贴心服务</text>
- </view>
- <view class="advantage-item">
- <text class="advantage-icon">✓</text>
- <text class="advantage-text">高效精准匹配</text>
- </view>
- </view>
- </view>
- <!-- 成功案例展示 -->
- <view class="section-card">
- <view class="section-title">
- <text class="title-icon">💑</text>
- <text class="title-text">成功案例</text>
- </view>
- <view class="success-tip">
- <text class="tip-text">已成功撮合 {{ matchmaker.success_couples || 0 }} 对佳偶</text>
- </view>
- </view>
- <!-- 底部占位 -->
- <view class="bottom-placeholder"></view>
- </scroll-view>
- <!-- 加载中 -->
- <view class="loading-container" v-if="loading">
- <text class="loading-text">加载中...</text>
- </view>
- <!-- 底部操作栏 -->
- <view class="bottom-bar" v-if="matchmaker">
- <view class="action-btn call-btn" @click="callPhone(matchmaker.phone)">
- <text class="btn-icon">📞</text>
- <text class="btn-text">拨打电话</text>
- </view>
- <view class="action-btn consult-btn" @click="consultMatchmaker">
- <text class="btn-icon">💬</text>
- <text class="btn-text">在线咨询</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import api from '@/utils/api.js'
- import { DEFAULT_IMAGES } from '@/config/index.js'
- export default {
- data() {
- return {
- // 红娘ID
- matchmakerId: null,
-
- // 红娘详情
- matchmaker: null,
-
- // 加载状态
- loading: false,
-
- // 图片加载错误状态
- imageLoadError: false,
-
- // 默认头像
- defaultAvatar: DEFAULT_IMAGES.avatar
- }
- },
- onLoad(options) {
- console.log('红娘详情页接收到的参数:', options)
- if (options.id) {
- const parsedId = parseInt(options.id)
- console.log('解析后的红娘ID:', parsedId)
-
- // 检查解析后的ID是否有效
- if (isNaN(parsedId)) {
- console.error('红娘ID解析失败,原始值:', options.id)
- uni.showToast({
- title: 'ID参数无效',
- icon: 'none'
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 1500)
- return
- }
-
- this.matchmakerId = parsedId
- this.loadMatchmakerDetail()
- } else {
- console.error('未接收到红娘ID参数')
- uni.showToast({
- title: '参数错误',
- icon: 'none'
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 1500)
- }
- },
- methods: {
- /**
- * 加载红娘详情
- */
- async loadMatchmakerDetail() {
- this.loading = true
-
- try {
- const result = await api.matchmaker.getDetail(this.matchmakerId)
- console.log(result)
- this.matchmaker = result
- } catch (error) {
- console.error('加载红娘详情失败:', error)
- uni.showToast({
- title: '加载失败,请重试',
- icon: 'none'
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 1500)
- } finally {
- this.loading = false
- }
- },
- /**
- * 图片加载成功处理
- */
- handleImageLoad(item) {
- console.log(item)
- // 防御性检查:确保item存在且是对象
- if (!item || typeof item !== 'object') {
- console.warn('handleImageLoad: item参数无效', item)
- return
- }
- this.$set(item, 'imageLoadError', false)
- this.$set(item, 'imageLoaded', true)
- },
-
- /**
- * 获取等级文本
- */
- getLevelText(level) {
- const levelMap = {
- 1: '青铜',
- 2: '白银',
- 3: '黄金',
- 4: '铂金',
- 5: '钻石'
- }
- return levelMap[level] || '青铜'
- },
- /**
- * 拨打电话
- */
- callPhone(phone) {
- uni.showModal({
- title: '拨打电话',
- content: `是否拨打 ${phone}?`,
- success: (res) => {
- if (res.confirm) {
- uni.makePhoneCall({
- phoneNumber: phone,
- fail: () => {
- uni.showToast({
- title: '拨号失败',
- icon: 'none'
- })
- }
- })
- }
- }
- })
- },
- /**
- * 在线咨询
- */
- consultMatchmaker() {
- if (!this.matchmaker) {
- uni.showToast({
- title: '红娘信息未加载',
- icon: 'none'
- })
- return
- }
-
- // 目标用户信息(红娘)
- // 给红娘 ID 加上 m_ 前缀,避免与普通用户 ID 冲突
- const matchmakerId = this.matchmaker.id || this.matchmakerId
- const targetUserId = 'm_' + matchmakerId
- const targetUserName = this.matchmaker.real_name || '红娘'
- const targetUserAvatar = this.getAvatarUrl(this.matchmaker.avatar_url)
-
- if (!targetUserId) {
- uni.showToast({
- title: '缺少红娘ID',
- icon: 'none'
- })
- return
- }
-
- // 跳转到聊天页面,携带对方用户信息和红娘标记
- uni.navigateTo({
- url: `/pages/message/chat?targetUserId=${encodeURIComponent(targetUserId)}&targetUserName=${encodeURIComponent(targetUserName)}&targetUserAvatar=${encodeURIComponent(targetUserAvatar)}&fromMatchmaker=1`
- })
- },
- /**
- * 获取头像URL
- */
- getAvatarUrl(avatarUrl) {
- if (avatarUrl) {
- // 如果是完整URL(MinIO生成的预签名URL或其他有效URL)
- if (avatarUrl.startsWith('http')) {
- // 检查是否是无效的placeholder URL
- if (avatarUrl.includes('placeholder')) {
- console.log('检测到placeholder URL,使用默认头像')
- return this.defaultAvatar
- }
- return avatarUrl
- }
- // 如果是相对路径,添加基础路径
- if (!avatarUrl.startsWith('/')) {
- return `/static/${avatarUrl}`
- }
- return avatarUrl
- }
- // 无头像URL时使用默认头像
- return this.defaultAvatar
- },
- /**
- * 判断是否显示占位符
- */
- shouldShowPlaceholder() {
- if (!this.matchmaker) return false
- // 如果没有头像URL,或头像加载失败,显示占位符
- return !this.matchmaker.avatar_url || this.imageLoadError ||
- (this.matchmaker.avatar_url && this.matchmaker.avatar_url.includes('placeholder'))
- },
- /**
- * 图片加载错误处理
- */
- handleImageError(item) {
- console.log(item)
- // 防御性检查:确保item存在且是对象
- if (!item || typeof item !== 'object') {
- console.warn('handleImageError: item参数无效', item)
- return
- }
-
- console.log('头像加载失败:', item.real_name, item.avatar_url)
- this.$set(item, 'imageLoadError', true)
- this.$set(item, 'imageLoaded', false)
- },
- /**
- * 返回
- */
- goBack() {
- uni.navigateBack()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .matchmaker-detail-page {
- min-height: 100vh;
- background-color: #F5F5F5;
- padding-bottom: 120rpx;
- }
- /* 导航栏 */
- .nav-bar {
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 88rpx;
- padding: 0 30rpx;
- background-color: #FFFFFF;
- border-bottom: 1rpx solid #F0F0F0;
- position: sticky;
- top: 0;
- z-index: 999;
- .nav-left {
- width: 60rpx;
- height: 60rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- .back-icon {
- font-size: 48rpx;
- color: #333333;
- }
- }
- .nav-title {
- flex: 1;
- text-align: center;
- font-size: 36rpx;
- font-weight: bold;
- color: #333333;
- }
- .nav-right {
- width: 60rpx;
- }
- }
- /* 内容滚动区 */
- .content-scroll {
- height: calc(100vh - 88rpx - 120rpx);
- }
- /* 头部卡片 */
- .header-card {
- margin: 20rpx 30rpx;
- padding: 40rpx;
- background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
- border-radius: 20rpx;
- box-shadow: 0 4rpx 12rpx rgba(233, 30, 99, 0.1);
- .avatar-wrapper {
- position: relative;
- width: 200rpx;
- height: 200rpx;
- margin: 0 auto 30rpx;
- .avatar {
- width: 100%;
- height: 100%;
- border-radius: 50%;
- border: 6rpx solid #FFFFFF;
- background: linear-gradient(135deg, #F5F5F5 0%, #E0E0E0 100%);
- }
- .avatar-placeholder {
- position: absolute;
- top: 6rpx;
- left: 6rpx;
- width: calc(100% - 12rpx);
- height: calc(100% - 12rpx);
- border-radius: 50%;
- background: linear-gradient(135deg, #FFE5F1 0%, #FFECF3 100%);
- display: flex;
- align-items: center;
- justify-content: center;
- border: 2rpx solid rgba(233, 30, 99, 0.1);
- .placeholder-icon {
- font-size: 100rpx;
- color: rgba(233, 30, 99, 0.4);
- }
- }
- .level-badge {
- position: absolute;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- padding: 8rpx 20rpx;
- border-radius: 20rpx;
- font-size: 24rpx;
- color: #FFFFFF;
- white-space: nowrap;
- &.level-1 {
- background: linear-gradient(135deg, #CD7F32 0%, #8B4513 100%);
- }
- &.level-2 {
- background: linear-gradient(135deg, #C0C0C0 0%, #808080 100%);
- }
- &.level-3 {
- background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
- }
- &.level-4 {
- background: linear-gradient(135deg, #00CED1 0%, #4682B4 100%);
- }
- &.level-5 {
- background: linear-gradient(135deg, #9370DB 0%, #8A2BE2 100%);
- }
- }
- }
- .basic-info {
- text-align: center;
- .name-row {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 15rpx;
- margin-bottom: 15rpx;
- .name {
- font-size: 40rpx;
- font-weight: bold;
- color: #333333;
- }
- .gender-icon {
- font-size: 36rpx;
- color: #E91E63;
- }
- }
- .type-tag {
- display: inline-block;
- padding: 8rpx 20rpx;
- border-radius: 20rpx;
- font-size: 24rpx;
- color: #FFFFFF;
- margin-bottom: 30rpx;
- &.formal {
- background-color: #E91E63;
- }
- &.parttime {
- background-color: #FF9800;
- }
- }
- .stats-grid {
- display: flex;
- justify-content: space-around;
- align-items: center;
- .stats-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 10rpx;
- .stats-value {
- font-size: 36rpx;
- font-weight: bold;
- color: #E91E63;
- }
- .stats-label {
- font-size: 24rpx;
- color: #666666;
- }
- }
- .stats-divider {
- width: 2rpx;
- height: 60rpx;
- background-color: #E0E0E0;
- }
- }
- }
- }
- /* 区块卡片 */
- .section-card {
- margin: 20rpx 30rpx;
- padding: 30rpx;
- background-color: #FFFFFF;
- border-radius: 20rpx;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
- .section-title {
- display: flex;
- align-items: center;
- gap: 15rpx;
- margin-bottom: 30rpx;
- padding-bottom: 20rpx;
- border-bottom: 1rpx solid #F0F0F0;
- .title-icon {
- font-size: 36rpx;
- }
- .title-text {
- font-size: 32rpx;
- font-weight: bold;
- color: #333333;
- }
- }
- }
- /* 联系方式列表 */
- .contact-list {
- .contact-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 25rpx 0;
- border-bottom: 1rpx solid #F5F5F5;
- &:last-child {
- border-bottom: none;
- }
- .contact-left {
- display: flex;
- align-items: center;
- gap: 15rpx;
- .contact-icon {
- font-size: 32rpx;
- }
- .contact-label {
- font-size: 28rpx;
- color: #666666;
- }
- }
- .contact-right {
- display: flex;
- align-items: center;
- gap: 10rpx;
- .contact-value {
- font-size: 28rpx;
- color: #333333;
- }
- .contact-arrow {
- font-size: 28rpx;
- color: #999999;
- }
- }
- }
- }
- /* 地址内容 */
- .address-content {
- .address-text {
- font-size: 28rpx;
- color: #666666;
- line-height: 1.6;
- }
- }
- /* 个人简介 */
- .profile-content {
- .profile-text {
- font-size: 28rpx;
- color: #666666;
- line-height: 1.8;
- white-space: pre-wrap;
- }
- }
- /* 服务优势列表 */
- .advantage-list {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: 20rpx;
- .advantage-item {
- display: flex;
- align-items: center;
- gap: 10rpx;
- padding: 20rpx;
- background-color: #F9F9F9;
- border-radius: 10rpx;
- .advantage-icon {
- font-size: 28rpx;
- color: #4CAF50;
- }
- .advantage-text {
- font-size: 26rpx;
- color: #666666;
- }
- }
- }
- /* 成功案例提示 */
- .success-tip {
- padding: 20rpx;
- background: linear-gradient(135deg, #FFE5EE 0%, #FFF9F9 100%);
- border-radius: 10rpx;
- text-align: center;
- .tip-text {
- font-size: 28rpx;
- color: #E91E63;
- }
- }
- /* 加载中 */
- .loading-container {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 80vh;
- .loading-text {
- font-size: 28rpx;
- color: #999999;
- }
- }
- /* 底部操作栏 */
- .bottom-bar {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- display: flex;
- gap: 20rpx;
- padding: 20rpx 30rpx;
- background-color: #FFFFFF;
- border-top: 1rpx solid #F0F0F0;
- box-shadow: 0 -4rpx 12rpx rgba(0, 0, 0, 0.05);
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- .action-btn {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 10rpx;
- padding: 25rpx 0;
- border-radius: 50rpx;
- font-size: 28rpx;
- font-weight: bold;
- color: #FFFFFF;
- transition: transform 0.2s;
- &:active {
- transform: scale(0.95);
- }
- .btn-icon {
- font-size: 32rpx;
- }
- &.call-btn {
- background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
- }
- &.consult-btn {
- background: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
- }
- }
- }
- /* 底部占位 */
- .bottom-placeholder {
- height: 40rpx;
- }
- </style>
|