|
|
@@ -4,12 +4,12 @@
|
|
|
<view class="top-bar">
|
|
|
<view class="logo">婚恋</view>
|
|
|
<view class="top-right-icons">
|
|
|
- <!-- 红娘工作台切换按钮 - 仅登录用户显示 -->
|
|
|
- <view v-if="userInfo && userInfo.userId && userInfo.isMatchmaker && parseInt(userInfo.isMatchmaker) === 1"
|
|
|
- class="matchmaker-btn" @click="openMatchmakerPopup">
|
|
|
- <text class="switch-icon">🔄</text>
|
|
|
- <text class="switch-text">切换工作台</text>
|
|
|
- </view>
|
|
|
+ <!-- 红娘工作台切换按钮 - 根据数据库查询结果动态显示 -->
|
|
|
+ <view v-if="showMatchmakerButton"
|
|
|
+ class="matchmaker-btn" @click="openMatchmakerPopup">
|
|
|
+ <text class="switch-icon">🔄</text>
|
|
|
+ <text class="switch-text">切换工作台</text>
|
|
|
+ </view>
|
|
|
<!-- 消息通知图标 -->
|
|
|
<view class="msg-icon" @click="goToMessages">
|
|
|
<text class="icon">🔔</text>
|
|
|
@@ -251,6 +251,9 @@
|
|
|
// 用户信息
|
|
|
userInfo: {},
|
|
|
matchCount: 3,
|
|
|
+
|
|
|
+ // 是否显示红娘工作台按钮(根据数据库查询结果)
|
|
|
+ showMatchmakerButton: false,
|
|
|
|
|
|
// 轮播图数据
|
|
|
bannerList: [],
|
|
|
@@ -338,16 +341,47 @@
|
|
|
console.log('📱 页面onShow触发')
|
|
|
// 页面显示时重新加载用户信息(确保登录后能更新)
|
|
|
this.loadUserInfo()
|
|
|
- // 页面显示时检查是否为红娘
|
|
|
- this.checkMatchmakerStatus()
|
|
|
+ // 页面显示时查询数据库检查是否为红娘
|
|
|
+ this.checkMatchmakerStatusFromDB()
|
|
|
},
|
|
|
methods: {
|
|
|
- // 删除自动弹出功能,只保留手动点击切换
|
|
|
- checkMatchmakerStatus() {
|
|
|
- // 从本地存储获取用户信息
|
|
|
- const userInfo = uni.getStorageSync('userInfo')
|
|
|
- console.log('🔍 检查红娘状态,用户信息:', userInfo)
|
|
|
- // 此处不再自动弹出弹框,只在用户点击切换按钮时显示
|
|
|
+ // 从数据库查询用户是否为红娘
|
|
|
+ async checkMatchmakerStatusFromDB() {
|
|
|
+ try {
|
|
|
+ const userId = uni.getStorageSync('userId')
|
|
|
+ if (!userId) {
|
|
|
+ console.log('⚠️ 用户未登录,不显示红娘按钮')
|
|
|
+ this.showMatchmakerButton = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('🔍 查询用户红娘状态,userId:', userId)
|
|
|
+
|
|
|
+ // 调用API查询用户的is_matchmaker字段
|
|
|
+ const result = await api.user.getMatchmakerStatus(userId)
|
|
|
+
|
|
|
+ if (result && result.isMatchmaker !== undefined) {
|
|
|
+ const isMatchmaker = parseInt(result.isMatchmaker)
|
|
|
+ console.log('✅ 查询成功,isMatchmaker:', isMatchmaker)
|
|
|
+
|
|
|
+ // 根据查询结果设置按钮显示状态
|
|
|
+ this.showMatchmakerButton = (isMatchmaker === 1)
|
|
|
+
|
|
|
+ // 同时更新本地存储的用户信息
|
|
|
+ const userInfo = uni.getStorageSync('userInfo') || {}
|
|
|
+ userInfo.isMatchmaker = isMatchmaker
|
|
|
+ uni.setStorageSync('userInfo', userInfo)
|
|
|
+ this.userInfo.isMatchmaker = isMatchmaker
|
|
|
+
|
|
|
+ console.log('🎯 红娘按钮显示状态:', this.showMatchmakerButton ? '显示' : '隐藏')
|
|
|
+ } else {
|
|
|
+ console.log('⚠️ 查询结果异常,不显示红娘按钮')
|
|
|
+ this.showMatchmakerButton = false
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('❌ 查询红娘状态失败:', error)
|
|
|
+ this.showMatchmakerButton = false
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
// 前往红娘工作台
|