【bug】时间的校验
This commit is contained in:
@@ -3,7 +3,8 @@ import signUpApi from '../../assets/js/http/signUp'
|
||||
import MeetingApi from '../../assets/js/http/meetingApi'
|
||||
import {
|
||||
phoneReg,
|
||||
postcode
|
||||
postcode,
|
||||
compareDate
|
||||
} from '../../utils/validate'
|
||||
Page({
|
||||
/**
|
||||
@@ -245,15 +246,20 @@ Page({
|
||||
})
|
||||
return
|
||||
}
|
||||
// 是否住酒店
|
||||
// if (formData.checkInHotel === '') {
|
||||
// wx.showToast({
|
||||
// title: '请选择是否住酒店',
|
||||
// icon: 'none',
|
||||
// duration: 2000
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// 校验时间
|
||||
if(formData.arrivalTime && formData.departureTime){
|
||||
let flag = compareDate(formData.arrivalTime,formData.departureTime)
|
||||
if(flag){
|
||||
// 抵达时间大于离开时间
|
||||
wx.showToast({
|
||||
title: '抵达时间不能大于离开时间',
|
||||
icon:'none',
|
||||
duration:2000
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
mask:true
|
||||
@@ -378,7 +384,6 @@ Page({
|
||||
this.setData({
|
||||
meetingId:options.meetingId
|
||||
})
|
||||
|
||||
wx.setStorage({
|
||||
key:'meetingId',
|
||||
data:options.meetingId
|
||||
|
||||
@@ -3,7 +3,8 @@ import MeetingApi from "../../assets/js/http/meetingApi"
|
||||
import signUpApi from "../../assets/js/http/signUp"
|
||||
import {
|
||||
phoneReg,
|
||||
postcode
|
||||
postcode,
|
||||
compareDate
|
||||
} from '../../utils/validate'
|
||||
import {
|
||||
baseUrl,
|
||||
@@ -167,8 +168,8 @@ Page({
|
||||
let value = e.detail.value
|
||||
this.setData({
|
||||
needHotel: value,
|
||||
inHotelTime:'请选择入住酒店时间',
|
||||
outHotelTime:'请选择离店时间'
|
||||
inHotelTime: '请选择入住酒店时间',
|
||||
outHotelTime: '请选择离店时间'
|
||||
})
|
||||
|
||||
},
|
||||
@@ -177,7 +178,7 @@ Page({
|
||||
let value = e.detail.value
|
||||
this.setData({
|
||||
needPick: value,
|
||||
arrivalTime:'请选择抵达时间'
|
||||
arrivalTime: '请选择抵达时间'
|
||||
})
|
||||
},
|
||||
// 是否送站
|
||||
@@ -185,7 +186,7 @@ Page({
|
||||
let value = e.detail.value
|
||||
this.setData({
|
||||
needSend: value,
|
||||
departureTime:'请选择离开时间'
|
||||
departureTime: '请选择离开时间'
|
||||
})
|
||||
},
|
||||
// 缴费方式选择
|
||||
@@ -216,14 +217,15 @@ Page({
|
||||
speakerBool: false,
|
||||
cooperatieBool: false,
|
||||
guestBool: false,
|
||||
guestType:''
|
||||
})
|
||||
}
|
||||
},
|
||||
// 是否住酒店 参会人与内部企业 清除抵达时间 离开时间
|
||||
needHotelNot(){
|
||||
needHotelNot() {
|
||||
this.setData({
|
||||
arrivalTime:'请选择抵达时间',
|
||||
departureTime:'请选择离开时间'
|
||||
arrivalTime: '请选择抵达时间',
|
||||
departureTime: '请选择离开时间'
|
||||
})
|
||||
},
|
||||
// 选择参会单位
|
||||
@@ -312,10 +314,10 @@ Page({
|
||||
console.log(validateArr[0].type);
|
||||
this.setData({
|
||||
guestType: validateArr[0].type,
|
||||
haveMeals:'',
|
||||
needHotel:'',
|
||||
needPick:'',
|
||||
needSend:''
|
||||
haveMeals: '',
|
||||
needHotel: '',
|
||||
needPick: '',
|
||||
needSend: ''
|
||||
})
|
||||
switch (validateArr[0].type) {
|
||||
case '1':
|
||||
@@ -635,7 +637,7 @@ Page({
|
||||
|
||||
// 离店时间
|
||||
|
||||
if ((formData.outHotelTime === '' || formData.outHotelTime === null || formData.outHotelTime === undefined ) && this.data.needHotel === '1' && this.data.guestType === '1') {
|
||||
if ((formData.outHotelTime === '' || formData.outHotelTime === null || formData.outHotelTime === undefined) && this.data.needHotel === '1' && this.data.guestType === '1') {
|
||||
wx.showToast({
|
||||
title: '请选择离店时间',
|
||||
icon: 'none',
|
||||
@@ -643,6 +645,18 @@ Page({
|
||||
})
|
||||
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') {
|
||||
@@ -664,7 +678,7 @@ Page({
|
||||
return
|
||||
}
|
||||
// 抵达时间
|
||||
if (this.data.identity === '1' && this.data.needPick === '1' && this.data.guestType !== '4' && (formData.arrivalTime === '' || formData.arrivalTime === null || formData.arrivalTime === undefined )) {
|
||||
if (this.data.identity === '1' && this.data.needPick === '1' && this.data.guestType !== '4' && (formData.arrivalTime === '' || formData.arrivalTime === null || formData.arrivalTime === undefined)) {
|
||||
wx.showToast({
|
||||
title: '请选择抵达时间',
|
||||
icon: 'none',
|
||||
@@ -702,7 +716,7 @@ Page({
|
||||
}
|
||||
|
||||
// 离开时间
|
||||
if (this.data.identity === '1' && this.data.needSend === '1' && this.data.guestType !== '4' && (formData.departureTime === '' || formData.departureTime === null || formData.departureTime === undefined) ) {
|
||||
if (this.data.identity === '1' && this.data.needSend === '1' && this.data.guestType !== '4' && (formData.departureTime === '' || formData.departureTime === null || formData.departureTime === undefined)) {
|
||||
wx.showToast({
|
||||
title: '请选择离开时间',
|
||||
icon: 'none',
|
||||
@@ -710,6 +724,19 @@ Page({
|
||||
})
|
||||
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 === '') {
|
||||
wx.showToast({
|
||||
@@ -729,6 +756,9 @@ Page({
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 会议id
|
||||
if (this.data.selectedMeeting.id) {
|
||||
formData.meetingId = this.data.selectedMeeting.id
|
||||
@@ -794,18 +824,18 @@ Page({
|
||||
}
|
||||
}
|
||||
})
|
||||
}else{
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon:'none',
|
||||
duration:2000
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
wx.showToast({
|
||||
title: err.message,
|
||||
icon:'none',
|
||||
duration:2000
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
@@ -90,3 +90,12 @@ export function money(s) {
|
||||
export function dutyCode(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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user