index.html 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>比赛报名系统</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
  15. height: 100vh;
  16. display: flex;
  17. flex-direction: column;
  18. overflow: hidden;
  19. background-color: #f5f7fa;
  20. }
  21. /* 导航栏样式 */
  22. nav {
  23. background: linear-gradient(135deg, #1a73e8, #0d47a1);
  24. color: white;
  25. padding: 15px 30px;
  26. display: flex;
  27. align-items: center;
  28. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  29. z-index: 100;
  30. }
  31. .logo {
  32. font-size: 24px;
  33. font-weight: bold;
  34. margin-right: 15px;
  35. }
  36. .event-name {
  37. font-size: 20px;
  38. flex-grow: 1;
  39. }
  40. /* 主内容区域 */
  41. .main-container {
  42. display: flex;
  43. flex: 1;
  44. overflow: hidden;
  45. }
  46. /* 左侧菜单 */
  47. .sidebar {
  48. width: 200px;
  49. background-color: #2c3e50;
  50. color: white;
  51. display: flex;
  52. flex-direction: column;
  53. padding: 20px 0;
  54. }
  55. .menu-btn {
  56. padding: 15px 20px;
  57. margin: 10px 15px;
  58. background-color: #3498db;
  59. color: white;
  60. border: none;
  61. border-radius: 5px;
  62. font-size: 16px;
  63. cursor: pointer;
  64. transition: all 0.3s;
  65. text-align: center;
  66. }
  67. .menu-btn:hover {
  68. background-color: #2980b9;
  69. transform: translateY(-2px);
  70. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  71. }
  72. .menu-btn.active {
  73. background-color: #1abc9c;
  74. }
  75. /* 右侧内容区域 */
  76. .content-area {
  77. flex: 1;
  78. display: flex;
  79. flex-direction: column;
  80. padding: 20px;
  81. background-color: white;
  82. border-radius: 10px;
  83. margin: 20px;
  84. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  85. overflow: hidden;
  86. }
  87. .content-header {
  88. font-size: 24px;
  89. color: #2c3e50;
  90. margin-bottom: 20px;
  91. padding-bottom: 10px;
  92. border-bottom: 2px solid #3498db;
  93. }
  94. /* 下载区域 */
  95. .download-section {
  96. display: none;
  97. flex-direction: column;
  98. height: 100%;
  99. }
  100. .download-section.active {
  101. display: flex;
  102. }
  103. .download-list {
  104. overflow-y: auto;
  105. flex: 1;
  106. }
  107. .download-item {
  108. width: calc(100% - 30px);
  109. background-color: #f8f9fa;
  110. border: 1px solid #e9ecef;
  111. border-radius: 8px;
  112. padding: 15px;
  113. margin-bottom: 15px;
  114. display: flex;
  115. align-items: center;
  116. transition: all 0.3s;
  117. }
  118. .download-item:hover {
  119. transform: translateX(5px);
  120. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  121. border-color: #3498db;
  122. }
  123. .file-icon {
  124. font-size: 24px;
  125. margin-right: 15px;
  126. color: #3498db;
  127. }
  128. .file-info {
  129. flex: 1;
  130. }
  131. .file-title {
  132. font-weight: bold;
  133. margin-bottom: 5px;
  134. }
  135. .file-desc {
  136. color: #6c757d;
  137. font-size: 14px;
  138. }
  139. .download-btn {
  140. background-color: #28a745;
  141. color: white;
  142. border: none;
  143. padding: 8px 15px;
  144. border-radius: 5px;
  145. cursor: pointer;
  146. transition: background-color 0.3s;
  147. text-decoration: none;
  148. }
  149. .download-btn:hover {
  150. background-color: #218838;
  151. }
  152. /* 报名区域 */
  153. .registration-section {
  154. display: none;
  155. flex-direction: column;
  156. height: 100%;
  157. overflow-y: auto;
  158. position: relative;
  159. }
  160. .registration-section.active {
  161. display: flex;
  162. }
  163. .form-container {
  164. flex: 1;
  165. padding-right: 10px;
  166. }
  167. .form-group {
  168. margin-bottom: 20px;
  169. }
  170. .form-label {
  171. display: block;
  172. margin-bottom: 8px;
  173. font-weight: bold;
  174. color: #495057;
  175. }
  176. .required::after {
  177. content: " *";
  178. color: #e74c3c;
  179. }
  180. .form-input {
  181. width: 100%;
  182. padding: 12px;
  183. border: 1px solid #ced4da;
  184. border-radius: 5px;
  185. font-size: 16px;
  186. transition: border-color 0.3s;
  187. }
  188. .form-input:focus {
  189. border-color: #3498db;
  190. outline: none;
  191. box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
  192. }
  193. .form-row {
  194. display: flex;
  195. gap: 20px;
  196. }
  197. .form-col {
  198. flex: 1;
  199. }
  200. .file-upload {
  201. border: 2px dashed #ced4da;
  202. padding: 30px;
  203. text-align: center;
  204. border-radius: 8px;
  205. margin: 20px 0;
  206. background-color: #f8f9fa;
  207. transition: all 0.3s;
  208. }
  209. .file-upload:hover {
  210. border-color: #3498db;
  211. background-color: #e3f2fd;
  212. }
  213. .upload-icon {
  214. font-size: 40px;
  215. color: #3498db;
  216. margin-bottom: 15px;
  217. }
  218. .submit-btn {
  219. background-color: #1a73e8;
  220. color: white;
  221. border: none;
  222. padding: 14px 25px;
  223. border-radius: 5px;
  224. font-size: 18px;
  225. cursor: pointer;
  226. transition: all 0.3s;
  227. margin-top: 20px;
  228. width: 100%;
  229. }
  230. .submit-btn:hover {
  231. background-color: #0d47a1;
  232. transform: translateY(-2px);
  233. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  234. }
  235. .error {
  236. color: #e74c3c;
  237. font-size: 14px;
  238. margin-top: 5px;
  239. display: none;
  240. }
  241. .menu-btn-add {
  242. position: absolute;
  243. right: 20px;
  244. top: 1px;
  245. padding: 7px 15px;
  246. font-size: 14px;
  247. background-color: #3498db;
  248. color: white;
  249. border: none;
  250. border-radius: 5px;
  251. cursor: pointer;
  252. transition: all 0.3s;
  253. text-align: center;
  254. }
  255. .step-container {
  256. display: none;
  257. }
  258. .step-container.active {
  259. display: block;
  260. }
  261. .competition-grid {
  262. display: grid;
  263. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  264. gap: 20px;
  265. margin-bottom: 30px;
  266. }
  267. .competition-card {
  268. border: 1px solid #e0e0e0;
  269. border-radius: 10px;
  270. padding: 20px;
  271. text-align: center;
  272. cursor: pointer;
  273. transition: all 0.3s;
  274. }
  275. .competition-card:hover {
  276. border-color: #1a73e8;
  277. box-shadow: 0 4px 12px rgba(26, 115, 232, 0.15);
  278. transform: translateY(-5px);
  279. }
  280. .competition-card.selected {
  281. border-color: #1a73e8;
  282. background-color: #e8f0fe;
  283. }
  284. .competition-icon {
  285. font-size: 36px;
  286. color: #1a73e8;
  287. margin-bottom: 15px;
  288. }
  289. .competition-name {
  290. font-weight: 500;
  291. color: #202124;
  292. }
  293. .btn {
  294. padding: 12px 30px;
  295. border-radius: 8px;
  296. font-size: 16px;
  297. font-weight: 500;
  298. cursor: pointer;
  299. transition: all 0.3s;
  300. border: none;
  301. }
  302. .btn-prev {
  303. background-color: #f8f9fa;
  304. color: #5f6368;
  305. }
  306. .btn-prev:hover {
  307. background-color: #e8f0fe;
  308. color: #1a73e8;
  309. }
  310. .btn-next {
  311. background-color: #1a73e8;
  312. color: white;
  313. }
  314. .btn-next:hover {
  315. background-color: #0d47a1;
  316. }
  317. .btn-submit {
  318. background-color: #34a853;
  319. color: white;
  320. }
  321. .btn-submit:hover {
  322. background-color: #2d9249;
  323. }
  324. .error {
  325. color: #ea4335;
  326. font-size: 14px;
  327. margin-top: 5px;
  328. display: none;
  329. }
  330. .button-group {
  331. display: flex;
  332. justify-content: space-between;
  333. margin-top: 30px;
  334. }
  335. .step-title {
  336. font-size: 18px;
  337. color: #202124;
  338. margin-bottom: 20px;
  339. padding-bottom: 10px;
  340. border-bottom: 1px solid #e0e0e0;
  341. }
  342. </style>
  343. <script src="https://sdk.amazonaws.com/js/aws-sdk-2.235.1.min.js"></script>
  344. <script>
  345. var credentials = {
  346. accessKeyId: 'AKIATLPEDU37QV5CHLMH',
  347. secretAccessKey: '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'
  348. }; //秘鑰形式的登錄上傳
  349. window.AWS.config.update(credentials);
  350. window.AWS.config.region = 'cn-northwest-1'; //設置區域
  351. </script>
  352. </head>
  353. <body>
  354. <!-- 导航栏 -->
  355. <nav>
  356. <img src="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/a/logo.png" alt="logo"
  357. style="width: 40px;margin-right: 15px;"></img>
  358. <div class="event-name">第六届广东省青少年创新思维及科技实践大赛创新思维挑战赛(选手报名)</div>
  359. </nav>
  360. <!-- 主内容区域 -->
  361. <div class="main-container">
  362. <!-- 左侧菜单 -->
  363. <div class="sidebar">
  364. <button class="menu-btn active" id="downloadBtn">资料下载</button>
  365. <button class="menu-btn" id="registerBtn">在线报名</button>
  366. <button class="menu-btn" id="registerBtn1">资格确认</button>
  367. </div>
  368. <!-- 右侧内容区域 -->
  369. <div class="content-area">
  370. <!-- 下载区域 -->
  371. <div class="download-section active" id="downloadSection">
  372. <h2 class="content-header">比赛资料下载</h2>
  373. <div class="download-list">
  374. <div class="download-item">
  375. <div class="file-icon">📋</div>
  376. <div class="file-info">
  377. <div class="file-title">第六届广东省青少年创新思维及科技实践大赛创新思维挑战赛</div>
  378. </div>
  379. <a target="_blank"
  380. 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"
  381. class="download-btn" download="第六届广东省青少年创新思维及科技实践大赛创新思维挑战赛.pdf">下载</a>
  382. </div>
  383. <div class="download-item">
  384. <div class="file-icon">📊</div>
  385. <div class="file-info">
  386. <div class="file-title">第六届广东省青少年创新思维及科技实践大赛的通知</div>
  387. </div>
  388. <a target="_blank"
  389. 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"
  390. class="download-btn" download="第六届广东省青少年创新思维及科技实践大赛的通知.pdf">下载</a>
  391. </div>
  392. <div class="download-item">
  393. <div class="file-icon">📄</div>
  394. <div class="file-info">
  395. <div class="file-title">报名表模板</div>
  396. <div class="file-desc">完成在线报名后,请先下载该模板,经所在学校盖章确认后,将盖章后的模板上传至【资格确认】板块,即可完成赛前准备。</div>
  397. </div>
  398. <a target="_blank"
  399. href="https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/a/%E6%8A%A5%E5%90%8D%E8%A1%A8.docx"
  400. class="download-btn" download>下载</a>
  401. </div>
  402. </div>
  403. </div>
  404. <!-- 报名区域 -->
  405. <div class="registration-section " id="registrationSection">
  406. <!-- <div class="select-type">
  407. <select id="selectType" class="form-input" required >
  408. <option value="">请选择参赛类型</option>
  409. <option value="1">桌游设计挑战类</option>
  410. <option value="2">智能体应用类</option>
  411. </select>
  412. </div> -->
  413. <div class="content-header">
  414. <h2 style="display: inline-block;font-size: 24px;">参赛信息登记</h2>
  415. <button class="menu-btn-add" onclick="addContestant()">添加选手</button>
  416. </div>
  417. <!-- 步骤1:选择比赛类型 -->
  418. <div id="step1" class="step-container active">
  419. <div class="step-title">第一步:请选择您要报名的比赛类型</div>
  420. <div class="competition-grid">
  421. <div class="competition-card" data-id="1">
  422. <div class="competition-icon">🧮</div>
  423. <div class="competition-name">桌游设计挑战类</div>
  424. </div>
  425. <div class="competition-card" data-id="2">
  426. <div class="competition-icon">💻</div>
  427. <div class="competition-name">智能体应用类</div>
  428. </div>
  429. </div>
  430. <div class="button-group">
  431. <div></div> <!-- 占位 -->
  432. <button class="btn btn-next" id="nextToStep2">下一步</button>
  433. </div>
  434. </div>
  435. <!-- 步骤2:填写报名信息 -->
  436. <div id="step2" class="step-container">
  437. <div class="step-title">第二步:填写报名信息</div>
  438. <div class="form-container" id="formContainer">
  439. <input type="hidden" id="competitionType" value="">
  440. <h3>选手1:</h3>
  441. <br />
  442. <form id="registrationForm1">
  443. <div class="form-row">
  444. <div class="form-col">
  445. <div class="form-group">
  446. <label class="form-label required" for="name">姓名</label>
  447. <input type="text" id="name1" class="form-input" required>
  448. <div class="error" id="name-error1">请输入姓名</div>
  449. </div>
  450. </div>
  451. <div class="form-col">
  452. <div class="form-group">
  453. <label class="form-label required" for="gender">性别</label>
  454. <select id="gender1" class="form-input" required>
  455. <option value="">请选择</option>
  456. <option value="1">男</option>
  457. <option value="2">女</option>
  458. </select>
  459. <div class="error" id="gender-error1">请选择性别</div>
  460. </div>
  461. </div>
  462. </div>
  463. <div class="form-row">
  464. <div class="form-col">
  465. <div class="form-group">
  466. <label class="form-label required" for="ethnicity">民族</label>
  467. <input type="text" id="ethnicity1" class="form-input" required>
  468. <div class="error" id="ethnicity-error1">请输入民族</div>
  469. </div>
  470. </div>
  471. <div class="form-col">
  472. <div class="form-group">
  473. <label class="form-label required" for="birthdate">出生年月</label>
  474. <input type="date" id="birthdate1" class="form-input" required>
  475. <div class="error" id="birthdate-error1">请选择出生年月</div>
  476. </div>
  477. </div>
  478. </div>
  479. <div class="form-row">
  480. <div class="form-col">
  481. <div class="form-group">
  482. <label class="form-label required" for="email">电子邮箱</label>
  483. <input type="email" id="email1" class="form-input" required>
  484. <div class="error" id="email-error1">请输入有效的电子邮箱</div>
  485. </div>
  486. </div>
  487. <div class="form-col">
  488. <div class="form-group">
  489. <label class="form-label required" for="idNumber">身份证号码</label>
  490. <input type="text" id="idNumber1" class="form-input" required
  491. pattern="\d{17}[\dXx]">
  492. <div class="error" id="idNumber-error1">请输入18位身份证号码</div>
  493. </div>
  494. </div>
  495. </div>
  496. <div class="form-row">
  497. <div class="form-col">
  498. <div class="form-group">
  499. <label class="form-label required" for="group">组别</label>
  500. <select id="group1" class="form-input" required>
  501. <option value="">请选择</option>
  502. <option value="1">小学组</option>
  503. <option value="2">初中组</option>
  504. <option value="3">高中组</option>
  505. <option value="4">大学组</option>
  506. </select>
  507. <div class="error" id="group-error1">请选择组别</div>
  508. </div>
  509. </div>
  510. <div class="form-col">
  511. <div class="form-group">
  512. <label class="form-label required" for="grade">年级</label>
  513. <input type="text" id="grade1" class="form-input" required>
  514. <div class="error" id="grade-error1">请输入年级</div>
  515. </div>
  516. </div>
  517. </div>
  518. <div class="form-row">
  519. <div class="form-col">
  520. <div class="form-group">
  521. <label class="form-label required" for="school">所在学校</label>
  522. <input type="text" id="school1" class="form-input" required>
  523. <div class="error" id="school-error1">请输入学校名称</div>
  524. </div>
  525. </div>
  526. <div class="form-col">
  527. <div class="form-group">
  528. <label class="form-label required" for="schoolRegion">学校所在地区</label>
  529. <input type="text" id="schoolRegion1" class="form-input" required
  530. placeholder="省/市/区">
  531. <div class="error" id="schoolRegion-error1">请输入学校所在地区</div>
  532. </div>
  533. </div>
  534. </div>
  535. <div class="form-group">
  536. <label class="form-label required" for="phone">联系电话</label>
  537. <input type="tel" id="phone1" class="form-input" required pattern="[0-9]{11}">
  538. <div class="error" id="phone-error1">请输入11位手机号码</div>
  539. </div>
  540. </form>
  541. </div>
  542. <div class="file-upload" id="photoSection">
  543. <!-- <div class="upload-icon">📷</div> -->
  544. <label class="form-label required" for="photo">上传文件</label>
  545. <input type="file" id="photo" required>
  546. <div class="error" id="photo-error">请上传照片</div>
  547. </div>
  548. <div class="button-group">
  549. <button type="button" class="btn btn-prev" id="prevToStep1">上一步</button>
  550. <button type="submit" class="btn btn-submit" onclick="submitData()">提交报名</button>
  551. </div>
  552. </div>
  553. </div>
  554. <!-- 上传报名表单 -->
  555. <div class="registration-section" id="uploadSection">
  556. <h2 class="content-header">上传报名表</h2>
  557. <div class="download-list">
  558. <div class="form-row">
  559. <div class="form-col">
  560. <div class="form-group">
  561. <label class="form-label required" for="idNumber">身份证号码</label>
  562. <input type="text" id="id_number" class="form-input" required pattern="\d{17}[\dXx]"
  563. placeholder="请填写在线报名时,团队内任一选手的身份证号码">
  564. </div>
  565. </div>
  566. </div>
  567. <div class="file-upload">
  568. <label class="form-label required" for="photo">上传文件</label>
  569. <input type="file" id="registration" required>
  570. </div>
  571. <button type="submit" class="submit-btn" onclick="submitRegistration()">提交报名表</button>
  572. </div>
  573. </div>
  574. </div>
  575. </div>
  576. <script>
  577. const requesturl = window.location.href;
  578. console.log("requesturl:",requesturl);
  579. // 切换下载和报名区域
  580. document.getElementById('downloadBtn').addEventListener('click', function () {
  581. document.getElementById('downloadBtn').classList.add('active');
  582. document.getElementById('registerBtn').classList.remove('active');
  583. document.getElementById('registerBtn1').classList.remove('active');
  584. document.getElementById('downloadSection').classList.add('active');
  585. document.getElementById('registrationSection').classList.remove('active');
  586. document.getElementById('uploadSection').classList.remove('active');
  587. });
  588. document.getElementById('registerBtn1').addEventListener('click', function () {
  589. document.getElementById('registerBtn1').classList.add('active');
  590. document.getElementById('downloadBtn').classList.remove('active');
  591. document.getElementById('registerBtn').classList.remove('active');
  592. document.getElementById('downloadSection').classList.remove('active');
  593. document.getElementById('registrationSection').classList.remove('active');
  594. document.getElementById('uploadSection').classList.add('active');
  595. });
  596. document.getElementById('registerBtn').addEventListener('click', function () {
  597. document.getElementById('registerBtn').classList.add('active');
  598. document.getElementById('downloadBtn').classList.remove('active');
  599. document.getElementById('registerBtn1').classList.remove('active');
  600. document.getElementById('registrationSection').classList.add('active');
  601. document.getElementById('downloadSection').classList.remove('active');
  602. document.getElementById('uploadSection').classList.remove('active');
  603. });
  604. let uploadFileUrl = ''
  605. document.getElementById('photo').addEventListener('change', function (e) {
  606. // 拼接文件名:身份证号_姓名_比赛类型_原文件名
  607. const idNumber = document.getElementById('idNumber1').value;
  608. if (!idNumber) {
  609. alert('请先填写身份证号');
  610. e.target.value = ''; // 清空已选择的文件
  611. return;
  612. }
  613. const file = e.target.files[0];
  614. if (!file) return;
  615. console.log('选择文件:', file);
  616. const fileName = `${idNumber}/${file.name}`;
  617. var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } });
  618. var params = {
  619. Key: fileName,
  620. ContentType: file.type,
  621. Body: file,
  622. 'Access-Control-Allow-Credentials': '*',
  623. 'ACL': 'public-read'
  624. };
  625. console.log(params)
  626. bucket.upload(params, function (err, data) {
  627. if (err) {
  628. console.error('上传失败:', err);
  629. alert('文件上传失败');
  630. } else {
  631. console.log('上传成功:', data);
  632. uploadFileUrl = data.Location;
  633. alert('文件上传成功');
  634. }
  635. });
  636. });
  637. // 比赛类型选择
  638. const competitionCards = document.querySelectorAll('.competition-card');
  639. let selectedCompetitionId = null;
  640. competitionCards.forEach(card => {
  641. card.addEventListener('click', function () {
  642. // 移除所有卡片的selected类
  643. competitionCards.forEach(c => {
  644. c.classList.remove('selected');
  645. });
  646. // 添加当前卡片的selected类
  647. this.classList.add('selected');
  648. // 存储选择的比赛ID
  649. selectedCompetitionId = this.getAttribute('data-id');
  650. });
  651. });
  652. // 步骤切换
  653. document.getElementById('nextToStep2').addEventListener('click', function () {
  654. if (!selectedCompetitionId) {
  655. alert('请先选择比赛类型');
  656. return;
  657. }
  658. // 设置隐藏字段的值
  659. document.getElementById('competitionType').value = selectedCompetitionId;
  660. if (selectedCompetitionId == 1) {
  661. document.getElementById('photoSection').style.display = 'block';
  662. } else {
  663. document.getElementById('photoSection').style.display = 'none';
  664. }
  665. // 切换到步骤2
  666. document.getElementById('step1').classList.remove('active');
  667. document.getElementById('step2').classList.add('active');
  668. });
  669. document.getElementById('prevToStep1').addEventListener('click', function () {
  670. // 切换回步骤1
  671. document.getElementById('step2').classList.remove('active');
  672. document.getElementById('step1').classList.add('active');
  673. });
  674. let num = 1;
  675. function addContestant() {
  676. num = num + 1;
  677. const html = document.getElementById('formContainer');
  678. const h3Create = document.createElement('h3');
  679. h3Create.innerText = `选手${num}:`;
  680. html.appendChild(h3Create);
  681. const brCreate = document.createElement('br');
  682. html.appendChild(brCreate);
  683. const formCrate = document.createElement('form');
  684. formCrate.id = `registrationForm${num}`;
  685. formCrate.innerHTML = `<div class="form-row">
  686. <div class="form-col">
  687. <div class="form-group">
  688. <label class="form-label required" for="name">姓名</label>
  689. <input type="text" id="name${num}" class="form-input" required>
  690. <div class="error" id="name-error${num}">请输入姓名</div>
  691. </div>
  692. </div>
  693. <div class="form-col">
  694. <div class="form-group">
  695. <label class="form-label required" for="gender">性别</label>
  696. <select id="gender${num}" class="form-input" required>
  697. <option value="">请选择</option>
  698. <option value="1">男</option>
  699. <option value="2">女</option>
  700. </select>
  701. <div class="error" id="gender-error${num}">请选择性别</div>
  702. </div>
  703. </div>
  704. </div>
  705. <div class="form-row">
  706. <div class="form-col">
  707. <div class="form-group">
  708. <label class="form-label required" for="ethnicity">民族</label>
  709. <input type="text" id="ethnicity${num}" class="form-input" required>
  710. <div class="error" id="ethnicity-error${num}">请输入民族</div>
  711. </div>
  712. </div>
  713. <div class="form-col">
  714. <div class="form-group">
  715. <label class="form-label required" for="birthdate">出生年月</label>
  716. <input type="date" id="birthdate${num}" class="form-input" required>
  717. <div class="error" id="birthdate-error${num}">请选择出生年月</div>
  718. </div>
  719. </div>
  720. </div>
  721. <div class="form-row">
  722. <div class="form-col">
  723. <div class="form-group">
  724. <label class="form-label required" for="email">电子邮箱</label>
  725. <input type="email" id="email${num}" class="form-input" required>
  726. <div class="error" id="email-error${num}">请输入有效的电子邮箱</div>
  727. </div>
  728. </div>
  729. <div class="form-col">
  730. <div class="form-group">
  731. <label class="form-label required" for="idNumber">身份证号码</label>
  732. <input type="text" id="idNumber${num}" class="form-input" required pattern="\d{17}[\dXx]">
  733. <div class="error" id="idNumber-error${num}">请输入18位身份证号码</div>
  734. </div>
  735. </div>
  736. </div>
  737. <div class="form-row">
  738. <div class="form-col">
  739. <div class="form-group">
  740. <label class="form-label required" for="group">组别</label>
  741. <select id="group${num}" class="form-input" required>
  742. <option value="">请选择</option>
  743. <option value="1">小学组</option>
  744. <option value="2">初中组</option>
  745. <option value="3">高中组</option>
  746. <option value="4">大学组</option>
  747. </select>
  748. <div class="error" id="group-error${num}">请选择组别</div>
  749. </div>
  750. </div>
  751. <div class="form-col">
  752. <div class="form-group">
  753. <label class="form-label required" for="grade">年级</label>
  754. <input type="text" id="grade${num}" class="form-input" required>
  755. <div class="error" id="grade-error${num}">请输入年级</div>
  756. </div>
  757. </div>
  758. </div>
  759. <div class="form-row">
  760. <div class="form-col">
  761. <div class="form-group">
  762. <label class="form-label required" for="school">所在学校</label>
  763. <input type="text" id="school${num}" class="form-input" required>
  764. <div class="error" id="school-error${num}">请输入学校名称</div>
  765. </div>
  766. </div>
  767. <div class="form-col">
  768. <div class="form-group">
  769. <label class="form-label required" for="schoolRegion">学校所在地区</label>
  770. <input type="text" id="schoolRegion${num}" class="form-input" required
  771. placeholder="省/市/区">
  772. <div class="error" id="schoolRegion-error${num}">请输入学校所在地区</div>
  773. </div>
  774. </div>
  775. </div>
  776. <div class="form-group">
  777. <label class="form-label required" for="phone">联系电话</label>
  778. <input type="tel" id="phone${num}" class="form-input" required pattern="[0-9]{11}">
  779. <div class="error" id="phone-error${num}">请输入11位手机号码</div>
  780. </div>`;
  781. html.appendChild(formCrate);
  782. }
  783. async function submitData() {
  784. const requiredFields = ['name', 'gender', 'ethnicity', 'birthdate', 'email',
  785. 'idNumber', 'group', 'grade', 'school', 'schoolRegion', 'phone',];
  786. let formData = [];
  787. let idNumber = '';
  788. let idError = '';
  789. let phone = '';
  790. let phoneError = '';
  791. for (let i = 1; i <= num; i++) {
  792. let element = null;
  793. let errorElement = null;
  794. let isValid = true;
  795. requiredFields.forEach(field => {
  796. element = document.getElementById(field + i);
  797. errorElement = document.getElementById(`${field}-error` + i);
  798. if (!element.value) {
  799. errorElement.style.display = 'block';
  800. isValid = false;
  801. } else {
  802. errorElement.style.display = 'none';
  803. }
  804. });
  805. // 验证身份证格式
  806. idNumber = document.getElementById('idNumber' + i);
  807. idError = document.getElementById('idNumber-error' + i);
  808. if (!/^\d{17}[\dXx]$/.test(idNumber.value)) {
  809. idError.style.display = 'block';
  810. isValid = false;
  811. } else {
  812. idError.style.display = 'none';
  813. }
  814. // 验证手机号格式
  815. phone = document.getElementById('phone' + i);
  816. phoneError = document.getElementById('phone-error' + i);
  817. if (!/^[0-9]{11}$/.test(phone.value)) {
  818. phoneError.style.display = 'block';
  819. isValid = false;
  820. } else {
  821. phoneError.style.display = 'none';
  822. }
  823. if (!isValid) {
  824. alert(`选手${num}填写信息有误,请重新填写`);
  825. return;
  826. };
  827. formData.push({
  828. name: document.getElementById('name' + i).value,
  829. gender: document.getElementById('gender' + i).value,
  830. ethnicity: document.getElementById('ethnicity' + i).value,
  831. birthdate: document.getElementById('birthdate' + i).value,
  832. email: document.getElementById('email' + i).value,
  833. id_number: document.getElementById('idNumber' + i).value,
  834. group: document.getElementById('group' + i).value,
  835. grade: document.getElementById('grade' + i).value,
  836. school: document.getElementById('school' + i).value,
  837. schoolRegion: document.getElementById('schoolRegion' + i).value,
  838. phone: document.getElementById('phone' + i).value,
  839. })
  840. }
  841. try {
  842. // 收集表单数据
  843. const formDataObj = {
  844. type: selectedCompetitionId, // 报名类型,1桌游,2智能体
  845. uploadUrl: uploadFileUrl, // 上传文件的URL
  846. idCard: formData.map(item => item.id_number).join(","), // 选手身份证号拼接
  847. registrationFormUrl: "", // 报名表上传URL
  848. user: JSON.stringify(formData),
  849. };
  850. if (!confirm('提交之后无法再修改信息,是否确认提交?')) {
  851. return;
  852. }
  853. // 发送报名信息请求
  854. const registerResponse = await fetch(requesturl+'api/user', {
  855. method: 'POST',
  856. headers: {
  857. 'Content-Type': 'application/json'
  858. },
  859. body: JSON.stringify(formDataObj)
  860. });
  861. if (!registerResponse.ok) {
  862. throw new Error('报名提交失败');
  863. }
  864. const registerData = await registerResponse.json();
  865. console.log(registerData);
  866. if(registerData.status == "ok"){
  867. alert("报名完成,审核情况会通过邮箱通知,请注意邮箱信息");
  868. }else{
  869. alert(registerData.message);
  870. }
  871. // document.getElementById('registrationForm').reset();
  872. } catch (error) {
  873. console.error('提交错误:', error);
  874. alert(`报名失败: ${error.message}`);
  875. }
  876. }
  877. let RegistrationUrl = "";
  878. document.getElementById('registration').addEventListener('change', function (e) {
  879. const idNumber = document.getElementById('id_number').value;
  880. if (!idNumber) {
  881. alert('请先填写身份证号');
  882. e.target.value = ''; // 清空已选择的文件
  883. return;
  884. }
  885. const file = e.target.files[0];
  886. if (!file) return;
  887. console.log('选择文件:', file);
  888. const fileName = `${idNumber}/${file.name}`;
  889. var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } });
  890. var params = {
  891. Key: fileName,
  892. ContentType: file.type,
  893. Body: file,
  894. 'Access-Control-Allow-Credentials': '*',
  895. 'ACL': 'public-read'
  896. };
  897. bucket.upload(params, function (err, data) {
  898. if (err) {
  899. console.error('上传失败:', err);
  900. alert('文件上传失败');
  901. } else {
  902. console.log('上传成功:', data);
  903. RegistrationUrl = data.Location;
  904. alert('文件上传成功');
  905. }
  906. });
  907. });
  908. async function submitRegistration() {
  909. const idNumber = document.getElementById('id_number').value;
  910. if (!idNumber) {
  911. alert('请先填写身份证号');
  912. e.target.value = ''; // 清空已选择的文件
  913. return;
  914. }
  915. if (!RegistrationUrl) {
  916. alert('请先上传文件');
  917. }
  918. if (!confirm('确定提交吗?')) {
  919. return;
  920. }
  921. try{
  922. const response = await fetch(requesturl+"api/update", {
  923. method: "POST",
  924. headers: {
  925. "Content-Type": "application/json"
  926. },
  927. body: JSON.stringify({
  928. url: RegistrationUrl,
  929. id_number: idNumber
  930. })
  931. })
  932. if (!response.ok) {
  933. throw new Error('信息更新失败');
  934. }
  935. const registerData = await response.json();
  936. console.log(registerData);
  937. alert(registerData.message);
  938. }catch (error) {
  939. console.error('信息更新失败:', error);
  940. alert(error.message);
  941. }
  942. }
  943. </script>
  944. </body>
  945. </html>