diff --git a/admin/customer_service.php b/admin/customer_service.php index c943656..fa3cf9a 100644 --- a/admin/customer_service.php +++ b/admin/customer_service.php @@ -250,15 +250,20 @@ let currentUserContext = ''; async function refreshUsers() { try { + const list = document.getElementById('user-list'); + if (!list) return; + const searchInput = document.getElementById('user-search'); const search = searchInput ? searchInput.value.toLowerCase() : ''; const r = await fetch('/api/chat.php?action=admin_get_all'); + if (!r.ok) { + list.innerHTML = `
接口响应错误: ${r.status}
`; + return; + } + const users = await r.json(); - const list = document.getElementById('user-list'); - if (!list) return; - if (users.error) { list.innerHTML = `
接口错误: ${users.error}
`; return; @@ -277,19 +282,21 @@ async function refreshUsers() { let html = ''; users.forEach(u => { const userId = u.user_id || 0; - const username = (u.username || '匿名用户').toString(); + const username = (u.username || '匿名访客').toString(); const uid = (u.uid || '---').toString(); const ip = (u.ip_address || '---').toString(); const rawRemark = (u.remark || '').toString(); const userTime = (u.user_time || '---').toString(); - const lastTimeStr = u.created_at ? u.created_at.replace(/-/g, "/") : new Date().toISOString(); - const lastTime = new Date(lastTimeStr); // Search filter if (search && !username.toLowerCase().includes(search) && !ip.includes(search) && !uid.includes(search)) { return; } + const createdAt = u.created_at || ''; + const lastTimeStr = createdAt ? createdAt.replace(/-/g, "/") : new Date().toISOString(); + const lastTime = new Date(lastTimeStr); + let lastMsgText = (u.message || '').toString(); if (lastMsgText.startsWith('[PAYMENT_INFO]')) { lastMsgText = '[收款账号信息]'; @@ -322,7 +329,7 @@ async function refreshUsers() { console.error('Refresh users failed:', err); const list = document.getElementById('user-list'); if (list) { - list.innerHTML = `
脚本运行错误,请刷新页面
`; + list.innerHTML = `
脚本运行错误: ${err.message}
`; } } } @@ -440,10 +447,30 @@ function appendMessageHTML(m) { if (isPaymentInfo) { try { const info = JSON.parse(displayMsg.replace('[PAYMENT_INFO]', '')); - displayMsg = `
-
已发送收款账号
-
${info.bank} - ${info.name}
-
`; + displayMsg = ` +
+
+ 已发送收款账户 +
+
+
银行名称
+
${info.bank}
+
+
+
收款账号
+
${info.account}
+
+
+
收款姓名
+
${info.name}
+
+ ${info.note ? ` +
+
备注
+
${info.note}
+
` : ''} +
+ `; } catch(e) { displayMsg = '[支付信息错误]'; } } @@ -607,9 +634,14 @@ document.getElementById('save-remark-btn').addEventListener('click', async () => document.getElementById('user-search').addEventListener('input', refreshUsers); -setInterval(refreshUsers, 2000); -setInterval(fetchMessages, 2000); -refreshUsers(); +// Polling logic +async function startPolling() { + await refreshUsers(); + await fetchMessages(); + setTimeout(startPolling, 3000); +} + +startPolling(); fetchAll();
返回

+ 条记录
充值审核 diff --git a/admin/layout.php b/admin/layout.php index 9fe3e41..bd1e352 100644 --- a/admin/layout.php +++ b/admin/layout.php @@ -46,6 +46,7 @@ function renderAdminPage($content, $title = '后台管理') { <?= $title ?> - <?= $site_name ?> + @@ -265,7 +266,6 @@ function renderAdminPage($content, $title = '后台管理') {
-