Files
litianming 08ce60344d Initial commit: 心理咨询预约系统
PHP 前后端一体:首页咨询师列表、预约表单、管理后台、二维码准入与邮件通知;敏感配置与提交数据通过 .gitignore 排除。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 10:17:09 +08:00

93 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/api/bootstrap.php';
sendHtmlNoCacheHeaders();
$v = getAssetVersion();
?><!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>生成访问二维码 - 心理咨询</title>
<link rel="stylesheet" href="<?= asset('css/base.css') ?>">
<link rel="stylesheet" href="<?= asset('css/admin.css') ?>">
</head>
<body>
<div class="page qr-page page--fade-in">
<h1 class="qr-page__title">访问二维码</h1>
<p class="qr-page__desc">用户扫描下方二维码即可进入心理咨询服务(仅限持有链接者访问)</p>
<div class="qr-canvas-wrap">
<div id="qrcode"></div>
</div>
<div class="qr-url-box" id="access-url">加载中…</div>
<div class="qr-actions">
<button type="button" class="btn btn--primary btn--block" id="copy-url">复制链接</button>
<a href="index.php" class="btn btn--ghost btn--block" style="text-align:center;line-height:48px">预览首页</a>
<a href="admin.php" class="btn btn--ghost btn--block" style="text-align:center;line-height:48px;margin-top:8px">管理后台</a>
</div>
<div class="qr-note">
<p><strong>使用说明:</strong></p>
<p>1. 部署前请在 <code>config/app.json</code> 中修改 <code>accessToken</code> 为随机长字符串。</p>
<p>2. 将本页生成的二维码打印或发送给用户,勿公开传播链接。</p>
<p>3. 更换 token 后需重新生成二维码,旧链接将失效。</p>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
<script src="<?= asset('js/api.js') ?>"></script>
<script>
async function initQr() {
const urlBox = document.getElementById("access-url");
let token = "";
try {
const config = await apiGet("config.php");
token = config.accessToken || "";
document.title = (config.siteTitle || "心理咨询") + " - 二维码";
} catch (e) {
urlBox.textContent = "无法加载配置,请确认 PHP 服务已启动";
return;
}
const base = window.location.origin + window.location.pathname.replace(/qr\.php$/, "").replace(/qr\.html$/, "");
const accessUrl = base + "index.php?access=" + encodeURIComponent(token);
urlBox.textContent = accessUrl;
document.getElementById("qrcode").innerHTML = "";
new QRCode(document.getElementById("qrcode"), {
text: accessUrl,
width: 200,
height: 200,
colorDark: "#2c2c2c",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H,
});
document.getElementById("copy-url").addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(accessUrl);
alert("链接已复制");
} catch {
const input = document.createElement("input");
input.value = accessUrl;
document.body.appendChild(input);
input.select();
document.execCommand("copy");
input.remove();
alert("链接已复制");
}
});
}
document.addEventListener("DOMContentLoaded", initQr);
</script>
</body>
</html>