136 lines
4.7 KiB
PHP
136 lines
4.7 KiB
PHP
|
|
<?php
|
||
|
|
// 获取反馈列表
|
||
|
|
try {
|
||
|
|
$stmt = $pdo->query("
|
||
|
|
SELECT f.*, u.username
|
||
|
|
FROM feedbacks f
|
||
|
|
LEFT JOIN users u ON f.user_id = u.id
|
||
|
|
ORDER BY f.created_at DESC
|
||
|
|
LIMIT 50
|
||
|
|
");
|
||
|
|
$feedbacks = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||
|
|
} catch(PDOException $e) {
|
||
|
|
$feedbacks = [];
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<div class="admin-section">
|
||
|
|
<h3>用户反馈</h3>
|
||
|
|
|
||
|
|
<div class="table-responsive">
|
||
|
|
<table class="admin-table">
|
||
|
|
<thead>
|
||
|
|
<tr>
|
||
|
|
<th>ID</th>
|
||
|
|
<th>用户</th>
|
||
|
|
<th>类型</th>
|
||
|
|
<th>主题</th>
|
||
|
|
<th>内容</th>
|
||
|
|
<th>状态</th>
|
||
|
|
<th>提交时间</th>
|
||
|
|
<th>操作</th>
|
||
|
|
</tr>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
<?php foreach($feedbacks as $feedback): ?>
|
||
|
|
<tr>
|
||
|
|
<td><?php echo $feedback['id']; ?></td>
|
||
|
|
<td>
|
||
|
|
<?php if($feedback['username']): ?>
|
||
|
|
<?php echo htmlspecialchars($feedback['username']); ?>
|
||
|
|
<?php else: ?>
|
||
|
|
<em>匿名用户</em>
|
||
|
|
<?php endif; ?>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<?php
|
||
|
|
$typeLabels = [
|
||
|
|
'bug' => '错误报告',
|
||
|
|
'feature' => '功能建议',
|
||
|
|
'suggestion' => '改进建议',
|
||
|
|
'other' => '其他'
|
||
|
|
];
|
||
|
|
echo $typeLabels[$feedback['type']] ?? $feedback['type'];
|
||
|
|
?>
|
||
|
|
</td>
|
||
|
|
<td><?php echo htmlspecialchars($feedback['subject']); ?></td>
|
||
|
|
<td>
|
||
|
|
<div style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">
|
||
|
|
<?php echo htmlspecialchars($feedback['message']); ?>
|
||
|
|
</div>
|
||
|
|
</td>
|
||
|
|
<td>
|
||
|
|
<select onchange="updateFeedbackStatus(<?php echo $feedback['id']; ?>, this.value)">
|
||
|
|
<option value="pending" <?php echo $feedback['status'] === 'pending' ? 'selected' : ''; ?>>待处理</option>
|
||
|
|
<option value="reviewed" <?php echo $feedback['status'] === 'reviewed' ? 'selected' : ''; ?>>已审核</option>
|
||
|
|
<option value="resolved" <?php echo $feedback['status'] === 'resolved' ? 'selected' : ''; ?>>已解决</option>
|
||
|
|
</select>
|
||
|
|
</td>
|
||
|
|
<td><?php echo date('Y-m-d H:i', strtotime($feedback['created_at'])); ?></td>
|
||
|
|
<td>
|
||
|
|
<div class="admin-actions">
|
||
|
|
<button class="btn btn-sm" onclick="viewFeedback(<?php echo $feedback['id']; ?>)">
|
||
|
|
查看详情
|
||
|
|
</button>
|
||
|
|
<button class="btn btn-sm btn-danger"
|
||
|
|
onclick="deleteFeedback(<?php echo $feedback['id']; ?>)">
|
||
|
|
删除
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
<?php endforeach; ?>
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
function updateFeedbackStatus(feedbackId, newStatus) {
|
||
|
|
fetch('admin/ajax_update_feedback.php', {
|
||
|
|
method: 'POST',
|
||
|
|
headers: {
|
||
|
|
'Content-Type': 'application/json',
|
||
|
|
},
|
||
|
|
body: JSON.stringify({
|
||
|
|
feedback_id: feedbackId,
|
||
|
|
status: newStatus
|
||
|
|
})
|
||
|
|
})
|
||
|
|
.then(response => response.json())
|
||
|
|
.then(data => {
|
||
|
|
if (data.success) {
|
||
|
|
alert('反馈状态更新成功!');
|
||
|
|
} else {
|
||
|
|
alert('更新失败: ' + data.error);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
function viewFeedback(feedbackId) {
|
||
|
|
// 这里可以打开一个模态框显示完整反馈内容
|
||
|
|
alert('查看反馈详情功能开发中...');
|
||
|
|
}
|
||
|
|
|
||
|
|
function deleteFeedback(feedbackId) {
|
||
|
|
if (!confirm('确定要删除这条反馈吗?')) return;
|
||
|
|
|
||
|
|
fetch('admin/ajax_delete_feedback.php', {
|
||
|
|
method: 'POST',
|
||
|
|
headers: {
|
||
|
|
'Content-Type': 'application/json',
|
||
|
|
},
|
||
|
|
body: JSON.stringify({
|
||
|
|
feedback_id: feedbackId
|
||
|
|
})
|
||
|
|
})
|
||
|
|
.then(response => response.json())
|
||
|
|
.then(data => {
|
||
|
|
if (data.success) {
|
||
|
|
alert('反馈删除成功!');
|
||
|
|
location.reload();
|
||
|
|
} else {
|
||
|
|
alert('删除失败: ' + data.error);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
</script>
|