优化时间限制
This commit is contained in:
parent
47ed335951
commit
b90ec0c35b
|
|
@ -126,11 +126,13 @@ export default {
|
||||||
console.log('🚀 ~ handleExamination ~ item:', item)
|
console.log('🚀 ~ handleExamination ~ item:', item)
|
||||||
// 获取当前考试限制时间 item.validityDate 2021-09-01~2021-09-30 如果今天不在这个范围内, 不能考试
|
// 获取当前考试限制时间 item.validityDate 2021-09-01~2021-09-30 如果今天不在这个范围内, 不能考试
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
const year = date.getFullYear()
|
const validityDate = item.validityDate.split('~')
|
||||||
const month = date.getMonth() + 1
|
const startDate = new Date(validityDate[0].trim())
|
||||||
const day = date.getDate()
|
const endDate = new Date(validityDate[1].trim())
|
||||||
const today = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`
|
console.log('🚀 ~ 时间 ~ date:', date)
|
||||||
if (today < item.validityDate.split('~')[0] || today > item.validityDate.split('~')[1]) {
|
console.log('🚀 ~ 时间 ~ startDate:', startDate)
|
||||||
|
console.log('🚀 ~ 时间 ~ endDate:', endDate)
|
||||||
|
if (date < startDate || date > endDate) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '当前时间不在考试时间范围内',
|
title: '当前时间不在考试时间范围内',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|
|
||||||
|
|
@ -339,11 +339,10 @@ export default {
|
||||||
toggleTheoryExam(item) {
|
toggleTheoryExam(item) {
|
||||||
console.log('🚀 ~ toggleTheoryExam ~ item:', item, item.examMsg.examEquipment)
|
console.log('🚀 ~ toggleTheoryExam ~ item:', item, item.examMsg.examEquipment)
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
const year = date.getFullYear()
|
const validityDate = item.examMsg.validityDate.split('~')
|
||||||
const month = date.getMonth() + 1
|
const startDate = new Date(validityDate[0].trim())
|
||||||
const day = date.getDate()
|
const endDate = new Date(validityDate[1].trim())
|
||||||
const today = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`
|
if (date < startDate || date > endDate) {
|
||||||
if (today < item.examMsg.validityDate.split('~')[0] || today > item.examMsg.validityDate.split('~')[1]) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '当前时间不在考试时间范围内',
|
title: '当前时间不在考试时间范围内',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue