|
|
@@ -0,0 +1,568 @@
|
|
|
+<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="zh-CN">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8"/>
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
|
+ <title>匿名人脸采集二维码生成</title>
|
|
|
+ <style>
|
|
|
+ :root {
|
|
|
+ --bg: #f3f6fb;
|
|
|
+ --card: #ffffff;
|
|
|
+ --line: #dbe3ef;
|
|
|
+ --text: #152033;
|
|
|
+ --muted: #607089;
|
|
|
+ --primary: #0f766e;
|
|
|
+ --primary-deep: #115e59;
|
|
|
+ --warn: #b45309;
|
|
|
+ --err: #b91c1c;
|
|
|
+ }
|
|
|
+
|
|
|
+ * {
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
+
|
|
|
+ body {
|
|
|
+ margin: 0;
|
|
|
+ font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
|
|
|
+ background: linear-gradient(180deg, #eef5f3 0%, var(--bg) 45%, #e9eef8 100%);
|
|
|
+ color: var(--text);
|
|
|
+ }
|
|
|
+
|
|
|
+ .wrap {
|
|
|
+ max-width: 1160px;
|
|
|
+ margin: 0 auto;
|
|
|
+ padding: 28px 16px 40px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .hero {
|
|
|
+ margin-bottom: 18px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .hero h1 {
|
|
|
+ margin: 0 0 8px;
|
|
|
+ font-size: 30px;
|
|
|
+ line-height: 1.2;
|
|
|
+ }
|
|
|
+
|
|
|
+ .hero p {
|
|
|
+ margin: 0;
|
|
|
+ color: var(--muted);
|
|
|
+ line-height: 1.7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .grid {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: minmax(320px, 420px) minmax(420px, 1fr);
|
|
|
+ gap: 18px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card {
|
|
|
+ background: var(--card);
|
|
|
+ border: 1px solid var(--line);
|
|
|
+ border-radius: 20px;
|
|
|
+ box-shadow: 0 14px 40px rgba(16, 24, 40, 0.08);
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-hd {
|
|
|
+ padding: 18px 22px 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-hd h2 {
|
|
|
+ margin: 0;
|
|
|
+ font-size: 20px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-hd p {
|
|
|
+ margin: 8px 0 0;
|
|
|
+ color: var(--muted);
|
|
|
+ line-height: 1.6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .card-bd {
|
|
|
+ padding: 0 22px 22px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .field {
|
|
|
+ margin-bottom: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .field label {
|
|
|
+ display: block;
|
|
|
+ margin-bottom: 6px;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 700;
|
|
|
+ }
|
|
|
+
|
|
|
+ .field input,
|
|
|
+ .field select,
|
|
|
+ .field textarea {
|
|
|
+ width: 100%;
|
|
|
+ padding: 12px 14px;
|
|
|
+ border-radius: 12px;
|
|
|
+ border: 1px solid #c8d3e2;
|
|
|
+ background: #fbfdff;
|
|
|
+ color: var(--text);
|
|
|
+ font-size: 14px;
|
|
|
+ outline: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .field textarea {
|
|
|
+ min-height: 88px;
|
|
|
+ resize: vertical;
|
|
|
+ }
|
|
|
+
|
|
|
+ .field input:focus,
|
|
|
+ .field select:focus,
|
|
|
+ .field textarea:focus {
|
|
|
+ border-color: #5cb9ac;
|
|
|
+ box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
|
|
|
+ }
|
|
|
+
|
|
|
+ .row {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: 1fr 1fr;
|
|
|
+ gap: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .actions {
|
|
|
+ display: flex;
|
|
|
+ gap: 12px;
|
|
|
+ margin-top: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ appearance: none;
|
|
|
+ border: 0;
|
|
|
+ border-radius: 12px;
|
|
|
+ padding: 12px 18px;
|
|
|
+ cursor: pointer;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 700;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-primary {
|
|
|
+ background: linear-gradient(135deg, var(--primary) 0%, var(--primary-deep) 100%);
|
|
|
+ color: #fff;
|
|
|
+ box-shadow: 0 10px 24px rgba(17, 94, 89, 0.22);
|
|
|
+ }
|
|
|
+
|
|
|
+ .btn-lite {
|
|
|
+ background: #edf7f6;
|
|
|
+ color: var(--primary-deep);
|
|
|
+ }
|
|
|
+
|
|
|
+ .tips {
|
|
|
+ margin-top: 14px;
|
|
|
+ padding: 12px 14px;
|
|
|
+ border-radius: 12px;
|
|
|
+ background: #f8fbff;
|
|
|
+ color: var(--muted);
|
|
|
+ font-size: 13px;
|
|
|
+ line-height: 1.7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .status {
|
|
|
+ margin: 14px 0 0;
|
|
|
+ padding: 12px 14px;
|
|
|
+ border-radius: 12px;
|
|
|
+ font-size: 14px;
|
|
|
+ line-height: 1.7;
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+
|
|
|
+ .status.info {
|
|
|
+ display: block;
|
|
|
+ background: #ecfeff;
|
|
|
+ color: #155e75;
|
|
|
+ }
|
|
|
+
|
|
|
+ .status.warn {
|
|
|
+ display: block;
|
|
|
+ background: #fff7ed;
|
|
|
+ color: var(--warn);
|
|
|
+ }
|
|
|
+
|
|
|
+ .status.err {
|
|
|
+ display: block;
|
|
|
+ background: #fef2f2;
|
|
|
+ color: var(--err);
|
|
|
+ }
|
|
|
+
|
|
|
+ .preview {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ gap: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .qr-box {
|
|
|
+ min-height: 380px;
|
|
|
+ border-radius: 18px;
|
|
|
+ border: 1px dashed #bfd0e5;
|
|
|
+ background: linear-gradient(180deg, #f9fbff 0%, #f3f8ff 100%);
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ padding: 22px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .qr-box.empty {
|
|
|
+ color: var(--muted);
|
|
|
+ font-size: 15px;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 1.8;
|
|
|
+ }
|
|
|
+
|
|
|
+ .qr-panel {
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ gap: 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .qr-panel img {
|
|
|
+ width: min(320px, 100%);
|
|
|
+ max-width: 320px;
|
|
|
+ border-radius: 16px;
|
|
|
+ border: 1px solid #d3dfef;
|
|
|
+ background: #fff;
|
|
|
+ padding: 12px;
|
|
|
+ box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
|
|
|
+ }
|
|
|
+
|
|
|
+ .scan-tip {
|
|
|
+ color: var(--muted);
|
|
|
+ text-align: center;
|
|
|
+ line-height: 1.7;
|
|
|
+ }
|
|
|
+
|
|
|
+ .meta {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: 1fr 1fr;
|
|
|
+ gap: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .meta-item {
|
|
|
+ border-radius: 14px;
|
|
|
+ background: #f8fafc;
|
|
|
+ border: 1px solid #e5edf7;
|
|
|
+ padding: 12px 14px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .meta-item .k {
|
|
|
+ color: var(--muted);
|
|
|
+ font-size: 12px;
|
|
|
+ margin-bottom: 6px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .meta-item .v {
|
|
|
+ font-size: 14px;
|
|
|
+ word-break: break-all;
|
|
|
+ line-height: 1.6;
|
|
|
+ }
|
|
|
+
|
|
|
+ .meta-wide {
|
|
|
+ grid-column: 1 / -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ .linkbar {
|
|
|
+ display: flex;
|
|
|
+ gap: 10px;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ }
|
|
|
+
|
|
|
+ .linkbar a {
|
|
|
+ color: var(--primary-deep);
|
|
|
+ text-decoration: none;
|
|
|
+ font-weight: 700;
|
|
|
+ }
|
|
|
+
|
|
|
+ @media (max-width: 960px) {
|
|
|
+ .grid {
|
|
|
+ grid-template-columns: 1fr;
|
|
|
+ }
|
|
|
+
|
|
|
+ .meta,
|
|
|
+ .row {
|
|
|
+ grid-template-columns: 1fr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+<div class="wrap">
|
|
|
+ <div class="hero">
|
|
|
+ <h1>匿名人脸采集二维码生成</h1>
|
|
|
+ <p>打开本页会自动生成一张可扫码的小程序二维码。学生扫码后会进入匿名采集表单,填写姓名、身份证号,并在小程序内自拍上传。</p>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="grid">
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-hd">
|
|
|
+ <h2>生成参数</h2>
|
|
|
+ <p>默认按正式版小程序生成。你可以按批次号、有效期和备注重生成新的二维码。</p>
|
|
|
+ </div>
|
|
|
+ <div class="card-bd">
|
|
|
+ <form id="genForm">
|
|
|
+ <div class="field">
|
|
|
+ <label for="batchId">批次号</label>
|
|
|
+ <input id="batchId" name="batchId" type="text" placeholder="不填则自动生成,如 FC20260725180000"/>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="field">
|
|
|
+ <label for="remark">备注</label>
|
|
|
+ <textarea id="remark" name="remark" placeholder="例如:2026级新生人脸采集首轮">匿名人脸采集二维码</textarea>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row">
|
|
|
+ <div class="field">
|
|
|
+ <label for="envVersion">小程序版本</label>
|
|
|
+ <select id="envVersion" name="envVersion">
|
|
|
+ <option value="release" selected>release 正式版</option>
|
|
|
+ <option value="trial">trial 体验版</option>
|
|
|
+ <option value="develop">develop 开发版</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="field">
|
|
|
+ <label for="expireDays">有效天数</label>
|
|
|
+ <input id="expireDays" name="expireDays" type="number" min="1" value="30"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row">
|
|
|
+ <div class="field">
|
|
|
+ <label for="expireTime">指定过期时间</label>
|
|
|
+ <input id="expireTime" name="expireTime" type="text" placeholder="yyyy-MM-dd HH:mm:ss"/>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="field">
|
|
|
+ <label for="maxSubmitNum">最多提交次数</label>
|
|
|
+ <input id="maxSubmitNum" name="maxSubmitNum" type="number" min="1" placeholder="不填表示不限次数"/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="row">
|
|
|
+ <div class="field">
|
|
|
+ <label for="checkPath">校验页面路径</label>
|
|
|
+ <select id="checkPath" name="checkPath">
|
|
|
+ <option value="false" selected>false</option>
|
|
|
+ <option value="true">true</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="field">
|
|
|
+ <label for="autoGenerate">页面打开即生成</label>
|
|
|
+ <select id="autoGenerate" name="autoGenerate">
|
|
|
+ <option value="true" selected>true</option>
|
|
|
+ <option value="false">false</option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="actions">
|
|
|
+ <button type="submit" class="btn btn-primary" id="genBtn">生成二维码</button>
|
|
|
+ <button type="button" class="btn btn-lite" id="resetBtn">恢复默认</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+
|
|
|
+ <div class="tips">
|
|
|
+ 建议正式发给学生时使用 <b>release</b>。如果页面还未发布到正式版,再切到 <b>develop</b> 或 <b>trial</b> 做测试。扫码进入后无需登录,当前小程序侧采用“智能引导拍照 + 基础规格校验”模式。
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div id="statusBox" class="status"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-hd">
|
|
|
+ <h2>二维码预览</h2>
|
|
|
+ <p>生成成功后,直接使用微信扫码即可进入匿名人脸采集页面。</p>
|
|
|
+ </div>
|
|
|
+ <div class="card-bd preview">
|
|
|
+ <div id="qrBox" class="qr-box empty">正在等待生成二维码……</div>
|
|
|
+
|
|
|
+ <div class="meta">
|
|
|
+ <div class="meta-item">
|
|
|
+ <div class="k">小程序 AppId</div>
|
|
|
+ <div class="v" id="miniProgramAppId">-</div>
|
|
|
+ </div>
|
|
|
+ <div class="meta-item">
|
|
|
+ <div class="k">页面路径</div>
|
|
|
+ <div class="v" id="pagePath">-</div>
|
|
|
+ </div>
|
|
|
+ <div class="meta-item">
|
|
|
+ <div class="k">二维码 Token</div>
|
|
|
+ <div class="v" id="tokenVal">-</div>
|
|
|
+ </div>
|
|
|
+ <div class="meta-item">
|
|
|
+ <div class="k">批次号</div>
|
|
|
+ <div class="v" id="batchVal">-</div>
|
|
|
+ </div>
|
|
|
+ <div class="meta-item">
|
|
|
+ <div class="k">过期时间</div>
|
|
|
+ <div class="v" id="expireVal">-</div>
|
|
|
+ </div>
|
|
|
+ <div class="meta-item">
|
|
|
+ <div class="k">最多提交次数</div>
|
|
|
+ <div class="v" id="maxSubmitVal">-</div>
|
|
|
+ </div>
|
|
|
+ <div class="meta-item meta-wide">
|
|
|
+ <div class="k">二维码链接</div>
|
|
|
+ <div class="v linkbar">
|
|
|
+ <a id="qrPreviewLink" href="javascript:void(0)">尚未生成</a>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+<script>
|
|
|
+ (function () {
|
|
|
+ var serviceUrl = "/service?ssServ=faceCollect_genQrcode";
|
|
|
+ var form = document.getElementById("genForm");
|
|
|
+ var statusBox = document.getElementById("statusBox");
|
|
|
+ var qrBox = document.getElementById("qrBox");
|
|
|
+ var genBtn = document.getElementById("genBtn");
|
|
|
+ var resetBtn = document.getElementById("resetBtn");
|
|
|
+ var defaultRemark = "匿名人脸采集二维码";
|
|
|
+
|
|
|
+ function setStatus(level, msg) {
|
|
|
+ statusBox.className = "status " + (level || "info");
|
|
|
+ statusBox.style.display = "block";
|
|
|
+ statusBox.textContent = msg || "";
|
|
|
+ }
|
|
|
+
|
|
|
+ function clearStatus() {
|
|
|
+ statusBox.className = "status";
|
|
|
+ statusBox.style.display = "none";
|
|
|
+ statusBox.textContent = "";
|
|
|
+ }
|
|
|
+
|
|
|
+ function setGenerating(isGenerating) {
|
|
|
+ genBtn.disabled = isGenerating;
|
|
|
+ genBtn.textContent = isGenerating ? "生成中..." : "生成二维码";
|
|
|
+ }
|
|
|
+
|
|
|
+ function fillMeta(data) {
|
|
|
+ document.getElementById("miniProgramAppId").textContent = data.miniProgramAppId || "-";
|
|
|
+ document.getElementById("pagePath").textContent = data.page || "-";
|
|
|
+ document.getElementById("tokenVal").textContent = data.token || "-";
|
|
|
+ document.getElementById("batchVal").textContent = data.batchId || "-";
|
|
|
+ document.getElementById("expireVal").textContent = data.expireTime || "-";
|
|
|
+ document.getElementById("maxSubmitVal").textContent = data.maxSubmitNum == null ? "不限" : data.maxSubmitNum;
|
|
|
+
|
|
|
+ var qrPreviewLink = document.getElementById("qrPreviewLink");
|
|
|
+ qrPreviewLink.href = data.qrPreviewUrl || "javascript:void(0)";
|
|
|
+ qrPreviewLink.textContent = data.qrPreviewUrl || "尚未生成";
|
|
|
+ if (data.qrPreviewUrl) {
|
|
|
+ qrPreviewLink.target = "_blank";
|
|
|
+ qrPreviewLink.rel = "noopener noreferrer";
|
|
|
+ } else {
|
|
|
+ qrPreviewLink.removeAttribute("target");
|
|
|
+ qrPreviewLink.removeAttribute("rel");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function showQr(data) {
|
|
|
+ if (!data || !data.qrPreviewUrl) {
|
|
|
+ qrBox.className = "qr-box empty";
|
|
|
+ qrBox.textContent = "二维码尚未生成";
|
|
|
+ fillMeta({});
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ qrBox.className = "qr-box";
|
|
|
+ qrBox.innerHTML =
|
|
|
+ '<div class="qr-panel">' +
|
|
|
+ '<img src="' + escapeHtml(data.qrPreviewUrl) + '" alt="匿名人脸采集二维码"/>' +
|
|
|
+ '<div class="scan-tip">请使用微信扫描此二维码进入小程序匿名采集表单。<br/>进入后填写学生姓名、身份证号,并完成自拍上传。</div>' +
|
|
|
+ '</div>';
|
|
|
+ fillMeta(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ function escapeHtml(text) {
|
|
|
+ return String(text || "")
|
|
|
+ .replace(/&/g, "&")
|
|
|
+ .replace(/</g, "<")
|
|
|
+ .replace(/>/g, ">")
|
|
|
+ .replace(/"/g, """)
|
|
|
+ .replace(/'/g, "'");
|
|
|
+ }
|
|
|
+
|
|
|
+ function resetForm() {
|
|
|
+ form.reset();
|
|
|
+ document.getElementById("remark").value = defaultRemark;
|
|
|
+ document.getElementById("envVersion").value = "release";
|
|
|
+ document.getElementById("expireDays").value = "30";
|
|
|
+ document.getElementById("checkPath").value = "false";
|
|
|
+ document.getElementById("autoGenerate").value = "true";
|
|
|
+ clearStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ function buildBody() {
|
|
|
+ var formData = new FormData(form);
|
|
|
+ var params = new URLSearchParams();
|
|
|
+ formData.forEach(function (value, key) {
|
|
|
+ if (value != null && String(value).trim() !== "") {
|
|
|
+ params.append(key, value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ params.delete("autoGenerate");
|
|
|
+ return params.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ function genQrcode() {
|
|
|
+ clearStatus();
|
|
|
+ setGenerating(true);
|
|
|
+ setStatus("info", "正在向后端申请微信小程序二维码,请稍候...");
|
|
|
+
|
|
|
+ fetch(serviceUrl, {
|
|
|
+ method: "POST",
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
|
|
|
+ },
|
|
|
+ body: buildBody()
|
|
|
+ }).then(function (resp) {
|
|
|
+ return resp.json();
|
|
|
+ }).then(function (json) {
|
|
|
+ if (!json || json.ok !== true) {
|
|
|
+ var errMsg = json && json.msg ? json.msg : "生成失败,请检查后端日志。";
|
|
|
+ setStatus("err", errMsg);
|
|
|
+ showQr(null);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var data = json.data || {};
|
|
|
+ showQr(data);
|
|
|
+ setStatus("info", "二维码生成成功。当前 token=" + (data.token || "-") + ",可直接扫码测试。");
|
|
|
+ }).catch(function (err) {
|
|
|
+ setStatus("err", "请求失败:" + (err && err.message ? err.message : "未知错误"));
|
|
|
+ showQr(null);
|
|
|
+ }).finally(function () {
|
|
|
+ setGenerating(false);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ form.addEventListener("submit", function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ genQrcode();
|
|
|
+ });
|
|
|
+
|
|
|
+ resetBtn.addEventListener("click", function () {
|
|
|
+ resetForm();
|
|
|
+ });
|
|
|
+
|
|
|
+ resetForm();
|
|
|
+
|
|
|
+ if (document.getElementById("autoGenerate").value === "true") {
|
|
|
+ genQrcode();
|
|
|
+ }
|
|
|
+ })();
|
|
|
+</script>
|
|
|
+</body>
|
|
|
+</html>
|