优化时间限制

This commit is contained in:
binbin_pan 2024-12-17 19:16:49 +08:00
parent 99ab169c2d
commit 9c6f47ee89
2 changed files with 14 additions and 10 deletions

View File

@ -126,11 +126,13 @@ export default {
console.log('🚀 ~ handleExamination ~ item:', item)
// item.validityDate 2021-09-01~2021-09-30 ,
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const today = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`
if (today < item.validityDate.split('~')[0] || today > item.validityDate.split('~')[1]) {
const validityDate = item.validityDate.split('~')
const startDate = new Date(validityDate[0].trim())
const endDate = new Date(validityDate[1].trim())
console.log('🚀 ~ 时间 ~ date:', date)
console.log('🚀 ~ 时间 ~ startDate:', startDate)
console.log('🚀 ~ 时间 ~ endDate:', endDate)
if (date < startDate || date > endDate) {
uni.showToast({
title: '当前时间不在考试时间范围内',
icon: 'none'

View File

@ -339,11 +339,13 @@ export default {
toggleTheoryExam(item) {
console.log('🚀 ~ toggleTheoryExam ~ item:', item, item.examMsg.examEquipment)
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const today = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`
if (today < item.examMsg.validityDate.split('~')[0] || today > item.examMsg.validityDate.split('~')[1]) {
const validityDate = item.examMsg.validityDate.split('~')
const startDate = new Date(validityDate[0].trim())
const endDate = new Date(validityDate[1].trim())
console.log('🚀 ~ 时间 ~ date:', date)
console.log('🚀 ~ 时间 ~ startDate:', startDate)
console.log('🚀 ~ 时间 ~ endDate:', endDate)
if (date < startDate || date > endDate) {
uni.showToast({
title: '当前时间不在考试时间范围内',
icon: 'none'