diff --git a/invite.html b/invite.html
index a71f077..2bfd123 100644
--- a/invite.html
+++ b/invite.html
@@ -186,6 +186,7 @@
+
diff --git a/qr-collection.html b/qr-collection.html
new file mode 100644
index 0000000..80e8e38
--- /dev/null
+++ b/qr-collection.html
@@ -0,0 +1,428 @@
+
+
+
+
+
+ 二维码合集
+
+
+
+
+
+
+
+
筛选
+
+
+
+
+
+
+
+
+
+

+
暂无二维码
+
请先生成邀请二维码
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/server.js b/server.js
index d92b9f4..238b5fa 100644
--- a/server.js
+++ b/server.js
@@ -90,11 +90,12 @@ const server = http.createServer(async (req, res) => {
const formData = new URLSearchParams(body);
const userName = formData.get('userName');
const password = formData.get('password');
+ const projectName = formData.get('projectName');
- console.log('接收到的登录请求:', { userName });
+ console.log('接收到的登录请求:', { userName, projectName });
// 验证输入
- if (!userName || !password) {
+ if (!userName || !password || !projectName) {
res.writeHead(400, {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
@@ -103,7 +104,7 @@ const server = http.createServer(async (req, res) => {
});
res.end(JSON.stringify({
success: false,
- error: '请输入用户名和密码'
+ error: '请输入用户名、密码和职位名称'
}));
return;
}
@@ -117,7 +118,7 @@ const server = http.createServer(async (req, res) => {
// 验证用户名、密码和职位名称
const [loginRows] = await userloginPool.execute(
'SELECT * FROM login WHERE userName = ? AND password = ? AND projectName = ?',
- [userName, password, formData.get('projectName')]
+ [userName, password, projectName]
);
if (loginRows.length === 0) {
@@ -129,7 +130,7 @@ const server = http.createServer(async (req, res) => {
});
res.end(JSON.stringify({
success: false,
- error: '用户名或密码错误'
+ error: '用户名、密码或职位名称错误'
}));
return;
}
@@ -208,6 +209,57 @@ const server = http.createServer(async (req, res) => {
return;
}
+ // 获取二维码合集接口
+ if (req.method === 'GET' && req.url === '/getQrCollection') {
+ try {
+ // 从数据库获取所有的合格证信息
+ const [rows] = await pool.execute(
+ 'SELECT inviter, inviter_phone as inviterPhone, projectName as inviterProjectName, sessionId, DATE_FORMAT(issueDate, "%Y-%m-%d %H:%i:%s") as createdAt FROM certificate GROUP BY sessionId ORDER BY issueDate DESC'
+ );
+
+ // 生成二维码URL列表
+ const qrCodes = rows.map(row => {
+ // 生成包含会话ID的URL
+ const url = `http://8.137.125.67:3008/certificate.html?sessionId=${encodeURIComponent(row.sessionId)}&inviter=${encodeURIComponent(row.inviter)}&inviterPhone=${encodeURIComponent(row.inviterPhone)}&inviterProjectName=${encodeURIComponent(row.inviterProjectName)}`;
+
+ return {
+ inviter: row.inviter,
+ inviterPhone: row.inviterPhone,
+ inviterProjectName: row.inviterProjectName,
+ sessionId: row.sessionId,
+ createdAt: row.createdAt,
+ url: url
+ };
+ });
+
+ console.log('获取二维码合集成功,数量:', qrCodes.length);
+
+ res.writeHead(200, {
+ 'Content-Type': 'application/json',
+ 'Access-Control-Allow-Origin': '*',
+ 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
+ 'Access-Control-Allow-Headers': 'Content-Type'
+ });
+ res.end(JSON.stringify({
+ success: true,
+ qrCodes: qrCodes
+ }));
+ } catch (error) {
+ console.error('获取二维码合集失败:', error.message);
+ res.writeHead(500, {
+ 'Content-Type': 'application/json',
+ 'Access-Control-Allow-Origin': '*',
+ 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
+ 'Access-Control-Allow-Headers': 'Content-Type'
+ });
+ res.end(JSON.stringify({
+ success: false,
+ error: '获取二维码合集失败,请重试'
+ }));
+ }
+ return;
+ }
+
// 处理GET请求,获取最新的合格证信息
if (req.method === 'GET' && req.url.startsWith('/getLatestCertificate')) {
try {