fix(home): 即时匹配改为真实在线大神实时匹配,优化弹窗按钮与暖色主题对比度

- 每次匹配重新拉取 /api/companions,只匹配 user_id>0(真实注册)、接单中、排除当前用户的大神

- 换一位优先避开上一位,解决长期固定命中种子大神(林深见鹿 userId=0)的问题

- 弹窗更名为「在线大神即时匹配」,按钮改为「换一位 / 查看资料并预约」,补充图标、尺寸与暖色主题对比

- 关闭弹窗取消未完成匹配;117 套件/765 用例全绿
这个提交包含在:
xcbyy
2026-10-22 18:14:51 +08:00
父节点 cf88efbe18
当前提交 b573c1ed05
共有 8 个文件被更改,包括 180 次插入 和 41 次删除

查看文件

@@ -216,7 +216,7 @@
<view class="price-modal-mask" v-if="showMatchModal" @click="closeMatchModal">
<view class="price-modal-box match-modal-box" @click.stop>
<view class="modal-title-row">
<text class="modal-title">雷达即时派单匹配</text>
<text class="modal-title">在线大神即时匹配</text>
<view class="btn-close btn-active" @click="closeMatchModal">
<image class="close-svg" :src="ICONS.close" mode="aspectFit" />
</view>
@@ -236,21 +236,29 @@
<!-- 匹配命中结果展示 -->
<view class="match-result-box" v-else-if="matchedExpert">
<view class="match-success-badge">首位接单大神命中</view>
<view class="match-success-badge">已为你匹配到在线大神</view>
<view class="matched-expert-card">
<image class="matched-avatar" :src="matchedExpert.avatar" mode="aspectFill" />
<view class="matched-info">
<view class="matched-name-row">
<text class="matched-name">{{ matchedExpert.nickname }}</text>
<text class="matched-online-tag">接单中</text>
<text class="matched-online-tag" :class="{ offline: !matchedExpert.isOnline }">
{{ matchedExpert.isOnline ? '接单中' : '休息中' }}
</text>
</view>
<text class="matched-game">{{ matchedExpert.game }} · {{ matchedExpert.rankTag }}</text>
<text class="matched-price">¥{{ matchedExpert.price }}/小时</text>
</view>
</view>
<view class="match-actions-row">
<button class="btn-match-action secondary btn-active" @click="reMatch">重新速配</button>
<button class="btn-match-action primary btn-active" @click="confirmMatchedOrder">立即预约该大神</button>
<button class="btn-match-action secondary btn-active" @click="reMatch">
<image class="match-btn-icon" :src="ICONS.radarWave" mode="aspectFit" />
<text>换一位</text>
</button>
<button class="btn-match-action primary btn-active" @click="confirmMatchedOrder">
<text>查看资料并预约</text>
<image class="match-btn-icon" :src="ICONS.chevronRight" mode="aspectFit" />
</button>
</view>
</view>
@@ -272,7 +280,7 @@ import AppTabBar from '@/components/CustomTabBar.vue';
import SkeletonScreen from '@/components/SkeletonScreen.vue';
import PrivacyModal from '@/components/PrivacyModal.vue';
import HomePopupModal from '@/components/HomePopupModal.vue';
import { getCompanions, getBanners, getNavCategories, bindInviteCode } from '@/common/api.js';
import { getCompanions, getBanners, getNavCategories, bindInviteCode, normalizeUserId } from '@/common/api.js';
import { ICONS } from '@/common/icons.js';
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
import { getNavBarInfo } from '@/common/nav.js';
@@ -575,33 +583,51 @@ const resetAllFilters = () => {
filterPriceRange.value = 'all';
};
// 雷达即时速配逻辑
// 即时速配:每次重新拉取大神状态,只匹配「真实注册 + 已通过审核 + 当前接单中」的大神,
// 排除自己;换一位时优先避开上一位,避免长期命中同一条种子数据。
let matchTimer = null;
const startInstantMatch = () => {
let matchSeq = 0;
let lastMatchedId = '';
const startInstantMatch = async () => {
const seq = ++matchSeq;
showMatchModal.value = true;
isMatching.value = true;
matchedExpert.value = null;
if (matchTimer) clearTimeout(matchTimer);
const startedAt = Date.now();
let freshList = null;
try {
freshList = await getCompanions();
} catch (_) {}
if (seq !== matchSeq) return;
if (Array.isArray(freshList) && freshList.length > 0) {
experts.value = freshList;
}
const wait = Math.max(0, 600 - (Date.now() - startedAt));
matchTimer = setTimeout(() => {
if (seq !== matchSeq) return;
isMatching.value = false;
// 按真实在线状态与距离推荐(有 distanceKm 时取最近),不做随机抽取
const onlineList = experts.value.filter(e => e.isOnline);
const candidates = onlineList.length > 0 ? onlineList : experts.value;
const sorted = [...candidates].sort((a, b) => {
const da = Number(a.distanceKm);
const db = Number(b.distanceKm);
if (Number.isFinite(da) && Number.isFinite(db)) return da - db;
if (Number.isFinite(da)) return -1;
if (Number.isFinite(db)) return 1;
return 0;
});
matchedExpert.value = sorted[0] || null;
}, 600);
const uid = Number(normalizeUserId()) || 0;
const eligible = (experts.value || []).filter(
(e) => e.isOnline && Number(e.userId) > 0 && Number(e.userId) !== uid
);
const rotated = eligible.filter((e) => String(e.id) !== String(lastMatchedId));
const pool = rotated.length > 0 ? rotated : eligible;
if (pool.length === 0) {
matchedExpert.value = null;
return;
}
const picked = pool[Math.floor(Math.random() * pool.length)];
matchedExpert.value = picked;
lastMatchedId = String(picked.id);
}, wait);
};
const closeMatchModal = () => {
showMatchModal.value = false;
matchSeq += 1;
if (matchTimer) clearTimeout(matchTimer);
};
@@ -1671,6 +1697,10 @@ const navTo = (url) => {
background: #059669;
padding: 2rpx 8rpx;
border-radius: 6rpx;
&.offline {
background: #64748B;
}
}
}
@@ -1692,25 +1722,40 @@ const navTo = (url) => {
.match-actions-row {
width: 100%;
display: flex;
gap: 16rpx;
gap: 20rpx;
.btn-match-action {
flex: 1;
height: 72rpx;
line-height: 70rpx;
font-size: 24rpx;
height: 84rpx;
line-height: 82rpx;
font-size: 26rpx;
font-weight: 600;
border-radius: 36rpx;
border-radius: 42rpx;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
gap: 8rpx;
box-sizing: border-box;
&.secondary {
background: rgba(255, 255, 255, 0.08);
color: #94A3B8;
flex: 1;
background: rgba(255, 255, 255, 0.06);
color: #CBD5E1;
border: 1px solid rgba(255, 255, 255, 0.14);
}
&.primary {
flex: 1.5;
background: linear-gradient(135deg, #10B981, #059669);
color: #FFFFFF;
border: none;
box-shadow: 0 8rpx 20rpx rgba(16, 185, 129, 0.28);
}
.match-btn-icon {
width: 30rpx;
height: 30rpx;
flex-shrink: 0;
}
}
}
@@ -1790,5 +1835,31 @@ const navTo = (url) => {
}
}
}
.price-modal-box.match-modal-box {
.matched-expert-card {
background: #FDFBF7;
border-color: #E7E5E4;
}
.matched-info .matched-name-row .matched-name {
color: #1C1917;
}
.matched-info .matched-game {
color: #78716C;
}
.match-actions-row .btn-match-action.secondary {
background: #F5F2EC;
border-color: #E7E5E4;
color: #57534E;
}
.match-empty-box .empty-txt,
.radar-status-text {
color: #78716C;
}
}
}
</style>