【bug】时间的校验

This commit is contained in:
fengachen
2021-11-04 11:21:25 +08:00
parent 3a87b256d4
commit 33bb8f954f
3 changed files with 75 additions and 31 deletions
+16 -11
View File
@@ -3,7 +3,8 @@ import signUpApi from '../../assets/js/http/signUp'
import MeetingApi from '../../assets/js/http/meetingApi' import MeetingApi from '../../assets/js/http/meetingApi'
import { import {
phoneReg, phoneReg,
postcode postcode,
compareDate
} from '../../utils/validate' } from '../../utils/validate'
Page({ Page({
/** /**
@@ -245,15 +246,20 @@ Page({
}) })
return return
} }
// 是否住酒店 // 校验时间
// if (formData.checkInHotel === '') { if(formData.arrivalTime && formData.departureTime){
// wx.showToast({ let flag = compareDate(formData.arrivalTime,formData.departureTime)
// title: '请选择是否住酒店', if(flag){
// icon: 'none', // 抵达时间大于离开时间
// duration: 2000 wx.showToast({
// }) title: '抵达时间不能大于离开时间',
// return icon:'none',
// } duration:2000
})
return
}
}
wx.showLoading({ wx.showLoading({
title: '加载中', title: '加载中',
mask:true mask:true
@@ -378,7 +384,6 @@ Page({
this.setData({ this.setData({
meetingId:options.meetingId meetingId:options.meetingId
}) })
wx.setStorage({ wx.setStorage({
key:'meetingId', key:'meetingId',
data:options.meetingId data:options.meetingId
+31 -1
View File
@@ -3,7 +3,8 @@ import MeetingApi from "../../assets/js/http/meetingApi"
import signUpApi from "../../assets/js/http/signUp" import signUpApi from "../../assets/js/http/signUp"
import { import {
phoneReg, phoneReg,
postcode postcode,
compareDate
} from '../../utils/validate' } from '../../utils/validate'
import { import {
baseUrl, baseUrl,
@@ -216,6 +217,7 @@ Page({
speakerBool: false, speakerBool: false,
cooperatieBool: false, cooperatieBool: false,
guestBool: false, guestBool: false,
guestType:''
}) })
} }
}, },
@@ -643,6 +645,18 @@ Page({
}) })
return return
} }
if (formData.inHotelTime && formData.outHotelTime) {
let flag = compareDate(formData.inHotelTime, formData.outHotelTime)
if (flag) {
// 入住酒店时间大于离店时间
wx.showToast({
title: '入住酒店时间不能大于离店时间',
icon: 'none',
duration: 2000
})
return
}
}
// 房型 // 房型
if (formData.roomLayout === '' && this.data.needHotel === '1' && this.data.guestType === '1') { if (formData.roomLayout === '' && this.data.needHotel === '1' && this.data.guestType === '1') {
@@ -710,6 +724,19 @@ Page({
}) })
return return
} }
// 校验时间
if (formData.arrivalTime && formData.departureTime) {
let flag = compareDate(formData.arrivalTime, formData.departureTime)
if (flag) {
// 抵达时间大于离开时间
wx.showToast({
title: '抵达时间不能大于离开时间',
icon: 'none',
duration: 2000
})
return
}
}
// 离开站 // 离开站
if (this.data.identity === '1' && this.data.needSend === '1' && this.data.guestType !== '4' && formData.departureStation === '') { if (this.data.identity === '1' && this.data.needSend === '1' && this.data.guestType !== '4' && formData.departureStation === '') {
wx.showToast({ wx.showToast({
@@ -729,6 +756,9 @@ Page({
}) })
return return
} }
// 会议id // 会议id
if (this.data.selectedMeeting.id) { if (this.data.selectedMeeting.id) {
formData.meetingId = this.data.selectedMeeting.id formData.meetingId = this.data.selectedMeeting.id
+9
View File
@@ -90,3 +90,12 @@ export function money(s) {
export function dutyCode(s) { export function dutyCode(s) {
return /^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/.test(s) return /^([0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}|[1-9]\d{14})$/.test(s)
} }
export function compareDate(date1, date2) {
let Date1 = new Date(date1);
let Date2 = new Date(date2);
if (Date1.getTime() > Date2.getTime()) {
return true
} else {
return false
}
}