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:
@@ -85,7 +85,12 @@ export class AdminController {
|
|||||||
filter.$or = [
|
filter.$or = [
|
||||||
{ phone: { $regex: escaped, $options: 'i' } },
|
{ phone: { $regex: escaped, $options: 'i' } },
|
||||||
{ nickname: { $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 skip = (Math.max(1, +page) - 1) * +limit
|
||||||
const [users, total] = await Promise.all([
|
const [users, total] = await Promise.all([
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
<!-- 用户 -->
|
<!-- 用户 -->
|
||||||
<view v-if="tab === 'users'" class="section">
|
<view v-if="tab === 'users'" class="section">
|
||||||
<view class="search-bar">
|
<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>
|
<button class="search-btn" @click="loadUsers">搜索</button>
|
||||||
</view>
|
</view>
|
||||||
<view class="user-list" v-if="!usersLoading">
|
<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 email" v-if="u.email">{{ u.email }}</text>
|
||||||
<text class="meta-tag" v-if="u.wxOpenid">openid:{{ u.wxOpenid.slice(0,12) }}..</text>
|
<text class="meta-tag" v-if="u.wxOpenid">openid:{{ u.wxOpenid.slice(0,12) }}..</text>
|
||||||
</view>
|
</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">
|
<view class="user-meta-row">
|
||||||
<text class="meta-tag">引力:{{ u.gravity ?? 0 }}</text>
|
<text class="meta-tag">引力:{{ u.gravity ?? 0 }}</text>
|
||||||
<text class="meta-tag">面试:{{ u.interviewCount ?? 0 }}次</text>
|
<text class="meta-tag">面试:{{ u.interviewCount ?? 0 }}次</text>
|
||||||
@@ -1028,6 +1031,13 @@ const doAdjustCredits = async () => {
|
|||||||
} catch { uni.showToast({ title: '调整失败', icon: 'none' }) }
|
} catch { uni.showToast({ title: '调整失败', icon: 'none' }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const copyId = (id) => {
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: id,
|
||||||
|
success: () => uni.showToast({ title: 'ID 已复制', icon: 'success' }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => { doVerify() })
|
onMounted(() => { doVerify() })
|
||||||
</script>
|
</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 { 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.email { background: #EEF2FF; color: var(--color-primary); }
|
||||||
.meta-tag.share { background: #FFF7ED; color: #D97706; }
|
.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-done { background: #ECFDF5; color: #059669; }
|
||||||
.meta-tag.badge-pend { background: #FEF3C7; color: #D97706; }
|
.meta-tag.badge-pend { background: #FEF3C7; color: #D97706; }
|
||||||
.time-row { display: flex; flex-wrap: wrap; gap: 12rpx; }
|
.time-row { display: flex; flex-wrap: wrap; gap: 12rpx; }
|
||||||
|
|||||||
Reference in New Issue
Block a user