1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072 |
- <!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>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- body {
- font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
- height: 100vh;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- background-color: #f5f7fa;
- }
- /* 导航栏样式 */
- nav {
- background: linear-gradient(135deg, #1a73e8, #0d47a1);
- color: white;
- padding: 15px 30px;
- display: flex;
- align-items: center;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- z-index: 100;
- }
- .logo {
- font-size: 24px;
- font-weight: bold;
- margin-right: 15px;
- }
- .event-name {
- font-size: 20px;
- flex-grow: 1;
- }
- /* 主内容区域 */
- .main-container {
- display: flex;
- flex: 1;
- overflow: hidden;
- }
- /* 左侧菜单 */
- .sidebar {
- width: 200px;
- background-color: #2c3e50;
- color: white;
- display: flex;
- flex-direction: column;
- padding: 20px 0;
- }
- .menu-btn {
- padding: 15px 20px;
- margin: 10px 15px;
- background-color: #3498db;
- color: white;
- border: none;
- border-radius: 5px;
- font-size: 16px;
- cursor: pointer;
- transition: all 0.3s;
- text-align: center;
- }
- .menu-btn:hover {
- background-color: #2980b9;
- transform: translateY(-2px);
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
- }
- .menu-btn.active {
- background-color: #1abc9c;
- }
- /* 右侧内容区域 */
- .content-area {
- flex: 1;
- display: flex;
- flex-direction: column;
- padding: 20px;
- background-color: white;
- border-radius: 10px;
- margin: 20px;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
- overflow: hidden;
- }
- .content-header {
- font-size: 24px;
- color: #2c3e50;
- margin-bottom: 20px;
- padding-bottom: 10px;
- border-bottom: 2px solid #3498db;
- }
- /* 下载区域 */
- .download-section {
- display: none;
- flex-direction: column;
- height: 100%;
- }
- .download-section.active {
- display: flex;
- }
- .download-list {
- overflow-y: auto;
- flex: 1;
- }
- .download-item {
- width: calc(100% - 30px);
- background-color: #f8f9fa;
- border: 1px solid #e9ecef;
- border-radius: 8px;
- padding: 15px;
- margin-bottom: 15px;
- display: flex;
- align-items: center;
- transition: all 0.3s;
- }
- .download-item:hover {
- transform: translateX(5px);
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
- border-color: #3498db;
- }
- .file-icon {
- font-size: 24px;
- margin-right: 15px;
- color: #3498db;
- }
- .file-info {
- flex: 1;
- }
- .file-title {
- font-weight: bold;
- margin-bottom: 5px;
- }
- .file-desc {
- color: #6c757d;
- font-size: 14px;
- }
- .download-btn {
- background-color: #28a745;
- color: white;
- border: none;
- padding: 8px 15px;
- border-radius: 5px;
- cursor: pointer;
- transition: background-color 0.3s;
- text-decoration: none;
- }
- .download-btn:hover {
- background-color: #218838;
- }
- /* 报名区域 */
- .registration-section {
- display: none;
- flex-direction: column;
- height: 100%;
- overflow-y: auto;
- position: relative;
- }
- .registration-section.active {
- display: flex;
- }
- .form-container {
- flex: 1;
- padding-right: 10px;
- }
- .form-group {
- margin-bottom: 20px;
- }
- .form-label {
- display: block;
- margin-bottom: 8px;
- font-weight: bold;
- color: #495057;
- }
- .required::after {
- content: " *";
- color: #e74c3c;
- }
- .form-input {
- width: 100%;
- padding: 12px;
- border: 1px solid #ced4da;
- border-radius: 5px;
- font-size: 16px;
- transition: border-color 0.3s;
- }
- .form-input:focus {
- border-color: #3498db;
- outline: none;
- box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
- }
- .form-row {
- display: flex;
- gap: 20px;
- }
- .form-col {
- flex: 1;
- }
- .file-upload {
- border: 2px dashed #ced4da;
- padding: 30px;
- text-align: center;
- border-radius: 8px;
- margin: 20px 0;
- background-color: #f8f9fa;
- transition: all 0.3s;
- }
- .file-upload:hover {
- border-color: #3498db;
- background-color: #e3f2fd;
- }
- .upload-icon {
- font-size: 40px;
- color: #3498db;
- margin-bottom: 15px;
- }
- .submit-btn {
- background-color: #1a73e8;
- color: white;
- border: none;
- padding: 14px 25px;
- border-radius: 5px;
- font-size: 18px;
- cursor: pointer;
- transition: all 0.3s;
- margin-top: 20px;
- width: 100%;
- }
- .submit-btn:hover {
- background-color: #0d47a1;
- transform: translateY(-2px);
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
- }
- .error {
- color: #e74c3c;
- font-size: 14px;
- margin-top: 5px;
- display: none;
- }
- .menu-btn-add {
- position: absolute;
- right: 20px;
- top: 1px;
- padding: 7px 15px;
- font-size: 14px;
- background-color: #3498db;
- color: white;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- transition: all 0.3s;
- text-align: center;
- }
- .step-container {
- display: none;
- }
- .step-container.active {
- display: block;
- }
- .competition-grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
- gap: 20px;
- margin-bottom: 30px;
- }
- .competition-card {
- border: 1px solid #e0e0e0;
- border-radius: 10px;
- padding: 20px;
- text-align: center;
- cursor: pointer;
- transition: all 0.3s;
- }
- .competition-card:hover {
- border-color: #1a73e8;
- box-shadow: 0 4px 12px rgba(26, 115, 232, 0.15);
- transform: translateY(-5px);
- }
- .competition-card.selected {
- border-color: #1a73e8;
- background-color: #e8f0fe;
- }
- .competition-icon {
- font-size: 36px;
- color: #1a73e8;
- margin-bottom: 15px;
- }
- .competition-name {
- font-weight: 500;
- color: #202124;
- }
- .btn {
- padding: 12px 30px;
- border-radius: 8px;
- font-size: 16px;
- font-weight: 500;
- cursor: pointer;
- transition: all 0.3s;
- border: none;
- }
- .btn-prev {
- background-color: #f8f9fa;
- color: #5f6368;
- }
- .btn-prev:hover {
- background-color: #e8f0fe;
- color: #1a73e8;
- }
- .btn-next {
- background-color: #1a73e8;
- color: white;
- }
- .btn-next:hover {
- background-color: #0d47a1;
- }
- .btn-submit {
- background-color: #34a853;
- color: white;
- }
- .btn-submit:hover {
- background-color: #2d9249;
- }
- .error {
- color: #ea4335;
- font-size: 14px;
- margin-top: 5px;
- display: none;
- }
- .button-group {
- display: flex;
- justify-content: space-between;
- margin-top: 30px;
- }
- .step-title {
- font-size: 18px;
- color: #202124;
- margin-bottom: 20px;
- padding-bottom: 10px;
- border-bottom: 1px solid #e0e0e0;
- }
- </style>
- <script src="https://sdk.amazonaws.com/js/aws-sdk-2.235.1.min.js"></script>
- <script>
- var credentials = {
- accessKeyId: 'AKIATLPEDU37QV5CHLMH',
- secretAccessKey: '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'
- }; //秘鑰形式的登錄上傳
- window.AWS.config.update(credentials);
- window.AWS.config.region = 'cn-northwest-1'; //設置區域
- </script>
- </head>
- <body>
- <!-- 导航栏 -->
- <nav>
- <img src="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/a/logo.png" alt="logo"
- style="width: 40px;margin-right: 15px;"></img>
- <div class="event-name">第六届广东省青少年创新思维及科技实践大赛创新思维挑战赛(选手报名)</div>
- </nav>
- <!-- 主内容区域 -->
- <div class="main-container">
- <!-- 左侧菜单 -->
- <div class="sidebar">
- <button class="menu-btn active" id="downloadBtn">资料下载</button>
- <button class="menu-btn" id="registerBtn">在线报名</button>
- <button class="menu-btn" id="registerBtn1">资格确认</button>
- </div>
- <!-- 右侧内容区域 -->
- <div class="content-area">
- <!-- 下载区域 -->
- <div class="download-section active" id="downloadSection">
- <h2 class="content-header">比赛资料下载</h2>
- <div class="download-list">
- <div class="download-item">
- <div class="file-icon">📋</div>
- <div class="file-info">
- <div class="file-title">第六届广东省青少年创新思维及科技实践大赛创新思维挑战赛</div>
- </div>
- <a target="_blank"
- href="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/a/%E5%88%9B%E6%96%B0%E6%80%9D%E7%BB%B4%E7%B1%BB-%E5%88%9B%E6%96%B0%E6%80%9D%E7%BB%B4%E6%8C%91%E6%88%98%E8%B5%9B.pdf"
- class="download-btn" download="第六届广东省青少年创新思维及科技实践大赛创新思维挑战赛.pdf">下载</a>
- </div>
- <div class="download-item">
- <div class="file-icon">📊</div>
- <div class="file-info">
- <div class="file-title">第六届广东省青少年创新思维及科技实践大赛的通知</div>
- </div>
- <a target="_blank"
- href="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/a/%E5%85%B3%E4%BA%8E%E4%B8%BE%E5%8A%9E%E7%AC%AC%E5%85%AD%E5%B1%8A%E5%B9%BF%E4%B8%9C%E7%9C%81%E9%9D%92%E5%B0%91%E5%B9%B4%E5%88%9B%E6%96%B0%E6%80%9D%E7%BB%B4%E5%8F%8A%E7%A7%91%E6%8A%80%E5%AE%9E%E8%B7%B5%E5%A4%A7%E8%B5%9B%E7%9A%84%E9%80%9A%E7%9F%A5%286%29.pdf"
- class="download-btn" download="第六届广东省青少年创新思维及科技实践大赛的通知.pdf">下载</a>
- </div>
- <div class="download-item">
- <div class="file-icon">📄</div>
- <div class="file-info">
- <div class="file-title">报名表模板</div>
- <div class="file-desc">完成在线报名后,请先下载该模板,经所在学校盖章确认后,将盖章后的模板上传至【资格确认】板块,即可完成赛前准备。</div>
- </div>
- <a target="_blank"
- href="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/a/%E6%8A%A5%E5%90%8D%E8%A1%A8.docx"
- class="download-btn" download>下载</a>
- </div>
- </div>
- </div>
- <!-- 报名区域 -->
- <div class="registration-section " id="registrationSection">
- <!-- <div class="select-type">
- <select id="selectType" class="form-input" required >
- <option value="">请选择参赛类型</option>
- <option value="1">桌游设计挑战类</option>
- <option value="2">智能体应用类</option>
- </select>
- </div> -->
- <div class="content-header">
- <h2 style="display: inline-block;font-size: 24px;">参赛信息登记</h2>
- <button class="menu-btn-add" onclick="addContestant()">添加选手</button>
- </div>
- <!-- 步骤1:选择比赛类型 -->
- <div id="step1" class="step-container active">
- <div class="step-title">第一步:请选择您要报名的比赛类型</div>
- <div class="competition-grid">
- <div class="competition-card" data-id="1">
- <div class="competition-icon">🧮</div>
- <div class="competition-name">桌游设计挑战类</div>
- </div>
- <div class="competition-card" data-id="2">
- <div class="competition-icon">💻</div>
- <div class="competition-name">智能体应用类</div>
- </div>
- </div>
- <div class="button-group">
- <div></div> <!-- 占位 -->
- <button class="btn btn-next" id="nextToStep2">下一步</button>
- </div>
- </div>
- <!-- 步骤2:填写报名信息 -->
- <div id="step2" class="step-container">
- <div class="step-title">第二步:填写报名信息</div>
- <div class="form-container" id="formContainer">
- <input type="hidden" id="competitionType" value="">
- <h3>选手1:</h3>
- <br />
- <form id="registrationForm1">
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="name">姓名</label>
- <input type="text" id="name1" class="form-input" required>
- <div class="error" id="name-error1">请输入姓名</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="gender">性别</label>
- <select id="gender1" class="form-input" required>
- <option value="">请选择</option>
- <option value="1">男</option>
- <option value="2">女</option>
- </select>
- <div class="error" id="gender-error1">请选择性别</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="ethnicity">民族</label>
- <input type="text" id="ethnicity1" class="form-input" required>
- <div class="error" id="ethnicity-error1">请输入民族</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="birthdate">出生年月</label>
- <input type="date" id="birthdate1" class="form-input" required>
- <div class="error" id="birthdate-error1">请选择出生年月</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="email">电子邮箱</label>
- <input type="email" id="email1" class="form-input" required>
- <div class="error" id="email-error1">请输入有效的电子邮箱</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="idNumber">身份证号码</label>
- <input type="text" id="idNumber1" class="form-input" required
- pattern="\d{17}[\dXx]">
- <div class="error" id="idNumber-error1">请输入18位身份证号码</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="group">组别</label>
- <select id="group1" class="form-input" required>
- <option value="">请选择</option>
- <option value="1">小学组</option>
- <option value="2">初中组</option>
- <option value="3">高中组</option>
- <option value="4">大学组</option>
- </select>
- <div class="error" id="group-error1">请选择组别</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="grade">年级</label>
- <input type="text" id="grade1" class="form-input" required>
- <div class="error" id="grade-error1">请输入年级</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="school">所在学校</label>
- <input type="text" id="school1" class="form-input" required>
- <div class="error" id="school-error1">请输入学校名称</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="schoolRegion">学校所在地区</label>
- <input type="text" id="schoolRegion1" class="form-input" required
- placeholder="省/市/区">
- <div class="error" id="schoolRegion-error1">请输入学校所在地区</div>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label class="form-label required" for="phone">联系电话</label>
- <input type="tel" id="phone1" class="form-input" required pattern="[0-9]{11}">
- <div class="error" id="phone-error1">请输入11位手机号码</div>
- </div>
- </form>
- </div>
- <div class="file-upload" id="photoSection">
- <!-- <div class="upload-icon">📷</div> -->
- <label class="form-label required" for="photo">上传文件</label>
- <input type="file" id="photo" required>
- <div class="error" id="photo-error">请上传照片</div>
- </div>
- <div class="button-group">
- <button type="button" class="btn btn-prev" id="prevToStep1">上一步</button>
- <button type="submit" class="btn btn-submit" onclick="submitData()">提交报名</button>
- </div>
- </div>
- </div>
- <!-- 上传报名表单 -->
- <div class="registration-section" id="uploadSection">
- <h2 class="content-header">上传报名表</h2>
- <div class="download-list">
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="idNumber">身份证号码</label>
- <input type="text" id="id_number" class="form-input" required pattern="\d{17}[\dXx]"
- placeholder="请填写在线报名时,团队内任一选手的身份证号码">
- </div>
- </div>
- </div>
- <div class="file-upload">
- <label class="form-label required" for="photo">上传文件</label>
- <input type="file" id="registration" required>
- </div>
- <button type="submit" class="submit-btn" onclick="submitRegistration()">提交报名表</button>
- </div>
- </div>
- </div>
- </div>
- <script>
- const requesturl = window.location.href;
- console.log("requesturl:",requesturl);
- // 切换下载和报名区域
- document.getElementById('downloadBtn').addEventListener('click', function () {
- document.getElementById('downloadBtn').classList.add('active');
- document.getElementById('registerBtn').classList.remove('active');
- document.getElementById('registerBtn1').classList.remove('active');
- document.getElementById('downloadSection').classList.add('active');
- document.getElementById('registrationSection').classList.remove('active');
- document.getElementById('uploadSection').classList.remove('active');
- });
- document.getElementById('registerBtn1').addEventListener('click', function () {
- document.getElementById('registerBtn1').classList.add('active');
- document.getElementById('downloadBtn').classList.remove('active');
- document.getElementById('registerBtn').classList.remove('active');
- document.getElementById('downloadSection').classList.remove('active');
- document.getElementById('registrationSection').classList.remove('active');
- document.getElementById('uploadSection').classList.add('active');
- });
- document.getElementById('registerBtn').addEventListener('click', function () {
- document.getElementById('registerBtn').classList.add('active');
- document.getElementById('downloadBtn').classList.remove('active');
- document.getElementById('registerBtn1').classList.remove('active');
- document.getElementById('registrationSection').classList.add('active');
- document.getElementById('downloadSection').classList.remove('active');
- document.getElementById('uploadSection').classList.remove('active');
- });
- let uploadFileUrl = ''
- document.getElementById('photo').addEventListener('change', function (e) {
- // 拼接文件名:身份证号_姓名_比赛类型_原文件名
- const idNumber = document.getElementById('idNumber1').value;
- if (!idNumber) {
- alert('请先填写身份证号');
- e.target.value = ''; // 清空已选择的文件
- return;
- }
- const file = e.target.files[0];
- if (!file) return;
- console.log('选择文件:', file);
- const fileName = `${idNumber}/${file.name}`;
- var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } });
- var params = {
- Key: fileName,
- ContentType: file.type,
- Body: file,
- 'Access-Control-Allow-Credentials': '*',
- 'ACL': 'public-read'
- };
- console.log(params)
- bucket.upload(params, function (err, data) {
- if (err) {
- console.error('上传失败:', err);
- alert('文件上传失败');
- } else {
- console.log('上传成功:', data);
- uploadFileUrl = data.Location;
- alert('文件上传成功');
- }
- });
- });
- // 比赛类型选择
- const competitionCards = document.querySelectorAll('.competition-card');
- let selectedCompetitionId = null;
- competitionCards.forEach(card => {
- card.addEventListener('click', function () {
- // 移除所有卡片的selected类
- competitionCards.forEach(c => {
- c.classList.remove('selected');
- });
- // 添加当前卡片的selected类
- this.classList.add('selected');
- // 存储选择的比赛ID
- selectedCompetitionId = this.getAttribute('data-id');
- });
- });
- // 步骤切换
- document.getElementById('nextToStep2').addEventListener('click', function () {
- if (!selectedCompetitionId) {
- alert('请先选择比赛类型');
- return;
- }
- // 设置隐藏字段的值
- document.getElementById('competitionType').value = selectedCompetitionId;
- if (selectedCompetitionId == 1) {
- document.getElementById('photoSection').style.display = 'block';
- } else {
- document.getElementById('photoSection').style.display = 'none';
- }
- // 切换到步骤2
- document.getElementById('step1').classList.remove('active');
- document.getElementById('step2').classList.add('active');
- });
- document.getElementById('prevToStep1').addEventListener('click', function () {
- // 切换回步骤1
- document.getElementById('step2').classList.remove('active');
- document.getElementById('step1').classList.add('active');
- });
- let num = 1;
- function addContestant() {
- num = num + 1;
- const html = document.getElementById('formContainer');
- const h3Create = document.createElement('h3');
- h3Create.innerText = `选手${num}:`;
- html.appendChild(h3Create);
- const brCreate = document.createElement('br');
- html.appendChild(brCreate);
- const formCrate = document.createElement('form');
- formCrate.id = `registrationForm${num}`;
- formCrate.innerHTML = `<div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="name">姓名</label>
- <input type="text" id="name${num}" class="form-input" required>
- <div class="error" id="name-error${num}">请输入姓名</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="gender">性别</label>
- <select id="gender${num}" class="form-input" required>
- <option value="">请选择</option>
- <option value="1">男</option>
- <option value="2">女</option>
- </select>
- <div class="error" id="gender-error${num}">请选择性别</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="ethnicity">民族</label>
- <input type="text" id="ethnicity${num}" class="form-input" required>
- <div class="error" id="ethnicity-error${num}">请输入民族</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="birthdate">出生年月</label>
- <input type="date" id="birthdate${num}" class="form-input" required>
- <div class="error" id="birthdate-error${num}">请选择出生年月</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="email">电子邮箱</label>
- <input type="email" id="email${num}" class="form-input" required>
- <div class="error" id="email-error${num}">请输入有效的电子邮箱</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="idNumber">身份证号码</label>
- <input type="text" id="idNumber${num}" class="form-input" required pattern="\d{17}[\dXx]">
- <div class="error" id="idNumber-error${num}">请输入18位身份证号码</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="group">组别</label>
- <select id="group${num}" class="form-input" required>
- <option value="">请选择</option>
- <option value="1">小学组</option>
- <option value="2">初中组</option>
- <option value="3">高中组</option>
- <option value="4">大学组</option>
- </select>
- <div class="error" id="group-error${num}">请选择组别</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="grade">年级</label>
- <input type="text" id="grade${num}" class="form-input" required>
- <div class="error" id="grade-error${num}">请输入年级</div>
- </div>
- </div>
- </div>
- <div class="form-row">
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="school">所在学校</label>
- <input type="text" id="school${num}" class="form-input" required>
- <div class="error" id="school-error${num}">请输入学校名称</div>
- </div>
- </div>
- <div class="form-col">
- <div class="form-group">
- <label class="form-label required" for="schoolRegion">学校所在地区</label>
- <input type="text" id="schoolRegion${num}" class="form-input" required
- placeholder="省/市/区">
- <div class="error" id="schoolRegion-error${num}">请输入学校所在地区</div>
- </div>
- </div>
- </div>
- <div class="form-group">
- <label class="form-label required" for="phone">联系电话</label>
- <input type="tel" id="phone${num}" class="form-input" required pattern="[0-9]{11}">
- <div class="error" id="phone-error${num}">请输入11位手机号码</div>
- </div>`;
- html.appendChild(formCrate);
- }
- async function submitData() {
- const requiredFields = ['name', 'gender', 'ethnicity', 'birthdate', 'email',
- 'idNumber', 'group', 'grade', 'school', 'schoolRegion', 'phone',];
- let formData = [];
- let idNumber = '';
- let idError = '';
- let phone = '';
- let phoneError = '';
- for (let i = 1; i <= num; i++) {
- let element = null;
- let errorElement = null;
- let isValid = true;
- requiredFields.forEach(field => {
- element = document.getElementById(field + i);
- errorElement = document.getElementById(`${field}-error` + i);
- if (!element.value) {
- errorElement.style.display = 'block';
- isValid = false;
- } else {
- errorElement.style.display = 'none';
- }
- });
- // 验证身份证格式
- idNumber = document.getElementById('idNumber' + i);
- idError = document.getElementById('idNumber-error' + i);
- if (!/^\d{17}[\dXx]$/.test(idNumber.value)) {
- idError.style.display = 'block';
- isValid = false;
- } else {
- idError.style.display = 'none';
- }
- // 验证手机号格式
- phone = document.getElementById('phone' + i);
- phoneError = document.getElementById('phone-error' + i);
- if (!/^[0-9]{11}$/.test(phone.value)) {
- phoneError.style.display = 'block';
- isValid = false;
- } else {
- phoneError.style.display = 'none';
- }
- if (!isValid) {
- alert(`选手${num}填写信息有误,请重新填写`);
- return;
- };
- formData.push({
- name: document.getElementById('name' + i).value,
- gender: document.getElementById('gender' + i).value,
- ethnicity: document.getElementById('ethnicity' + i).value,
- birthdate: document.getElementById('birthdate' + i).value,
- email: document.getElementById('email' + i).value,
- id_number: document.getElementById('idNumber' + i).value,
- group: document.getElementById('group' + i).value,
- grade: document.getElementById('grade' + i).value,
- school: document.getElementById('school' + i).value,
- schoolRegion: document.getElementById('schoolRegion' + i).value,
- phone: document.getElementById('phone' + i).value,
- })
- }
- try {
- // 收集表单数据
- const formDataObj = {
- type: selectedCompetitionId, // 报名类型,1桌游,2智能体
- uploadUrl: uploadFileUrl, // 上传文件的URL
- idCard: formData.map(item => item.id_number).join(","), // 选手身份证号拼接
- registrationFormUrl: "", // 报名表上传URL
- user: JSON.stringify(formData),
- };
- if (!confirm('提交之后无法再修改信息,是否确认提交?')) {
- return;
- }
- // 发送报名信息请求
- const registerResponse = await fetch(requesturl+'api/user', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(formDataObj)
- });
- if (!registerResponse.ok) {
- throw new Error('报名提交失败');
- }
- const registerData = await registerResponse.json();
- console.log(registerData);
- if(registerData.status == "ok"){
- alert("报名完成,审核情况会通过邮箱通知,请注意邮箱信息");
- }else{
- alert(registerData.message);
- }
-
- // document.getElementById('registrationForm').reset();
- } catch (error) {
- console.error('提交错误:', error);
- alert(`报名失败: ${error.message}`);
- }
- }
- let RegistrationUrl = "";
- document.getElementById('registration').addEventListener('change', function (e) {
- const idNumber = document.getElementById('id_number').value;
- if (!idNumber) {
- alert('请先填写身份证号');
- e.target.value = ''; // 清空已选择的文件
- return;
- }
- const file = e.target.files[0];
- if (!file) return;
- console.log('选择文件:', file);
- const fileName = `${idNumber}/${file.name}`;
- var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } });
- var params = {
- Key: fileName,
- ContentType: file.type,
- Body: file,
- 'Access-Control-Allow-Credentials': '*',
- 'ACL': 'public-read'
- };
- bucket.upload(params, function (err, data) {
- if (err) {
- console.error('上传失败:', err);
- alert('文件上传失败');
- } else {
- console.log('上传成功:', data);
- RegistrationUrl = data.Location;
- alert('文件上传成功');
- }
- });
- });
- async function submitRegistration() {
- const idNumber = document.getElementById('id_number').value;
- if (!idNumber) {
- alert('请先填写身份证号');
- e.target.value = ''; // 清空已选择的文件
- return;
- }
- if (!RegistrationUrl) {
- alert('请先上传文件');
- }
- if (!confirm('确定提交吗?')) {
- return;
- }
- try{
- const response = await fetch(requesturl+"api/update", {
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- },
- body: JSON.stringify({
- url: RegistrationUrl,
- id_number: idNumber
- })
- })
-
- if (!response.ok) {
- throw new Error('信息更新失败');
- }
- const registerData = await response.json();
- console.log(registerData);
- alert(registerData.message);
- }catch (error) {
- console.error('信息更新失败:', error);
- alert(error.message);
- }
- }
- </script>
- </body>
- </html>
|