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.
1451 lines
49 KiB
1451 lines
49 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);
|
|
}
|
|
|
|
/* 留言列表区域 */
|
|
.comment-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%;
|
|
}
|
|
|
|
.comment-header {
|
|
padding: 16px 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
background-color: #fafafa;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.comment-header h2 {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
margin: 0;
|
|
color: #333;
|
|
}
|
|
|
|
.comment-stats {
|
|
font-size: 14px;
|
|
color: #666;
|
|
}
|
|
|
|
.comment-list {
|
|
/* 取消内部滚轮,使用外部滚轮 */
|
|
}
|
|
|
|
/* 序号样式 */
|
|
.comment-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;
|
|
}
|
|
|
|
/* 勾选框样式 */
|
|
.comment-checkbox {
|
|
margin: 0;
|
|
width: 16px;
|
|
height: 16px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.comment-checkbox:disabled {
|
|
cursor: not-allowed;
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.comment-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);
|
|
}
|
|
|
|
.comment-item:hover {
|
|
background-color: #fafafa;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.comment-item:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.comment-meta {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.comment-info {
|
|
flex: 1;
|
|
}
|
|
|
|
.comment-author {
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: #333;
|
|
margin-bottom: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.comment-details {
|
|
font-size: 12px;
|
|
color: #999;
|
|
display: flex;
|
|
gap: 16px;
|
|
flex-wrap: wrap;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.comment-content {
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
color: #333;
|
|
margin-bottom: 16px;
|
|
white-space: pre-wrap;
|
|
word-break: break-word;
|
|
padding-left: 52px;
|
|
}
|
|
|
|
.comment-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;
|
|
}
|
|
|
|
.content-value {
|
|
font-size: 15px;
|
|
color: #333;
|
|
line-height: 1.7;
|
|
white-space: pre-wrap;
|
|
word-break: break-word;
|
|
padding: 16px;
|
|
background-color: #ffffff;
|
|
border-radius: 8px;
|
|
border: 1px solid #f0f0f0;
|
|
}
|
|
|
|
.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: "❌";
|
|
}
|
|
|
|
/* 滚动条样式 */
|
|
.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;
|
|
}
|
|
|
|
.comment-meta {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 8px;
|
|
}
|
|
|
|
.comment-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="refreshComments()">刷新</button>
|
|
<button class="btn btn-approve" onclick="batchApproveComments()">批量通过</button>
|
|
<button class="btn btn-reject" onclick="batchRejectComments()">批量拒绝</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 留言列表区域 -->
|
|
<div class="comment-list-section">
|
|
<div class="comment-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="comment-stats">
|
|
<span id="totalComments">共 0 条</span>
|
|
<span id="pendingComments" style="margin-left: 16px;">待审核: 0</span>
|
|
</div>
|
|
</div>
|
|
<div class="comment-list" id="commentList">
|
|
<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>
|
|
|
|
<script>
|
|
// 全局变量
|
|
let comments = [];
|
|
let filteredComments = [];
|
|
let currentPage = 1;
|
|
let pageSize = 10;
|
|
let currentStatus = 'pending';
|
|
let totalComments = 0;
|
|
let startDate = '';
|
|
let endDate = '';
|
|
|
|
// 缓存对象
|
|
const commentCache = {
|
|
// 缓存结构: { 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 loadComments() {
|
|
const commentListEl = document.getElementById('commentList');
|
|
commentListEl.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 (commentCache[cacheKey] && commentCache[cacheKey][pageSize] && commentCache[cacheKey][pageSize][currentPage] && isCacheValid(commentCache[cacheKey][pageSize][currentPage])) {
|
|
const cachedData = commentCache[cacheKey][pageSize][currentPage];
|
|
comments = cachedData.comments;
|
|
totalComments = cachedData.total;
|
|
const pendingTotal = cachedData.pendingTotal || 0;
|
|
|
|
// 更新统计信息
|
|
updateCommentStats(pendingTotal);
|
|
|
|
// 显示留言
|
|
displayComments();
|
|
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/comments?${queryParams.toString()}`);
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
comments = data.comments.map(comment => ({
|
|
id: comment.id,
|
|
phoneNumber: comment.phoneNumber,
|
|
productId: comment.productId,
|
|
time: comment.time,
|
|
comments: comment.comments,
|
|
review: comment.review,
|
|
like: comment.like || 0,
|
|
hate: comment.hate || 0
|
|
}));
|
|
|
|
totalComments = data.total;
|
|
const pendingTotal = data.pendingTotal || 0;
|
|
|
|
// 更新缓存
|
|
if (!commentCache[cacheKey]) {
|
|
commentCache[cacheKey] = {};
|
|
}
|
|
if (!commentCache[cacheKey][pageSize]) {
|
|
commentCache[cacheKey][pageSize] = {};
|
|
}
|
|
commentCache[cacheKey][pageSize][currentPage] = {
|
|
comments: [...comments],
|
|
total: totalComments,
|
|
pendingTotal: pendingTotal,
|
|
timestamp: Date.now()
|
|
};
|
|
|
|
// 更新统计信息
|
|
updateCommentStats(pendingTotal);
|
|
|
|
// 显示留言
|
|
displayComments();
|
|
} else {
|
|
console.error('加载留言失败:', data.message);
|
|
commentListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">⚠️</div><h3>加载失败</h3><p>无法加载留言数据,请稍后重试</p></div>';
|
|
}
|
|
} catch (error) {
|
|
console.error('加载留言失败:', error);
|
|
commentListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">⚠️</div><h3>加载失败</h3><p>无法加载留言数据,请稍后重试</p></div>';
|
|
}
|
|
}
|
|
|
|
// 更新留言统计信息
|
|
function updateCommentStats(pendingTotal) {
|
|
document.getElementById('totalComments').textContent = `共 ${totalComments} 条`;
|
|
|
|
// 只有在全部和待审核标签页中显示待审核数量
|
|
if (currentStatus === 'all' || currentStatus === 'pending') {
|
|
document.getElementById('pendingComments').textContent = `待审核: ${pendingTotal}`;
|
|
document.getElementById('pendingComments').style.display = 'inline';
|
|
} else {
|
|
document.getElementById('pendingComments').style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// 过滤留言(现在主要通过API参数过滤,前端过滤作为补充)
|
|
function filterComments() {
|
|
// 由于我们现在通过API参数进行过滤,这里只需要调用loadComments
|
|
loadComments();
|
|
}
|
|
|
|
// 显示留言
|
|
function displayComments() {
|
|
const commentListEl = document.getElementById('commentList');
|
|
|
|
if (comments.length === 0) {
|
|
commentListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">📝</div><h3>暂无留言</h3><p>没有找到符合条件的留言</p></div>';
|
|
} else {
|
|
commentListEl.innerHTML = comments.map((comment, index) => {
|
|
let statusClass = 'status-pending';
|
|
let statusText = '待审核';
|
|
|
|
if (comment.review === 1) {
|
|
statusClass = 'status-approved';
|
|
statusText = '已通过';
|
|
} else if (comment.review === 2) {
|
|
statusClass = 'status-rejected';
|
|
statusText = '已拒绝';
|
|
}
|
|
|
|
// 计算序号,考虑分页
|
|
const serialNumber = (currentPage - 1) * pageSize + (index + 1);
|
|
|
|
return `
|
|
<div class="comment-item">
|
|
<div class="comment-meta">
|
|
<div class="comment-index" style="display: flex; align-items: center; gap: 8px;">
|
|
<input type="checkbox" class="comment-checkbox" data-id="${comment.id}" ${(comment.review === 0 || comment.review === null) ? '' : 'disabled'}>
|
|
${serialNumber}
|
|
</div>
|
|
<div class="comment-info">
|
|
<div class="comment-author">
|
|
${comment.phoneNumber}
|
|
<span class="status-tag ${statusClass}">${statusText}</span>
|
|
</div>
|
|
<div class="comment-details">
|
|
<span>产品ID: ${comment.productId}</span>
|
|
<span>评论时间: ${utcToBeijingTime(comment.time)}</span>
|
|
<span>点赞: ${comment.like}</span>
|
|
<span>点踩: ${comment.hate}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="comment-content">${comment.comments}</div>
|
|
<div class="comment-actions">
|
|
${comment.review === 0 || comment.review === null ? `
|
|
<button class="btn btn-approve" onclick="approveComment(${comment.id})">审核通过</button>
|
|
<button class="btn btn-reject" onclick="rejectComment(${comment.id})">审核拒绝</button>
|
|
` : ''}
|
|
<button class="btn btn-details" onclick="showCommentDetail(${comment.id})">查看详情</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// 更新分页
|
|
updatePagination();
|
|
|
|
// 更新全选按钮状态
|
|
updateSelectAllStatus();
|
|
}
|
|
|
|
// 更新分页
|
|
function updatePagination() {
|
|
const paginationEl = document.getElementById('pagination');
|
|
const totalPages = Math.ceil(totalComments / 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(totalComments / pageSize);
|
|
if (page < 1 || page > totalPages) {
|
|
return;
|
|
}
|
|
currentPage = page;
|
|
loadComments();
|
|
}
|
|
|
|
// 处理搜索
|
|
function handleSearch() {
|
|
currentPage = 1;
|
|
filterComments();
|
|
}
|
|
|
|
// 刷新留言
|
|
function refreshComments() {
|
|
currentPage = 1;
|
|
loadComments();
|
|
}
|
|
|
|
// 审核通过
|
|
function approveComment(id) {
|
|
updateCommentStatus(id, 1);
|
|
}
|
|
|
|
// 审核拒绝
|
|
function rejectComment(id) {
|
|
updateCommentStatus(id, 2);
|
|
}
|
|
|
|
// 更新留言状态
|
|
async function updateCommentStatus(id, status) {
|
|
try {
|
|
// 调用后端API更新数据库
|
|
const response = await fetch('/api/comments/update', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ id, review: status })
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
// 更新本地数据
|
|
const comment = comments.find(c => c.id === id);
|
|
if (comment) {
|
|
comment.review = status;
|
|
}
|
|
|
|
// 清除缓存,确保下次加载时获取最新数据
|
|
Object.keys(commentCache).forEach(key => {
|
|
delete commentCache[key];
|
|
});
|
|
|
|
// 显示成功提示
|
|
alert(status === 1 ? '审核通过' : '审核拒绝');
|
|
|
|
// 重新过滤和显示
|
|
filterComments();
|
|
} else {
|
|
alert('更新失败: ' + data.message);
|
|
}
|
|
} catch (error) {
|
|
console.error('更新留言状态失败:', error);
|
|
alert('更新失败,请稍后重试');
|
|
}
|
|
}
|
|
|
|
// 显示留言详情
|
|
function showCommentDetail(id) {
|
|
const comment = comments.find(c => c.id === id);
|
|
if (comment) {
|
|
let statusText = '待审核';
|
|
let statusClass = 'status-pending-large';
|
|
|
|
if (comment.review === 1) {
|
|
statusText = '已通过';
|
|
statusClass = 'status-approved-large';
|
|
} else if (comment.review === 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">${comment.phoneNumber}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">产品ID</div>
|
|
<div class="detail-value">${comment.productId}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">评论时间</div>
|
|
<div class="detail-value">${utcToBeijingTime(comment.time)}</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 class="detail-card">
|
|
<div class="detail-label">点赞数</div>
|
|
<div class="detail-value">${comment.like}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">点踩数</div>
|
|
<div class="detail-value">${comment.hate}</div>
|
|
</div>
|
|
</div>
|
|
<div class="detail-content-section">
|
|
<div class="content-card">
|
|
<div class="content-label">评论内容</div>
|
|
<div class="content-value">${comment.comments}</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
document.getElementById('detailModal').style.display = 'flex';
|
|
}
|
|
}
|
|
|
|
// 关闭详情弹窗
|
|
function closeDetailModal() {
|
|
document.getElementById('detailModal').style.display = 'none';
|
|
}
|
|
|
|
// 更改页面大小
|
|
function changePageSize(size) {
|
|
pageSize = parseInt(size);
|
|
currentPage = 1;
|
|
loadComments();
|
|
}
|
|
|
|
// 将UTC时间转换为北京时间
|
|
function utcToBeijingTime(utcTime) {
|
|
if (!utcTime) return '';
|
|
const date = new Date(utcTime);
|
|
date.setHours(date.getHours() + 8); // UTC+8
|
|
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
const hours = String(date.getHours()).padStart(2, '0');
|
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
const seconds = String(date.getSeconds()).padStart(2, '0');
|
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
}
|
|
|
|
// 处理时间筛选
|
|
function handleDateFilter() {
|
|
startDate = document.getElementById('startDateInput').value;
|
|
endDate = document.getElementById('endDateInput').value;
|
|
currentPage = 1;
|
|
loadComments();
|
|
}
|
|
|
|
// 重置时间筛选
|
|
function resetDateFilter() {
|
|
document.getElementById('startDateInput').value = '';
|
|
document.getElementById('endDateInput').value = '';
|
|
startDate = '';
|
|
endDate = '';
|
|
currentPage = 1;
|
|
loadComments();
|
|
}
|
|
|
|
// 绑定事件
|
|
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;
|
|
filterComments();
|
|
});
|
|
});
|
|
|
|
// 回车键搜索
|
|
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();
|
|
}
|
|
});
|
|
|
|
// 全选功能
|
|
if (document.getElementById('selectAllCheckbox')) {
|
|
document.getElementById('selectAllCheckbox').addEventListener('change', function() {
|
|
const checkboxes = document.querySelectorAll('.comment-checkbox:not(:disabled)');
|
|
checkboxes.forEach(checkbox => {
|
|
checkbox.checked = this.checked;
|
|
});
|
|
// 更新已选中数量
|
|
updateSelectedCount();
|
|
});
|
|
}
|
|
|
|
// 单个勾选框变化时更新全选状态
|
|
document.addEventListener('change', function(e) {
|
|
if (e.target.classList.contains('comment-checkbox') && !e.target.disabled) {
|
|
updateSelectAllStatus();
|
|
}
|
|
});
|
|
}
|
|
|
|
// 更新全选按钮状态
|
|
function updateSelectAllStatus() {
|
|
const checkboxes = document.querySelectorAll('.comment-checkbox:not(:disabled)');
|
|
const checkedBoxes = document.querySelectorAll('.comment-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('.comment-checkbox:not(:disabled):checked');
|
|
const selectedCountElement = document.getElementById('selectedCount');
|
|
|
|
if (selectedCountElement) {
|
|
selectedCountElement.textContent = `已选中 ${checkedBoxes.length} 条`;
|
|
}
|
|
}
|
|
|
|
// 获取选中的评论ID列表
|
|
function getSelectedCommentIds() {
|
|
const checkboxes = document.querySelectorAll('.comment-checkbox:checked');
|
|
return Array.from(checkboxes).map(checkbox => parseInt(checkbox.dataset.id));
|
|
}
|
|
|
|
// 批量审核通过
|
|
function batchApproveComments() {
|
|
batchUpdateCommentStatus(1);
|
|
}
|
|
|
|
// 批量审核拒绝
|
|
function batchRejectComments() {
|
|
batchUpdateCommentStatus(2);
|
|
}
|
|
|
|
// 批量更新评论状态
|
|
async function batchUpdateCommentStatus(status) {
|
|
try {
|
|
const selectedIds = getSelectedCommentIds();
|
|
|
|
if (selectedIds.length === 0) {
|
|
alert('请先选择要审核的留言');
|
|
return;
|
|
}
|
|
|
|
// 调用后端API更新数据库
|
|
const response = await fetch('/api/comments/batch-update', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ ids: selectedIds, review: status })
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
// 更新本地数据
|
|
selectedIds.forEach(id => {
|
|
const comment = comments.find(c => c.id === id);
|
|
if (comment) {
|
|
comment.review = status;
|
|
}
|
|
});
|
|
|
|
// 清除缓存,确保下次加载时获取最新数据
|
|
Object.keys(commentCache).forEach(key => {
|
|
delete commentCache[key];
|
|
});
|
|
|
|
// 显示成功提示
|
|
alert(`批量${status === 1 ? '通过' : '拒绝'}成功`);
|
|
|
|
// 重新过滤和显示
|
|
filterComments();
|
|
} else {
|
|
alert('更新失败: ' + data.message);
|
|
}
|
|
} catch (error) {
|
|
console.error('批量更新评论状态失败:', error);
|
|
alert('更新失败,请稍后重试');
|
|
}
|
|
}
|
|
|
|
// 初始化
|
|
window.onload = function() {
|
|
if (!checkLogin()) {
|
|
return;
|
|
}
|
|
|
|
loadComments();
|
|
bindEvents();
|
|
};
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|