You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1693 lines
61 KiB

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0">
<title>身份信息审核</title>
<style>
/* 全局样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background-color: #f0f2f5;
color: #333;
line-height: 1.6;
}
/* 容器样式 */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
/* 顶部导航栏 */
.header {
background: linear-gradient(135deg, #1890ff, #36cfc9);
color: white;
padding: 16px 0;
margin-bottom: 24px;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.header-content {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
.header h1 {
font-size: 24px;
font-weight: 600;
margin: 0;
}
.header-actions {
display: flex;
gap: 12px;
}
.btn {
padding: 10px 20px;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 12px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
gap: 6px;
backdrop-filter: blur(10px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.btn-primary {
background-color: rgba(255, 255, 255, 0.2);
color: white;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-primary:hover {
background-color: rgba(255, 255, 255, 0.3);
transform: translateY(-1px);
}
/* 搜索和过滤区域 */
.search-filter-section {
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
margin-bottom: 24px;
}
.search-filter-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
flex-wrap: wrap;
gap: 12px;
}
.status-filter {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.date-filter {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.date-input {
padding: 6px 12px;
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 14px;
}
.btn-filter {
background-color: rgba(24, 144, 255, 0.9);
color: white;
padding: 8px 20px;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-filter:hover {
background-color: rgba(64, 169, 255, 0.9);
}
.btn-reset {
background-color: rgba(153, 153, 153, 0.9);
color: white;
padding: 8px 20px;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-reset:hover {
background-color: rgba(102, 102, 102, 0.9);
}
.filter-btn {
padding: 6px 16px;
border: 1px solid #d9d9d9;
background-color: white;
color: #666;
border-radius: 16px;
font-size: 14px;
cursor: pointer;
transition: all 0.3s ease;
}
.filter-btn.active {
background-color: #1890ff;
color: white;
border-color: #1890ff;
}
.filter-btn:hover:not(.active) {
border-color: #1890ff;
color: #1890ff;
}
.search-box {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
.search-input {
flex: 1;
min-width: 200px;
padding: 10px 16px;
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 14px;
transition: all 0.3s ease;
}
.search-input:focus {
outline: none;
border-color: #1890ff;
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}
.btn-search {
background-color: rgba(24, 144, 255, 0.9);
color: white;
padding: 12px 24px;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-search:hover {
background-color: rgba(64, 169, 255, 0.9);
}
.btn-refresh {
background-color: rgba(82, 196, 26, 0.9);
color: white;
padding: 12px 24px;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-refresh:hover {
background-color: rgba(115, 209, 61, 0.9);
}
/* 身份信息列表区域 */
.identity-list-section {
background: white;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
margin-bottom: 24px;
width: 100%;
}
.identity-header {
padding: 16px 20px;
border-bottom: 1px solid #f0f0f0;
background-color: #fafafa;
display: flex;
justify-content: space-between;
align-items: center;
}
.identity-header h2 {
font-size: 16px;
font-weight: 600;
margin: 0;
color: #333;
}
.identity-stats {
font-size: 14px;
color: #666;
}
.identity-list {
/* 取消内部滚轮,使用外部滚轮 */
}
/* 序号样式 */
.identity-index {
font-size: 14px;
color: #666;
font-weight: 500;
min-width: 60px;
text-align: left;
margin-right: 16px;
padding-top: 2px;
border-right: 1px solid #e8e8e8;
padding-right: 16px;
display: flex;
align-items: center;
gap: 8px;
}
/* 勾选框样式 */
.identity-checkbox {
margin: 0;
width: 16px;
height: 16px;
cursor: pointer;
}
.identity-checkbox:disabled {
cursor: not-allowed;
opacity: 0.5;
}
.identity-item {
padding: 20px;
border-bottom: 1px solid #f0f0f0;
transition: all 0.3s ease;
border-radius: 8px;
margin-bottom: 12px;
background-color: white;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.identity-item:hover {
background-color: #fafafa;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transform: translateY(-1px);
}
.identity-item:last-child {
margin-bottom: 0;
}
.identity-meta {
display: flex;
align-items: flex-start;
margin-bottom: 12px;
}
.identity-info {
flex: 1;
}
.identity-author {
font-size: 14px;
font-weight: 600;
color: #333;
margin-bottom: 8px;
display: flex;
align-items: center;
gap: 12px;
}
.identity-details {
font-size: 12px;
color: #999;
display: flex;
gap: 16px;
flex-wrap: wrap;
margin-bottom: 12px;
}
.identity-images {
display: flex;
gap: 16px;
flex-wrap: wrap;
margin-bottom: 16px;
padding-left: 52px;
}
.identity-image {
width: 120px;
height: 80px;
object-fit: cover;
border-radius: 4px;
cursor: pointer;
transition: transform 0.3s ease;
}
.identity-image:hover {
transform: scale(1.05);
}
.identity-actions {
display: flex;
gap: 12px;
align-items: center;
padding-left: 52px;
}
.btn-approve {
background-color: rgba(82, 196, 26, 0.9);
color: white;
padding: 8px 20px;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-approve:hover {
background-color: rgba(115, 209, 61, 0.9);
}
.btn-reject {
background-color: rgba(255, 77, 79, 0.9);
color: white;
padding: 8px 20px;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-reject:hover {
background-color: rgba(255, 120, 117, 0.9);
}
.btn-details {
background-color: rgba(24, 144, 255, 0.9);
color: white;
padding: 8px 20px;
border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-details:hover {
background-color: rgba(64, 169, 255, 0.9);
}
/* 状态标签 */
.status-tag {
padding: 2px 8px;
border-radius: 10px;
font-size: 12px;
font-weight: 500;
color: white;
display: inline-block;
}
.status-pending {
background-color: #faad14;
}
.status-approved {
background-color: #52c41a;
}
.status-rejected {
background-color: #ff4d4f;
}
/* 空状态 */
.empty-state {
padding: 60px 20px;
text-align: center;
color: #999;
}
.empty-icon {
font-size: 48px;
margin-bottom: 16px;
color: #d9d9d9;
}
.empty-state h3 {
margin: 0 0 8px 0;
color: #333;
font-size: 16px;
font-weight: 500;
}
/* 加载状态 */
.loading-state {
padding: 40px 20px;
text-align: center;
color: #1890ff;
}
/* 分页区域 */
.pagination-section {
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
margin-top: 20px;
}
/* 页面大小选择器 */
.page-size-selector {
display: flex;
align-items: center;
gap: 8px;
margin-right: 20px;
}
.page-size-selector label {
font-size: 14px;
color: #666;
}
.page-size-selector select {
padding: 4px 8px;
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 14px;
color: #666;
}
.page-btn {
padding: 6px 12px;
border: 1px solid #d9d9d9;
background-color: white;
color: #666;
border-radius: 4px;
cursor: pointer;
transition: all 0.3s ease;
font-size: 14px;
}
.page-btn:hover:not(:disabled) {
border-color: #1890ff;
color: #1890ff;
}
.page-btn.active {
background-color: #1890ff;
color: white;
border-color: #1890ff;
}
.page-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* 详情弹窗 */
.modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(4px);
display: none;
justify-content: center;
align-items: center;
z-index: 1000;
}
.modal-content {
background-color: white;
border-radius: 16px;
width: 92%;
max-width: 720px;
max-height: 90vh;
overflow: hidden;
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
display: flex;
flex-direction: column;
}
@keyframes modalFadeIn {
from {
opacity: 0;
transform: translateY(-30px) scale(0.92);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
.modal-header {
padding: 24px 32px;
border-bottom: 1px solid #f0f0f0;
display: flex;
justify-content: space-between;
align-items: center;
background: linear-gradient(135deg, #f8f9fa, #ffffff);
border-radius: 16px 16px 0 0;
}
.modal-title {
font-size: 20px;
font-weight: 600;
margin: 0;
color: #333;
display: flex;
align-items: center;
gap: 10px;
}
.modal-title::before {
content: "🆔";
font-size: 22px;
}
.modal-close {
background: none;
border: none;
font-size: 28px;
cursor: pointer;
color: #999;
padding: 0;
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
transition: all 0.3s ease;
line-height: 1;
}
.modal-close:hover {
background-color: #f0f0f0;
color: #333;
transform: rotate(90deg);
}
.modal-body {
padding: 32px;
overflow-y: auto;
flex: 1;
}
.detail-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 24px;
margin-bottom: 32px;
}
.detail-card {
background: linear-gradient(135deg, #f8f9fa, #ffffff);
border-radius: 12px;
padding: 20px;
transition: all 0.3s ease;
border: 1px solid #e8e8e8;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.detail-card:hover {
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
transform: translateY(-2px);
}
.detail-label {
font-size: 13px;
font-weight: 600;
color: #666;
margin-bottom: 10px;
text-transform: uppercase;
letter-spacing: 0.5px;
display: flex;
align-items: center;
gap: 6px;
}
.detail-label::before {
content: "•";
color: #1890ff;
font-size: 16px;
}
.detail-value {
font-size: 15px;
color: #333;
line-height: 1.5;
font-weight: 400;
}
.detail-content-section {
margin-top: 32px;
}
.content-card {
background: linear-gradient(135deg, #f8f9fa, #ffffff);
border-radius: 12px;
padding: 24px;
border: 1px solid #e8e8e8;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.content-label {
font-size: 15px;
font-weight: 600;
color: #333;
margin-bottom: 16px;
display: flex;
align-items: center;
gap: 8px;
}
.content-label::before {
content: "🖼️";
font-size: 18px;
}
.detail-images {
display: flex;
gap: 16px;
flex-wrap: wrap;
margin-top: 16px;
}
.detail-image {
width: 160px;
height: 100px;
object-fit: cover;
border-radius: 4px;
cursor: pointer;
transition: transform 0.3s ease;
}
.detail-image:hover {
transform: scale(1.05);
}
.status-tag-large {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 8px 20px;
border-radius: 20px;
font-size: 14px;
font-weight: 600;
color: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.status-pending-large {
background-color: #faad14;
}
.status-pending-large::before {
content: "⏳";
}
.status-approved-large {
background-color: #52c41a;
}
.status-approved-large::before {
content: "✅";
}
.status-rejected-large {
background-color: #ff4d4f;
}
.status-rejected-large::before {
content: "❌";
}
/* 图片预览弹窗 */
.image-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.9);
display: none;
justify-content: center;
align-items: center;
z-index: 2000;
}
.image-modal-content {
position: relative;
max-width: 90%;
max-height: 90vh;
}
.image-modal img {
max-width: 100%;
max-height: 90vh;
object-fit: contain;
}
.image-modal-close {
position: absolute;
top: -40px;
right: 0;
background: none;
border: none;
font-size: 32px;
color: white;
cursor: pointer;
}
/* 滚动条样式 */
.modal-body::-webkit-scrollbar {
width: 8px;
}
.modal-body::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
background: #a8a8a8;
}
/* 响应式设计 */
@media (max-width: 768px) {
.container {
padding: 12px;
}
.header h1 {
font-size: 20px;
}
.search-box {
flex-direction: column;
}
.search-input {
min-width: auto;
}
.identity-meta {
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
.identity-actions {
flex-wrap: wrap;
}
.status-filter {
overflow-x: auto;
padding-bottom: 8px;
}
.filter-btn {
flex-shrink: 0;
}
.pagination-section {
justify-content: center;
}
}
</style>
</head>
<body>
<!-- 顶部导航栏 -->
<div class="header">
<div class="header-content">
<h1>身份信息审核</h1>
<div class="header-actions">
<button class="btn btn-primary" onclick="window.location.href='admin.html'">返回管理后台</button>
</div>
</div>
</div>
<div class="container">
<!-- 搜索和过滤区域 -->
<div class="search-filter-section">
<div class="search-filter-header">
<div class="status-filter">
<button class="filter-btn" data-status="all">全部</button>
<button class="filter-btn active" data-status="pending">待审核</button>
<button class="filter-btn" data-status="approved">已通过</button>
<button class="filter-btn" data-status="rejected">已拒绝</button>
</div>
<div class="date-filter">
<span>创建时间:</span>
<input type="date" class="date-input" id="startDateInput" placeholder="开始日期">
<span></span>
<input type="date" class="date-input" id="endDateInput" placeholder="结束日期">
<button class="btn btn-filter" onclick="handleDateFilter()">筛选</button>
<button class="btn btn-reset" onclick="resetDateFilter()">重置</button>
</div>
</div>
<div class="search-box">
<input type="text" class="search-input" id="searchInput" placeholder="搜索用户信息...">
<input type="text" class="search-input" id="phoneInput" placeholder="按手机号搜索...">
<button class="btn btn-search" onclick="handleSearch()">搜索</button>
<button class="btn btn-refresh" onclick="refreshIdentities()">刷新</button>
<button class="btn btn-approve" onclick="batchApproveIdentities()">批量通过</button>
<button class="btn btn-reject" onclick="batchRejectIdentities()">批量拒绝</button>
</div>
</div>
<!-- 身份信息列表区域 -->
<div class="identity-list-section">
<div class="identity-header">
<div style="display: flex; align-items: center; gap: 16px;">
<h2>身份信息列表</h2>
<div style="display: flex; align-items: center; gap: 8px;">
<input type="checkbox" id="selectAllCheckbox" style="width: 16px; height: 16px; cursor: pointer;">
<label for="selectAllCheckbox" style="cursor: pointer; font-size: 14px;">全选</label>
<span id="selectedCount" style="font-size: 14px; color: #666;">已选中 0 条</span>
</div>
</div>
<div class="identity-stats">
<span id="totalIdentities">共 0 条</span>
<span id="pendingIdentities" style="margin-left: 16px;">待审核: 0</span>
</div>
</div>
<div class="identity-list" id="identityList">
<div class="loading-state">
<div>加载中...</div>
</div>
</div>
</div>
<!-- 分页区域 -->
<div class="pagination-section" id="pagination">
<div class="page-size-selector">
<label for="pageSizeSelect">每页显示:</label>
<select id="pageSizeSelect" onchange="changePageSize(this.value)">
<option value="10" selected>10条</option>
<option value="30">30条</option>
<option value="50">50条</option>
<option value="100">100条</option>
</select>
</div>
<!-- 分页按钮将通过JavaScript动态生成 -->
</div>
</div>
<!-- 详情弹窗 -->
<div class="modal" id="detailModal">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">身份信息详情</h3>
<button class="modal-close" onclick="closeDetailModal()">×</button>
</div>
<div class="modal-body" id="detailContent">
<!-- 详情内容将通过JavaScript动态生成 -->
</div>
</div>
</div>
<!-- 图片预览弹窗 -->
<div class="image-modal" id="imageModal">
<div class="image-modal-content">
<button class="image-modal-close" onclick="closeImageModal()">×</button>
<img id="previewImage" src="" alt="预览图片">
</div>
</div>
<!-- 拒绝原因弹窗 -->
<div class="modal" id="rejectReasonModal">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">输入拒绝原因</h3>
<button class="modal-close" onclick="closeRejectReasonModal()">×</button>
</div>
<div class="modal-body">
<div id="rejectIdentityInfo" style="margin-bottom: 20px;">
<div style="font-weight: 500; margin-bottom: 12px;">审核信息:</div>
<div id="rejectIdentityDetails"></div>
</div>
<div style="display: flex; gap: 12px; justify-content: flex-end;">
<button class="btn" style="background-color: #666; color: white; border: 1px solid #666;" onclick="closeRejectReasonModal()">取消</button>
<button class="btn btn-reject" onclick="confirmRejectReason()">确定</button>
</div>
</div>
</div>
</div>
<script>
// 全局变量
let identities = [];
let currentPage = 1;
let pageSize = 10;
let currentStatus = 'pending';
let totalIdentities = 0;
let startDate = '';
let endDate = '';
let currentRejectId = null; // 当前正在拒绝的身份信息ID
// 缓存对象
const identityCache = {
// 缓存结构: { status: { startDate: { endDate: { pageSize: { page: data } } } } }
};
// 缓存有效期 (毫秒)
const CACHE_EXPIRY = 5 * 60 * 1000; // 5分钟
// 登录检查
function checkLogin() {
const loginInfo = localStorage.getItem('loginInfo');
if (!loginInfo) {
window.location.href = 'login.html';
return false;
}
const parsedLoginInfo = JSON.parse(loginInfo);
// 检查是否为管理员
if (parsedLoginInfo.projectName !== '管理员') {
alert('权限不足,只有管理员可以访问此页面');
window.location.href = 'login.html';
return false;
}
return true;
}
// 检查缓存是否有效
function isCacheValid(cacheEntry) {
return cacheEntry && cacheEntry.timestamp && (Date.now() - cacheEntry.timestamp) < CACHE_EXPIRY;
}
// 加载身份信息数据
async function loadIdentities() {
const identityListEl = document.getElementById('identityList');
identityListEl.innerHTML = '<div class="loading-state"><div>加载中...</div></div>';
try {
const searchKeyword = document.getElementById('searchInput').value.trim();
const phoneKeyword = document.getElementById('phoneInput').value.trim();
// 构建缓存键
const cacheKey = `${currentStatus}_${startDate || 'none'}_${endDate || 'none'}_${searchKeyword || 'none'}_${phoneKeyword || 'none'}`;
// 检查缓存
if (identityCache[cacheKey] && identityCache[cacheKey][pageSize] && identityCache[cacheKey][pageSize][currentPage] && isCacheValid(identityCache[cacheKey][pageSize][currentPage])) {
const cachedData = identityCache[cacheKey][pageSize][currentPage];
identities = cachedData.identities;
totalIdentities = cachedData.total;
const pendingTotal = cachedData.pendingTotal || 0;
// 更新统计信息
updateIdentityStats(pendingTotal);
// 显示身份信息
displayIdentities();
return;
}
// 构建查询参数
let queryParams = new URLSearchParams();
if (currentStatus !== 'all') {
let statusMap = {
'pending': 0,
'approved': 1,
'rejected': 2
};
queryParams.append('status', statusMap[currentStatus]);
}
if (startDate) {
queryParams.append('startDate', startDate);
}
if (endDate) {
queryParams.append('endDate', endDate);
}
if (searchKeyword || phoneKeyword) {
queryParams.append('search', searchKeyword || phoneKeyword);
}
queryParams.append('page', currentPage);
queryParams.append('pageSize', pageSize);
// 调用后端API获取身份信息数据
const response = await fetch(`/api/identities?${queryParams.toString()}`);
const data = await response.json();
if (data.success) {
console.log('获取到的身份信息数据:', data.identities);
identities = data.identities.map(identity => ({
id: identity.id,
userId: identity.userId,
phone: identity.phone,
idcard1: identity.idcard1,
idcard2: identity.idcard2,
businesslicenseurl: identity.businesslicenseurl,
idcardstatus: identity.idcardstatus,
reason: identity.reason,
created_at: identity.created_at,
newtime: identity.newtime
})).filter(identity => {
// 过滤掉idcardstatus为null的记录
return identity.idcardstatus !== null;
});
console.log('处理后的身份信息数据:', identities);
totalIdentities = identities.length;
const pendingTotal = identities.filter(identity => identity.idcardstatus === 0).length;
// 更新缓存
if (!identityCache[cacheKey]) {
identityCache[cacheKey] = {};
}
if (!identityCache[cacheKey][pageSize]) {
identityCache[cacheKey][pageSize] = {};
}
identityCache[cacheKey][pageSize][currentPage] = {
identities: [...identities],
total: totalIdentities,
pendingTotal: pendingTotal,
timestamp: Date.now()
};
// 更新统计信息
updateIdentityStats(pendingTotal);
// 显示身份信息
displayIdentities();
} else {
console.error('加载身份信息失败:', data.message);
identityListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">⚠️</div><h3>加载失败</h3><p>无法加载身份信息数据,请稍后重试</p></div>';
}
} catch (error) {
console.error('加载身份信息失败:', error);
identityListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">⚠️</div><h3>加载失败</h3><p>无法加载身份信息数据,请稍后重试</p></div>';
}
}
// 更新身份信息统计信息
function updateIdentityStats(pendingTotal) {
document.getElementById('totalIdentities').textContent = `${totalIdentities}`;
// 只有在全部和待审核标签页中显示待审核数量
if (currentStatus === 'all' || currentStatus === 'pending') {
document.getElementById('pendingIdentities').textContent = `待审核: ${pendingTotal}`;
document.getElementById('pendingIdentities').style.display = 'inline';
} else {
document.getElementById('pendingIdentities').style.display = 'none';
}
}
// 过滤身份信息(现在主要通过API参数过滤,前端过滤作为补充)
function filterIdentities() {
// 由于我们现在通过API参数进行过滤,这里只需要调用loadIdentities
loadIdentities();
}
// 显示身份信息
function displayIdentities() {
const identityListEl = document.getElementById('identityList');
if (identities.length === 0) {
identityListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">🆔</div><h3>暂无身份信息</h3><p>没有找到符合条件的身份信息</p></div>';
} else {
identityListEl.innerHTML = identities.map((identity, index) => {
let statusClass = '';
let statusText = '';
if (identity.idcardstatus === 0) {
statusClass = 'status-pending';
statusText = '待审核';
} else if (identity.idcardstatus === 1) {
statusClass = 'status-approved';
statusText = '已通过';
} else if (identity.idcardstatus === 2) {
statusClass = 'status-rejected';
statusText = '已拒绝';
}
// 计算序号,考虑分页
const serialNumber = (currentPage - 1) * pageSize + (index + 1);
return `
<div class="identity-item">
<div class="identity-meta">
<div class="identity-index">
<input type="checkbox" class="identity-checkbox" data-id="${identity.id}" ${identity.idcardstatus === 0 ? '' : 'disabled'}>
${serialNumber}
</div>
<div class="identity-info">
<div class="identity-author">
${identity.phone || '未知用户'}
${statusText ? `<span class="status-tag ${statusClass}">${statusText}</span>` : ''}
</div>
<div class="identity-details">
<span>用户ID: ${identity.userId}</span>
<span>入驻时间: ${formatDateTime(identity.newtime || identity.created_at)}</span>
</div>
</div>
</div>
<div class="identity-images">
${identity.idcard1 ? `<img src="${identity.idcard1}" alt="身份证正面" class="identity-image" onclick="showImagePreview('${identity.idcard1}')">` : '<span>无身份证正面</span>'}
${identity.idcard2 ? `<img src="${identity.idcard2}" alt="身份证反面" class="identity-image" onclick="showImagePreview('${identity.idcard2}')">` : '<span>无身份证反面</span>'}
${identity.businesslicenseurl ? `<img src="${identity.businesslicenseurl}" alt="营业执照" class="identity-image" onclick="showImagePreview('${identity.businesslicenseurl}')">` : '<span>无营业执照</span>'}
</div>
${identity.idcardstatus === 2 && identity.reason ? `
<div style="margin: 12px 0; padding: 12px; background-color: #fff2f0; border: 1px solid #ffccc7; border-radius: 4px; padding-left: 52px;">
<div style="font-weight: 500; margin-bottom: 4px; color: #cf1322;">拒绝原因:</div>
<div style="color: #cf1322;">${identity.reason}</div>
</div>
` : ''}
<div class="identity-actions">
${identity.idcardstatus === 0 ? `
<button class="btn btn-approve" onclick="approveIdentity(${identity.id})">审核通过</button>
<button class="btn btn-reject" onclick="rejectIdentity(${identity.id})">审核拒绝</button>
` : ''}
<button class="btn btn-details" onclick="showIdentityDetail(${identity.id})">查看详情</button>
</div>
</div>
`;
}).join('');
}
// 更新分页
updatePagination();
// 更新全选按钮状态
updateSelectAllStatus();
}
// 更新分页
function updatePagination() {
const paginationEl = document.getElementById('pagination');
const totalPages = Math.ceil(totalIdentities / pageSize);
if (totalPages <= 1) {
paginationEl.innerHTML = '<div class="page-size-selector"><label for="pageSizeSelect">每页显示:</label><select id="pageSizeSelect" onchange="changePageSize(this.value)"><option value="10" ' + (pageSize === 10 ? 'selected' : '') + '>10条</option><option value="30" ' + (pageSize === 30 ? 'selected' : '') + '>30条</option><option value="50" ' + (pageSize === 50 ? 'selected' : '') + '>50条</option><option value="100" ' + (pageSize === 100 ? 'selected' : '') + '>100条</option></select></div>';
return;
}
// 构建页面大小选择器
const pageSizeSelector = '<div class="page-size-selector"><label for="pageSizeSelect">每页显示:</label><select id="pageSizeSelect" onchange="changePageSize(this.value)"><option value="10" ' + (pageSize === 10 ? 'selected' : '') + '>10条</option><option value="30" ' + (pageSize === 30 ? 'selected' : '') + '>30条</option><option value="50" ' + (pageSize === 50 ? 'selected' : '') + '>50条</option><option value="100" ' + (pageSize === 100 ? 'selected' : '') + '>100条</option></select></div>';
let paginationHTML = pageSizeSelector;
// 上一页
paginationHTML += `<button class="page-btn" onclick="changePage(${currentPage - 1})" ${currentPage === 1 ? 'disabled' : ''}>上一页</button>`;
// 页码
const startPage = Math.max(1, currentPage - 2);
const endPage = Math.min(totalPages, startPage + 4);
for (let i = startPage; i <= endPage; i++) {
paginationHTML += `<button class="page-btn ${currentPage === i ? 'active' : ''}" onclick="changePage(${i})")">${i}</button>`;
}
// 下一页
paginationHTML += `<button class="page-btn" onclick="changePage(${currentPage + 1})" ${currentPage === totalPages ? 'disabled' : ''}>下一页</button>`;
paginationEl.innerHTML = paginationHTML;
}
// 更改页码
function changePage(page) {
const totalPages = Math.ceil(totalIdentities / pageSize);
if (page < 1 || page > totalPages) {
return;
}
currentPage = page;
loadIdentities();
}
// 处理搜索
function handleSearch() {
currentPage = 1;
filterIdentities();
}
// 刷新身份信息
function refreshIdentities() {
currentPage = 1;
loadIdentities();
}
// 审核通过
function approveIdentity(id) {
updateIdentityStatus(id, 1);
}
// 审核拒绝
function rejectIdentity(id) {
currentRejectId = id;
// 显示审核信息
const identity = identities.find(i => i.id === id);
if (identity) {
const index = identities.findIndex(i => i.id === id) + 1 + (currentPage - 1) * pageSize;
document.getElementById('rejectIdentityDetails').innerHTML = `
<div style="margin-bottom: 16px; padding: 16px; background-color: #f6ffed; border: 1px solid #b7eb8f; border-radius: 4px;">
<div style="margin-bottom: 8px;">序号:${index}</div>
<div style="margin-bottom: 12px;">电话号码:${identity.phone || '未知'}</div>
<div style="margin-bottom: 8px; font-weight: 500;">拒绝原因:</div>
<textarea id="rejectReasonInput" rows="3" style="width: 100%; padding: 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; resize: vertical;"></textarea>
<p style="margin-top: 8px; font-size: 12px; color: #999;">请详细说明拒绝原因,以便用户了解审核结果</p>
</div>
`;
} else {
document.getElementById('rejectIdentityDetails').innerHTML = '<div>未找到身份信息</div>';
}
document.getElementById('rejectReasonModal').style.display = 'flex';
}
// 关闭拒绝原因弹窗
function closeRejectReasonModal() {
document.getElementById('rejectReasonModal').style.display = 'none';
currentRejectId = null;
}
// 确认拒绝原因
function confirmRejectReason() {
if (Array.isArray(currentRejectId)) {
// 批量拒绝
const reasonInputs = document.querySelectorAll('.reject-reason-input');
const reasons = {};
let hasEmptyReason = false;
reasonInputs.forEach(input => {
const id = input.dataset.id;
const reason = input.value.trim();
if (!reason) {
hasEmptyReason = true;
}
reasons[id] = reason;
});
if (hasEmptyReason) {
alert('请为所有选中的身份信息输入拒绝原因');
return;
}
// 批量更新每条记录的状态和原因
batchUpdateIdentityStatusWithReasons(2, reasons);
} else {
// 单个拒绝
const reason = document.getElementById('rejectReasonInput').value.trim();
if (!reason) {
alert('请输入拒绝原因');
return;
}
updateIdentityStatus(currentRejectId, 2, reason);
}
closeRejectReasonModal();
}
// 批量审核通过
function batchApproveIdentities() {
batchUpdateIdentityStatus(1);
}
// 批量审核拒绝
function batchRejectIdentities() {
const selectedIds = getSelectedIdentityIds();
if (selectedIds.length === 0) {
alert('请先选择要审核的身份信息');
return;
}
currentRejectId = selectedIds;
// 显示选中的身份信息和独立的拒绝原因输入框
let detailsHtml = '';
selectedIds.forEach(id => {
const identity = identities.find(i => i.id === id);
if (identity) {
const index = identities.findIndex(i => i.id === id) + 1 + (currentPage - 1) * pageSize;
detailsHtml += `
<div style="margin-bottom: 20px; padding: 16px; background-color: #f6ffed; border: 1px solid #b7eb8f; border-radius: 4px;">
<div style="margin-bottom: 8px;">序号:${index}</div>
<div style="margin-bottom: 12px;">电话号码:${identity.phone || '未知'}</div>
<div style="margin-bottom: 8px; font-weight: 500;">拒绝原因:</div>
<textarea class="reject-reason-input" data-id="${id}" rows="3" style="width: 100%; padding: 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; resize: vertical;"></textarea>
<p style="margin-top: 8px; font-size: 12px; color: #999;">请详细说明拒绝原因,以便用户了解审核结果</p>
</div>
`;
}
});
document.getElementById('rejectIdentityDetails').innerHTML = detailsHtml || '<div>未找到身份信息</div>';
document.getElementById('rejectReasonModal').style.display = 'flex';
}
// 批量更新身份信息状态(带各自的拒绝原因)
async function batchUpdateIdentityStatusWithReasons(status, reasons) {
try {
// 遍历每个ID,单独更新
for (const id of currentRejectId) {
const reason = reasons[id];
await updateIdentityStatus(id, status, reason);
}
// 清除缓存,确保下次加载时获取最新数据
Object.keys(identityCache).forEach(key => {
delete identityCache[key];
});
// 显示成功提示
alert(`批量拒绝成功`);
// 重新过滤和显示
filterIdentities();
} catch (error) {
console.error('批量更新身份信息状态失败:', error);
alert('更新失败,请稍后重试');
}
}
// 更新身份信息状态
async function updateIdentityStatus(id, status, reason = '') {
try {
// 调用后端API更新数据库
const response = await fetch('/api/identities/update', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ id, idcardstatus: status, reason })
});
const data = await response.json();
if (data.success) {
// 更新本地数据
const identity = identities.find(i => i.id === id);
if (identity) {
identity.idcardstatus = status;
}
// 清除缓存,确保下次加载时获取最新数据
Object.keys(identityCache).forEach(key => {
delete identityCache[key];
});
// 显示成功提示
alert(status === 1 ? '审核通过' : '审核拒绝');
// 重新过滤和显示
filterIdentities();
} else {
alert('更新失败: ' + data.message);
}
} catch (error) {
console.error('更新身份信息状态失败:', error);
alert('更新失败,请稍后重试');
}
}
// 批量更新身份信息状态
async function batchUpdateIdentityStatus(status, reason = '') {
try {
const selectedIds = Array.isArray(currentRejectId) ? currentRejectId : getSelectedIdentityIds();
if (selectedIds.length === 0) {
alert('请先选择要审核的身份信息');
return;
}
// 调用后端API更新数据库
const response = await fetch('/api/identities/batch-update', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ ids: selectedIds, idcardstatus: status, reason })
});
const data = await response.json();
if (data.success) {
// 更新本地数据
selectedIds.forEach(id => {
const identity = identities.find(i => i.id === id);
if (identity) {
identity.idcardstatus = status;
}
});
// 清除缓存,确保下次加载时获取最新数据
Object.keys(identityCache).forEach(key => {
delete identityCache[key];
});
// 显示成功提示
alert(`批量${status === 1 ? '通过' : '拒绝'}成功`);
// 重新过滤和显示
filterIdentities();
} else {
alert('更新失败: ' + data.message);
}
} catch (error) {
console.error('批量更新身份信息状态失败:', error);
alert('更新失败,请稍后重试');
}
}
// 显示身份信息详情
function showIdentityDetail(id) {
const identity = identities.find(i => i.id === id);
if (identity) {
let statusText = '待审核';
let statusClass = 'status-pending-large';
if (identity.idcardstatus === 1) {
statusText = '已通过';
statusClass = 'status-approved-large';
} else if (identity.idcardstatus === 2) {
statusText = '已拒绝';
statusClass = 'status-rejected-large';
}
document.getElementById('detailContent').innerHTML = `
<div class="detail-grid">
<div class="detail-card">
<div class="detail-label">用户电话</div>
<div class="detail-value">${identity.phone || '未知'}</div>
</div>
<div class="detail-card">
<div class="detail-label">用户ID</div>
<div class="detail-value">${identity.userId}</div>
</div>
<div class="detail-card">
<div class="detail-label">入驻时间</div>
<div class="detail-value">${formatDateTime(identity.newtime || identity.created_at)}</div>
</div>
<div class="detail-card">
<div class="detail-label">审核状态</div>
<div class="detail-value">
<span class="status-tag-large ${statusClass}">${statusText}</span>
</div>
</div>
</div>
${identity.idcardstatus === 2 && identity.reason ? `
<div class="detail-content-section">
<div class="content-card">
<div class="content-label">拒绝原因</div>
<div style="padding: 16px; background-color: #fff2f0; border: 1px solid #ffccc7; border-radius: 8px; color: #cf1322;">
${identity.reason}
</div>
</div>
</div>
` : ''}
<div class="detail-content-section">
<div class="content-card">
<div class="content-label">证件图片</div>
<div class="detail-images">
${identity.idcard1 ? `<img src="${identity.idcard1}" alt="身份证正面" class="detail-image" onclick="showImagePreview('${identity.idcard1}')">` : '<span>无身份证正面</span>'}
${identity.idcard2 ? `<img src="${identity.idcard2}" alt="身份证反面" class="detail-image" onclick="showImagePreview('${identity.idcard2}')">` : '<span>无身份证反面</span>'}
${identity.businesslicenseurl ? `<img src="${identity.businesslicenseurl}" alt="营业执照" class="detail-image" onclick="showImagePreview('${identity.businesslicenseurl}')">` : '<span>无营业执照</span>'}
</div>
</div>
</div>
`;
document.getElementById('detailModal').style.display = 'flex';
}
}
// 关闭详情弹窗
function closeDetailModal() {
document.getElementById('detailModal').style.display = 'none';
}
// 显示图片预览
function showImagePreview(imageUrl) {
document.getElementById('previewImage').src = imageUrl;
document.getElementById('imageModal').style.display = 'flex';
}
// 关闭图片预览弹窗
function closeImageModal() {
document.getElementById('imageModal').style.display = 'none';
}
// 更改页面大小
function changePageSize(size) {
pageSize = parseInt(size);
currentPage = 1;
loadIdentities();
}
// 格式化日期时间
function formatDateTime(dateTimeStr) {
if (!dateTimeStr) return '';
const date = new Date(dateTimeStr);
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
}
// 处理时间筛选
function handleDateFilter() {
startDate = document.getElementById('startDateInput').value;
endDate = document.getElementById('endDateInput').value;
currentPage = 1;
loadIdentities();
}
// 重置时间筛选
function resetDateFilter() {
document.getElementById('startDateInput').value = '';
document.getElementById('endDateInput').value = '';
startDate = '';
endDate = '';
currentPage = 1;
loadIdentities();
}
// 绑定事件
function bindEvents() {
// 状态过滤按钮
document.querySelectorAll('.filter-btn').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
currentStatus = btn.dataset.status;
currentPage = 1;
filterIdentities();
});
});
// 回车键搜索
document.getElementById('searchInput').addEventListener('keypress', (e) => {
if (e.key === 'Enter') handleSearch();
});
document.getElementById('phoneInput').addEventListener('keypress', (e) => {
if (e.key === 'Enter') handleSearch();
});
// 输入框内容变化时自动搜索
document.getElementById('searchInput').addEventListener('input', () => {
handleSearch();
});
document.getElementById('phoneInput').addEventListener('input', () => {
handleSearch();
});
// 点击弹窗外部关闭
document.getElementById('detailModal').addEventListener('click', (e) => {
if (e.target === document.getElementById('detailModal')) {
closeDetailModal();
}
});
document.getElementById('imageModal').addEventListener('click', (e) => {
if (e.target === document.getElementById('imageModal')) {
closeImageModal();
}
});
// 点击拒绝原因弹窗外部关闭
document.getElementById('rejectReasonModal').addEventListener('click', (e) => {
if (e.target === document.getElementById('rejectReasonModal')) {
closeRejectReasonModal();
}
});
// 全选功能
if (document.getElementById('selectAllCheckbox')) {
document.getElementById('selectAllCheckbox').addEventListener('change', function() {
const checkboxes = document.querySelectorAll('.identity-checkbox:not(:disabled)');
checkboxes.forEach(checkbox => {
checkbox.checked = this.checked;
});
// 更新已选中数量
updateSelectedCount();
});
}
// 单个勾选框变化时更新全选状态
document.addEventListener('change', function(e) {
if (e.target.classList.contains('identity-checkbox') && !e.target.disabled) {
updateSelectAllStatus();
}
});
}
// 更新全选按钮状态
function updateSelectAllStatus() {
const checkboxes = document.querySelectorAll('.identity-checkbox:not(:disabled)');
const checkedBoxes = document.querySelectorAll('.identity-checkbox:not(:disabled):checked');
const selectAllCheckbox = document.getElementById('selectAllCheckbox');
if (selectAllCheckbox) {
if (checkboxes.length === 0) {
selectAllCheckbox.checked = false;
selectAllCheckbox.disabled = true;
} else {
selectAllCheckbox.disabled = false;
selectAllCheckbox.checked = checkboxes.length === checkedBoxes.length;
}
}
// 更新已选中数量
updateSelectedCount();
}
// 更新已选中数量显示
function updateSelectedCount() {
const checkedBoxes = document.querySelectorAll('.identity-checkbox:not(:disabled):checked');
const selectedCountElement = document.getElementById('selectedCount');
if (selectedCountElement) {
selectedCountElement.textContent = `已选中 ${checkedBoxes.length}`;
}
}
// 获取选中的身份信息ID列表
function getSelectedIdentityIds() {
const checkboxes = document.querySelectorAll('.identity-checkbox:checked');
return Array.from(checkboxes).map(checkbox => parseInt(checkbox.dataset.id));
}
// 初始化
window.onload = function() {
if (!checkLogin()) {
return;
}
loadIdentities();
bindEvents();
};
</script>
</body>
</html>