|
@@ -641,17 +641,15 @@
|
|
|
<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]"
|
|
|
+ <input type="text" id="id_number" class="form-input" required pattern="\d{17}[\dXx]"
|
|
|
placeholder="请填写在线报名时,团队内任一选手的身份证号码">
|
|
|
- <div class="error" id="idNumber-error1">请输入18位身份证号码</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="file-upload">
|
|
|
<label class="form-label required" for="photo">上传文件</label>
|
|
|
- <input type="file" id="photo" required>
|
|
|
- <div class="error" id="photo-error">请上传照片</div>
|
|
|
+ <input type="file" id="registration" required>
|
|
|
</div>
|
|
|
<button type="submit" class="submit-btn" onclick="submitRegistration()">提交报名表</button>
|
|
|
</div>
|
|
@@ -660,6 +658,9 @@
|
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
+ const requesturl = window.location.href.indexOf("localhost") > -1 ? "http://localhost:11111" : window.location.origin+":11111";
|
|
|
+ console.log("requesturl:",requesturl);
|
|
|
+
|
|
|
// 切换下载和报名区域
|
|
|
document.getElementById('downloadBtn').addEventListener('click', function () {
|
|
|
document.getElementById('downloadBtn').classList.add('active');
|
|
@@ -749,9 +750,9 @@
|
|
|
|
|
|
// 设置隐藏字段的值
|
|
|
document.getElementById('competitionType').value = selectedCompetitionId;
|
|
|
- if(selectedCompetitionId == 1){
|
|
|
+ if (selectedCompetitionId == 1) {
|
|
|
document.getElementById('photoSection').style.display = 'block';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
document.getElementById('photoSection').style.display = 'none';
|
|
|
}
|
|
|
|
|
@@ -955,14 +956,15 @@
|
|
|
const formDataObj = {
|
|
|
type: selectedCompetitionId, // 报名类型,1桌游,2智能体
|
|
|
uploadUrl: uploadFileUrl, // 上传文件的URL
|
|
|
- idCard: formData.map(item=>item.id_number).join(","), // 选手身份证号拼接
|
|
|
+ idCard: formData.map(item => item.id_number).join(","), // 选手身份证号拼接
|
|
|
registrationFormUrl: "", // 报名表上传URL
|
|
|
user: JSON.stringify(formData),
|
|
|
};
|
|
|
- console.log(formDataObj);
|
|
|
-
|
|
|
+ if (!confirm('提交之后无法再修改信息,是否确认提交?')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 发送报名信息请求
|
|
|
- const registerResponse = await fetch('http://localhost:11111/api/user', {
|
|
|
+ const registerResponse = await fetch('https://prep.cocorobo.cn/:11111/api/user', {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json'
|
|
@@ -975,7 +977,8 @@
|
|
|
}
|
|
|
|
|
|
const registerData = await registerResponse.json();
|
|
|
- alert(`报名成功!您的报名ID: ${registerData.id}`);
|
|
|
+ console.log(registerData);
|
|
|
+ alert(registerData.message);
|
|
|
// document.getElementById('registrationForm').reset();
|
|
|
|
|
|
} catch (error) {
|
|
@@ -985,34 +988,80 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- const params = {
|
|
|
- type: selectedCompetitionId, // 报名类型,1桌游,2智能体
|
|
|
- uploadUrl: "", // 上传文件的URL
|
|
|
- idCard: "", // 选手身份证号拼接
|
|
|
- registrationFormUrl: "", // 报名表上传URL
|
|
|
- user: JSON.stringify([{
|
|
|
- name: "张三",
|
|
|
- gender: "男",
|
|
|
- ethnicity: "汉族",
|
|
|
- birthdate: "1990-01-01",
|
|
|
- email: "zhangsan@example.com",
|
|
|
- idNumber: "110101199001011234",
|
|
|
- group: "A",
|
|
|
- grade: "大一",
|
|
|
- school: "清华大学",
|
|
|
- schoolRegion: "北京",
|
|
|
- }])
|
|
|
- };
|
|
|
-
|
|
|
- // fetch("http://localhost:11111/api/user", {
|
|
|
- // method: "POST",
|
|
|
- // headers: {
|
|
|
- // "Content-Type": "application/json"
|
|
|
- // },
|
|
|
- // body: JSON.stringify(params)
|
|
|
- // }).then(res => res.json()).then(res => {
|
|
|
- // console.log(res)
|
|
|
- // })
|
|
|
+ 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 = fetch("https://prep.cocorobo.cn/:11111/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>
|