Update templates/index.html
Browse files- templates/index.html +20 -15
templates/index.html
CHANGED
|
@@ -1090,18 +1090,22 @@ textarea:focus {
|
|
| 1090 |
}
|
| 1091 |
|
| 1092 |
function selectTime(time, element) {
|
| 1093 |
-
|
| 1094 |
-
|
| 1095 |
-
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
| 1099 |
-
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1105 |
|
| 1106 |
function toggleTheme() {
|
| 1107 |
currentTheme = currentTheme === 'light' ? 'dark' : 'light';
|
|
@@ -1145,7 +1149,7 @@ textarea:focus {
|
|
| 1145 |
return { wrapper, content };
|
| 1146 |
}
|
| 1147 |
|
| 1148 |
-
async function submitForm(event) {
|
| 1149 |
event.preventDefault();
|
| 1150 |
|
| 1151 |
const birthDate = flatpickrInstance.selectedDates[0];
|
|
@@ -1154,7 +1158,8 @@ async function submitForm(event) {
|
|
| 1154 |
return;
|
| 1155 |
}
|
| 1156 |
|
| 1157 |
-
|
|
|
|
| 1158 |
alert('请选择出生时辰');
|
| 1159 |
return;
|
| 1160 |
}
|
|
@@ -1166,7 +1171,7 @@ async function submitForm(event) {
|
|
| 1166 |
}
|
| 1167 |
|
| 1168 |
const selectedTime = timeList.find(t => t.value === selectedTimeValue);
|
| 1169 |
-
|
| 1170 |
const requestData = {
|
| 1171 |
birth_info: {
|
| 1172 |
date: birthDate.toLocaleString('zh-CN', {
|
|
|
|
| 1090 |
}
|
| 1091 |
|
| 1092 |
function selectTime(time, element) {
|
| 1093 |
+
// 清除之前的选中状态
|
| 1094 |
+
document.querySelectorAll('.time-option').forEach(opt => {
|
| 1095 |
+
opt.classList.remove('selected');
|
| 1096 |
+
});
|
| 1097 |
+
|
| 1098 |
+
// 设置新的选中状态
|
| 1099 |
+
element.classList.add('selected');
|
| 1100 |
+
|
| 1101 |
+
// 确保值被正确设置为数字类型
|
| 1102 |
+
selectedTimeValue = parseInt(time.value);
|
| 1103 |
+
|
| 1104 |
+
// 更新显示的时间信息并清除提示状态
|
| 1105 |
+
const selectedTimeDisplay = document.getElementById('selectedTime');
|
| 1106 |
+
selectedTimeDisplay.textContent = time.text;
|
| 1107 |
+
selectedTimeDisplay.classList.remove('unselected');
|
| 1108 |
+
}
|
| 1109 |
|
| 1110 |
function toggleTheme() {
|
| 1111 |
currentTheme = currentTheme === 'light' ? 'dark' : 'light';
|
|
|
|
| 1149 |
return { wrapper, content };
|
| 1150 |
}
|
| 1151 |
|
| 1152 |
+
async function submitForm(event) {
|
| 1153 |
event.preventDefault();
|
| 1154 |
|
| 1155 |
const birthDate = flatpickrInstance.selectedDates[0];
|
|
|
|
| 1158 |
return;
|
| 1159 |
}
|
| 1160 |
|
| 1161 |
+
// 检查 selectedTimeValue 是否为数字,包括 0
|
| 1162 |
+
if (selectedTimeValue === null || selectedTimeValue === undefined) {
|
| 1163 |
alert('请选择出生时辰');
|
| 1164 |
return;
|
| 1165 |
}
|
|
|
|
| 1171 |
}
|
| 1172 |
|
| 1173 |
const selectedTime = timeList.find(t => t.value === selectedTimeValue);
|
| 1174 |
+
|
| 1175 |
const requestData = {
|
| 1176 |
birth_info: {
|
| 1177 |
date: birthDate.toLocaleString('zh-CN', {
|