优化时间限制
This commit is contained in:
parent
99ab169c2d
commit
9c6f47ee89
|
|
@ -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'
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Reference in New Issue