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.
 
 

282 lines
7.8 KiB

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>生成邀请二维码</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-color: #f5f5f5;
color: #333;
-webkit-overflow-scrolling: touch;
overflow-x: hidden;
position: relative;
touch-action: manipulation;
}
html, body {
height: 100%;
overflow: hidden;
overscroll-behavior: none;
}
.container {
max-width: 480px;
margin: 0 auto;
background-color: white;
height: 100%;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
position: relative;
padding: 20px;
}
.header {
text-align: center;
margin-bottom: 30px;
padding-top: 20px;
}
.header h1 {
font-size: 24px;
color: #28a745;
margin-bottom: 10px;
}
.header p {
font-size: 16px;
color: #666;
}
.qr-container {
text-align: center;
margin: 30px 0;
}
#qrCodeImage {
max-width: 300px;
max-height: 300px;
margin: 0 auto;
background-color: white;
padding: 15px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.info-box {
background-color: #f8f9fa;
border-radius: 8px;
padding: 15px;
margin: 20px 0;
}
.info-box h3 {
font-size: 18px;
color: #333;
margin-bottom: 10px;
}
.info-box p {
font-size: 14px;
color: #666;
line-height: 1.5;
margin-bottom: 8px;
}
.action-buttons {
display: flex;
flex-direction: column;
gap: 15px;
margin-top: 30px;
}
.btn {
padding: 15px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 500;
cursor: pointer;
text-align: center;
transition: background-color 0.3s;
}
.btn-primary {
background-color: #28a745;
color: white;
}
.btn-primary:hover {
background-color: #218838;
}
.btn-secondary {
background-color: #6c757d;
color: white;
}
.btn-secondary:hover {
background-color: #5a6268;
}
.footer {
text-align: center;
margin-top: 40px;
padding: 20px 0;
font-size: 14px;
color: #999;
border-top: 1px solid #f0f0f0;
}
@media (max-width: 480px) {
.container {
max-width: 100%;
padding: 15px;
}
.header h1 {
font-size: 20px;
}
#qrCodeImage {
max-width: 250px;
max-height: 250px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="user-info" style="background-color: #f8f9fa; border-radius: 8px; padding: 15px; margin-bottom: 20px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<h3 style="font-size: 16px; color: #333; margin: 0;">登录信息</h3>
<button class="btn btn-secondary" onclick="logout()" style="padding: 6px 12px; font-size: 14px;">退出</button>
</div>
<div id="userInfo" style="font-size: 14px; color: #666;">
<p>职位:<span id="userProjectName">未登录</span></p>
<p>姓名:<span id="userName">未登录</span></p>
<p>电话:<span id="userPhone">未登录</span></p>
</div>
</div>
<div class="header">
<h1>生成邀请二维码</h1>
<p>创建一个二维码,邀请他人填写合格证信息</p>
</div>
<div class="info-box">
<h3>使用说明</h3>
<p>1. 点击下方按钮生成邀请二维码</p>
<p>2. 将生成的二维码分享给需要填写信息的人</p>
<p>3. 对方扫描二维码后,填写完整的合格证信息并提交</p>
<p>4. 您可以扫描下方二维码查看和导出已填写的信息</p>
</div>
<div class="qr-container">
<h3 style="color: #28a745;">📝 邀请二维码</h3>
<img id="qrCodeImage" src="" alt="邀请二维码">
<div style="margin-top: 15px; padding: 10px; background-color: #e6f7ee; border-radius: 8px;">
<p style="color: #28a745; font-weight: 500;">作用:邀请他人填写合格证信息</p>
<p style="color: #666; font-size: 14px; margin-top: 5px;">扫描此二维码进入信息填写页面</p>
</div>
</div>
<div class="action-buttons">
<button class="btn btn-primary" onclick="generateInviteQR()">重新生成二维码</button>
<button class="btn btn-primary" onclick="window.location.href='qr-collection.html'">查看二维码合集</button>
</div>
<div class="footer">
技术支持:四川又鸟蛋贸易有限公司
</div>
</div>
<script>
// 加载用户信息
function loadUserInfo() {
const userInfo = localStorage.getItem('userInfo');
if (userInfo) {
try {
const user = JSON.parse(userInfo);
document.getElementById('userProjectName').textContent = user.projectName || '未提供';
document.getElementById('userName').textContent = user.name || user.userName;
document.getElementById('userPhone').textContent = user.phoneNumber || '未提供';
} catch (error) {
console.error('解析用户信息失败:', error);
}
}
}
// 生成邀请二维码
function generateInviteQR() {
// 生成包含会话ID的URL
const sessionId = 'session_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
// 获取用户信息
const userInfo = localStorage.getItem('userInfo');
let inviterName = '';
let inviterPhone = '';
let inviterProjectName = '';
if (userInfo) {
try {
const user = JSON.parse(userInfo);
inviterName = user.name || user.userName;
inviterPhone = user.phoneNumber || '';
inviterProjectName = user.projectName || '';
} catch (error) {
console.error('解析用户信息失败:', error);
}
}
// 构建邀请URL,包含会话ID和邀请者信息
const inviteUrl = `http://8.137.125.67:3008/certificate.html?sessionId=${encodeURIComponent(sessionId)}&inviter=${encodeURIComponent(inviterName)}&inviterPhone=${encodeURIComponent(inviterPhone)}&inviterProjectName=${encodeURIComponent(inviterProjectName)}`;
// 使用Google Charts API生成二维码
const qrCodeUrl = `https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=${encodeURIComponent(inviteUrl)}`;
// 更新二维码图片
document.getElementById('qrCodeImage').src = qrCodeUrl;
// 显示成功提示
alert('邀请二维码生成成功!\n\n请将此二维码分享给需要填写信息的人。\n\n对方填写完成后,您可以通过相同的二维码查看和导出信息。');
}
// 退出登录
function logout() {
// 清除本地存储的用户信息
localStorage.removeItem('userInfo');
// 跳转到登录页面
window.location.href = 'login.html';
}
// 检查用户是否已登录
function checkLogin() {
const userInfo = localStorage.getItem('userInfo');
if (!userInfo) {
// 未登录,跳转到登录页面
window.location.href = 'login.html';
return false;
}
return true;
}
// 页面加载时自动生成二维码并加载用户信息
window.onload = function() {
// 检查登录状态
if (!checkLogin()) {
return;
}
loadUserInfo();
generateInviteQR();
};
</script>
</body>
</html>