结婚证判断

This commit is contained in:
weichengwu 2025-11-26 23:55:59 +08:00
parent 86c430eedf
commit fbca24d9af
1 changed files with 409 additions and 357 deletions

View File

@ -96,10 +96,13 @@
<span class="pl-2">{{ formData.registerDate || '-' }}</span> <span class="pl-2">{{ formData.registerDate || '-' }}</span>
</div> </div>
</div> </div>
<div v-if="eligibilityError" class="mt-3 text-sm text-[#E8424D] bg-[#FFF5F5] border border-[#FFD7DF] rounded-lg p-3 leading-6">
{{ eligibilityError }}
</div>
</div> </div>
<!-- 提交按钮 --> <!-- 提交按钮 -->
<button @click="goToIdUpload" :disabled="!formData.marriageNo" <button @click="goToIdUpload" :disabled="isNextDisabled"
class="w-full h-14 bg-gradient-to-r from-[#E8424D]! to-[#FF7A7A]! text-white! rounded-full text-lg font-bold transition-all hover:opacity-90 active:scale-98 disabled:from-[#8a8a8a]! disabled:to-[#8a8a8a]!"> class="w-full h-14 bg-gradient-to-r from-[#E8424D]! to-[#FF7A7A]! text-white! rounded-full text-lg font-bold transition-all hover:opacity-90 active:scale-98 disabled:from-[#8a8a8a]! disabled:to-[#8a8a8a]!">
<div class="text-lg">下一步</div> <div class="text-lg">下一步</div>
</button> </button>
@ -216,7 +219,7 @@
<script setup lang="ts"> <script setup lang="ts">
import apiService from '../../services/apiService' import apiService from '../../services/apiService'
import { ref, onMounted, nextTick } from 'vue' import { ref, onMounted, nextTick, computed, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import QrcodeVue from 'qrcode.vue' import QrcodeVue from 'qrcode.vue'
@ -228,6 +231,7 @@ const ocrUploadId = ref<HTMLInputElement>();
const qrCodeWrapper = ref<HTMLDivElement | null>(null); const qrCodeWrapper = ref<HTMLDivElement | null>(null);
const qrImageSrc = ref(''); const qrImageSrc = ref('');
const router = useRouter(); const router = useRouter();
const eligibilityError = ref('');
const STORAGE_KEY_USER = 'userAs'; const STORAGE_KEY_USER = 'userAs';
const STORAGE_KEY_MARRIAGE = 'marriageOcr'; const STORAGE_KEY_MARRIAGE = 'marriageOcr';
@ -287,6 +291,7 @@ const formData = ref({
qrCode: '', // qrCode: '', //
status: 0, // 0- 1- status: 0, // 0- 1-
}) })
const isNextDisabled = computed(() => !formData.value.marriageNo || !!eligibilityError.value);
const activityInfo = ref<any>({}); // const activityInfo = ref<any>({}); //
onMounted(() => { onMounted(() => {
@ -300,7 +305,7 @@ onMounted(() => {
// activityStartTime: dayjs(response.data.activityStartTime).format('YYYYMMDD'), // activityStartTime: dayjs(response.data.activityStartTime).format('YYYYMMDD'),
// activityEndTime: dayjs(response.data.activityEndTime).format('YYYYMMDD'), // activityEndTime: dayjs(response.data.activityEndTime).format('YYYYMMDD'),
activityStartTime: '2026年1月1日', activityStartTime: '2026年1月1日',
activityEndTime: '12月31日', activityEndTime: '2026年12月31日',
}; };
if (new Date(response.data.activityEndTime) < new Date()) { if (new Date(response.data.activityEndTime) < new Date()) {
@ -329,6 +334,47 @@ onMounted(() => {
}) })
}) })
const pickYear = (value?: string) => {
if (!value) return '';
return value.trim().slice(0, 4);
}
const computeEligibilityError = () => {
if (!formData.value.marriageNo) return '';
if (!formData.value.marriageNo.startsWith('640')) {
return '本活动仅限在宁夏办理结婚登记的新人参与,当前结婚证字号不符合活动要求。';
}
const registerYear = pickYear(formData.value.registerDate);
const startYear = pickYear(activityInfo.value.activityStartTime);
const endYear = pickYear(activityInfo.value.activityEndTime);
if (![startYear, endYear].includes(registerYear)) {
return `您的结婚证登记年份不在活动范围内,暂无法领取。`;
}
return '';
}
watch(
() => [
formData.value.marriageNo,
formData.value.registerDate,
activityInfo.value.activityStartTime,
activityInfo.value.activityEndTime,
],
() => {
const nextReason = computeEligibilityError();
const hasNewReason = nextReason && nextReason !== eligibilityError.value;
eligibilityError.value = nextReason;
if (hasNewReason) {
showDialog({ message: nextReason });
}
},
{ immediate: true }
);
// //
const countdown = ref(0) const countdown = ref(0)
let countdownTimer: number | null = null let countdownTimer: number | null = null
@ -641,6 +687,12 @@ const goToIdUpload = () => {
}); });
return; return;
} }
if (eligibilityError.value) {
showDialog({
message: eligibilityError.value,
});
return;
}
persistMarriageInfo(); persistMarriageInfo();
router.push('/idcard'); router.push('/idcard');
} }