| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118 |
- <!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;
- }
- .remove-Contestant {
- padding: 7px 15px;
- font-size: 14px;
- background-color: #db3434;
- color: white;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- transition: all 0.3s;
- text-align: center;
- position: absolute;
- top: 0;
- left: 80px;
- }
- .menu-btn-add:nth-last-child(1) {
- padding: 7px 15px;
- font-size: 14px;
- color: white;
- border: none;
- border-radius: 5px;
- cursor: pointer;
- transition: all 0.3s;
- text-align: center;
- background-color: #3498db;
- }
- .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;
- }
- .button-Contestant {
- display: none;
- margin-right: 20px;
- }
- .button-Contestant.active {
- display: block;
- }
- #registerBtn1 {
- display: none;
- }
- </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" style="display: flex;justify-content: space-between;">
- <h2 style="display: inline-block;font-size: 24px;">参赛信息登记</h2>
- <div class="button-Contestant">
- <button class="menu-btn-add" onclick="addContestant()">添加选手</button>
- </div>
- </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-group" style="display: flex;align-items: center;">
- <label class="form-label required" for="name">指导教师</label>
- <input style="width: 200px;margin-left: 20px;margin-right: 15px;" type="text" id="teacher" class="form-input" required>
- <div class="error" id="name-error1">请输入指导教师</div>
- </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="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.indexOf("localhost") > -1 ? "http://localhost:11111" : "http://183.36.25.93:555/";
- console.log("requesturl:", requesturl);
- const nowTime = new Date();
- const givenTime = new Date("2025-10-13")
- if (givenTime - nowTime > 0) {
- document.getElementById('registerBtn1').style.display = "none";
- } else {
- document.getElementById('registerBtn1').style.display = "block";
- }
- // 切换下载和报名区域
- 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.getElementsByClassName("button-Contestant")[0].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.getElementsByClassName("button-Contestant")[0].classList.remove('active');
- });
- let buttonContestant = false
- 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');
- console.log("selectedCompetitionId:", selectedCompetitionId);
- if (buttonContestant) {
- document.getElementsByClassName("button-Contestant")[0].classList.add('active');
- } else {
- document.getElementsByClassName("button-Contestant")[0].classList.remove('active');
- }
- });
- let uploadFileUrl = ''
- // 比赛类型选择
- 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;
- }
- // 切换到步骤2
- document.getElementById('step1').classList.remove('active');
- document.getElementById('step2').classList.add('active');
- document.getElementsByClassName("button-Contestant")[0].classList.add('active');
- buttonContestant = true
- });
- document.getElementById('prevToStep1').addEventListener('click', function () {
- // 切换回步骤1
- document.getElementById('step2').classList.remove('active');
- document.getElementById('step1').classList.add('active');
- document.getElementsByClassName("button-Contestant")[0].classList.remove('active');
- buttonContestant = false
- });
- let num = 1;
- let addList = []
- function addContestant() {
- num = num + 1;
- addList.push(num)
- const ifFirst = addList.find(item => item === 1);
- let addListLength = addList.length+1;
- if (ifFirst) {
- addListLength = addList.length
- }
- const html = document.getElementById('formContainer');
- const createDiv = document.createElement('div');
- createDiv.id = `addformContainer${num}`;
- createDiv.style.position = 'relative';
- const h3Create = document.createElement('h3');
- h3Create.innerText = `选手${addListLength}:`;
- createDiv.appendChild(h3Create);
- const delButton = document.createElement('button');
- delButton.innerText = `删除选手${addListLength}`;
- delButton.className = 'menu-btn-add remove-Contestant';
- delButton.onclick = removeContestant;
- createDiv.appendChild(delButton);
- const brCreate = document.createElement('br');
- createDiv.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>`;
- createDiv.appendChild(formCrate);
- html.appendChild(createDiv);
- }
-
- function removeContestant(e) {
- const parentElement = Number(e.target.parentElement.id && e.target.parentElement.id.slice(16));
- addList = addList.filter(item => item !== parentElement);
- const html = document.getElementById('formContainer');
- let selectForm = html.querySelector(`div#addformContainer${parentElement}`);
- if (selectForm) html.removeChild(selectForm);
- // 依次递增更新剩余选手的序号
- addList.forEach((item, idx) => {
- let formDiv = html.querySelector(`div#addformContainer${item}`);
- if (formDiv) {
- formDiv.querySelector('h3').innerText = `选手${idx + 2}:`;
- formDiv.querySelector('button').innerText = `删除选手${idx + 2}`;
- }
- });
- // num = num - 1;
- }
- 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 = '';
- let i = 0
- let isFirst = addList.find(item => item === 1);
- if(!isFirst) addList.unshift(1);
-
- for (let j = 0; j <= addList.length-1; j++) {
- let element = null;
- let errorElement = null;
- let isValid = true;
- i = addList[j]
- 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(`选手${j+1}填写信息有误,请重新填写`);
- 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,
- })
- }
- const teacher = document.getElementById('teacher').value;
- if(!teacher) {
- alert('请填写指导老师');
- return;
- }
- try {
- // 收集表单数据
- const formDataObj = {
- type: selectedCompetitionId, // 报名类型,1桌游,2智能体
- uploadUrl: teacher, // 上传文件的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>
|