feat(admin): fuzzy search by email/ID, display full userId in user list

- Backend: add email + _id to  filter in getUsers() for fuzzy search
- Frontend: show full MongoDB _id in user row with tap-to-copy
- Search placeholder updated to mention email/ID
This commit is contained in:
yuzhiran
2026-06-22 11:46:14 +08:00
parent 4d54c8088c
commit d37bbd7a61
2 changed files with 17 additions and 1 deletions
@@ -85,7 +85,12 @@ export class AdminController {
filter.$or = [
{ phone: { $regex: escaped, $options: 'i' } },
{ nickname: { $regex: escaped, $options: 'i' } },
{ email: { $regex: escaped, $options: 'i' } },
]
// 支持按 MongoDB _id 搜索(24位 hex
if (/^[0-9a-f]{24}$/i.test(keyword)) {
filter.$or.push({ _id: keyword })
}
}
const skip = (Math.max(1, +page) - 1) * +limit
const [users, total] = await Promise.all([
+12 -1
View File
@@ -73,7 +73,7 @@
<!-- 用户 -->
<view v-if="tab === 'users'" class="section">
<view class="search-bar">
<input v-model="userKeyword" placeholder="搜索手机号/昵称" class="search-input" @confirm="loadUsers" />
<input v-model="userKeyword" placeholder="搜索手机号/邮箱/昵称/ID" class="search-input" @confirm="loadUsers" />
<button class="search-btn" @click="loadUsers">搜索</button>
</view>
<view class="user-list" v-if="!usersLoading">
@@ -87,6 +87,9 @@
<text class="meta-tag email" v-if="u.email">{{ u.email }}</text>
<text class="meta-tag" v-if="u.wxOpenid">openid:{{ u.wxOpenid.slice(0,12) }}..</text>
</view>
<view class="user-meta-row">
<text class="meta-tag id-tag" @click="copyId(u._id)">ID: {{ u._id }}</text>
</view>
<view class="user-meta-row">
<text class="meta-tag">引力:{{ u.gravity ?? 0 }}</text>
<text class="meta-tag">面试:{{ u.interviewCount ?? 0 }}</text>
@@ -1028,6 +1031,13 @@ const doAdjustCredits = async () => {
} catch { uni.showToast({ title: '调整失败', icon: 'none' }) }
}
const copyId = (id) => {
uni.setClipboardData({
data: id,
success: () => uni.showToast({ title: 'ID 已复制', icon: 'success' }),
})
}
onMounted(() => { doVerify() })
</script>
@@ -1162,6 +1172,7 @@ onMounted(() => { doVerify() })
.meta-tag { font-size: 18rpx; background: #F3F4F6; color: var(--color-text-tertiary); padding: 2rpx 10rpx; border-radius: var(--radius-round); }
.meta-tag.email { background: #EEF2FF; color: var(--color-primary); }
.meta-tag.share { background: #FFF7ED; color: #D97706; }
.meta-tag.id-tag { background: #F5F3FF; color: #7C3AED; font-family: monospace; font-size: 16rpx; }
.meta-tag.badge-done { background: #ECFDF5; color: #059669; }
.meta-tag.badge-pend { background: #FEF3C7; color: #D97706; }
.time-row { display: flex; flex-wrap: wrap; gap: 12rpx; }