时间改成年月日,人数和场次验证
This commit is contained in:
parent
ee188bd4a2
commit
d02c845016
@ -334,17 +334,7 @@
|
|||||||
name: '结束时间',
|
name: '结束时间',
|
||||||
reg: /^.+$/,
|
reg: /^.+$/,
|
||||||
errMsg: '结束时间不能空'
|
errMsg: '结束时间不能空'
|
||||||
},
|
}
|
||||||
num: {
|
|
||||||
name: '申请场次',
|
|
||||||
reg: /^[1-9]\d*$/,
|
|
||||||
errMsg: '申请场次不能空且是正整数'
|
|
||||||
},
|
|
||||||
counter: {
|
|
||||||
name: '申请人数',
|
|
||||||
reg: /^[1-9]\d*$/,
|
|
||||||
errMsg: '申请人数不能空且是正整数'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// userName: '谢雨晴',
|
// userName: '谢雨晴',
|
||||||
// userPhone: "15189809052",
|
// userPhone: "15189809052",
|
||||||
@ -431,8 +421,8 @@
|
|||||||
const year = now.getFullYear();
|
const year = now.getFullYear();
|
||||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||||
|
|
||||||
this.startTime = `${year}-${month}`;
|
this.startTime = `${year}年${month}月`;
|
||||||
this.endTime = `${year}-${month}`;
|
this.endTime = `${year}年${month}月`;
|
||||||
this.startTimePickerValue = this.startTime;
|
this.startTimePickerValue = this.startTime;
|
||||||
this.endTimePickerValue = this.endTime;
|
this.endTimePickerValue = this.endTime;
|
||||||
} else {
|
} else {
|
||||||
@ -441,9 +431,9 @@
|
|||||||
const year = now.getFullYear();
|
const year = now.getFullYear();
|
||||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||||
const day = now.getDate().toString().padStart(2, '0');
|
const day = now.getDate().toString().padStart(2, '0');
|
||||||
this.borrowTimeData = `${year}-${month}-${day} `
|
this.borrowTimeData = `${year}年${month}月${day}日 `
|
||||||
this.startTime = `09:00`;
|
this.startTime = `09时00分`;
|
||||||
this.endTime = `10:00`;
|
this.endTime = `10时00分`;
|
||||||
this.startTimePickerValue = this.startTime;
|
this.startTimePickerValue = this.startTime;
|
||||||
this.endTimePickerValue = this.endTime;
|
this.endTimePickerValue = this.endTime;
|
||||||
}
|
}
|
||||||
@ -579,7 +569,7 @@
|
|||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
|
||||||
this.startTime = `${year}-${month}`;
|
this.startTime = `${year}年${month}月`;
|
||||||
this.startTimePickerValue = this.startTime;
|
this.startTimePickerValue = this.startTime;
|
||||||
} else {
|
} else {
|
||||||
// 普通会议室模式处理完整日期时间
|
// 普通会议室模式处理完整日期时间
|
||||||
@ -599,9 +589,9 @@
|
|||||||
borrowTimeConfirm(e) {
|
borrowTimeConfirm(e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
if (this.pickerType === 1) {
|
if (this.pickerType === 1) {
|
||||||
this.startTime = `${e.value[0]}:${e.value[1]}`
|
this.startTime = `${e.value[0]}时${e.value[1]}分`
|
||||||
} else {
|
} else {
|
||||||
this.endTime = `${e.value[0]}:${e.value[1]}`
|
this.endTime = `${e.value[0]}时${e.value[1]}分`
|
||||||
}
|
}
|
||||||
this.noIsSelfStudy = false
|
this.noIsSelfStudy = false
|
||||||
},
|
},
|
||||||
@ -612,7 +602,7 @@
|
|||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
|
||||||
this.endTime = `${year}-${month}`;
|
this.endTime = `${year}年${month}月`;
|
||||||
this.endTimePickerValue = this.endTime;
|
this.endTimePickerValue = this.endTime;
|
||||||
} else {
|
} else {
|
||||||
// 普通会议室模式处理完整日期时间
|
// 普通会议室模式处理完整日期时间
|
||||||
@ -634,40 +624,9 @@
|
|||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
this.borrowTimeData = `${year}-${month}-${day}`;
|
this.borrowTimeData = `${year}年${month}月${day}日`;
|
||||||
this.borrowTimeShow = false
|
this.borrowTimeShow = false
|
||||||
},
|
},
|
||||||
adjustEndTime() {
|
|
||||||
console.log(this.startTime)
|
|
||||||
const [startH, startM] = this.startTime.split(':').map(Number);
|
|
||||||
let [endH, endM] = this.endTime.split(':').map(Number);
|
|
||||||
|
|
||||||
const startTotal = startH * 60 + startM;
|
|
||||||
let endTotal = endH * 60 + endM;
|
|
||||||
|
|
||||||
if (endTotal <= startTotal) {
|
|
||||||
endTotal = startTotal + 60;
|
|
||||||
endH = Math.floor(endTotal / 60);
|
|
||||||
endM = endTotal % 60;
|
|
||||||
this.endTime = `${endH.toString().padStart(2, '0')}:${endM.toString().padStart(2, '0')}`;
|
|
||||||
this.endTimeValue = `${endH}:${endM}`;
|
|
||||||
this.endTimePickerValue = this.endTime;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
validateTime() {
|
|
||||||
const [startH, startM] = this.startTime.split(':').map(Number);
|
|
||||||
const [endH, endM] = this.endTime.split(':').map(Number);
|
|
||||||
|
|
||||||
const duration = (endH * 60 + endM) - (startH * 60 + startM);
|
|
||||||
if (duration < 30) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '最少预订30分钟',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
this.adjustEndTime();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* 验证对象属性是否为空(Promise版)
|
* 验证对象属性是否为空(Promise版)
|
||||||
* @param {Object} obj - 要验证的对象
|
* @param {Object} obj - 要验证的对象
|
||||||
@ -762,9 +721,9 @@
|
|||||||
userPhone: this.userPhone,
|
userPhone: this.userPhone,
|
||||||
userAddress: this.userAddress,
|
userAddress: this.userAddress,
|
||||||
userCardId: this.userCardId,
|
userCardId: this.userCardId,
|
||||||
startTime: this.isSelfStudy ? this.startTime :
|
startTime: this.isSelfStudy ? this.startTime.replace('年','-').replace('月','') :
|
||||||
`${this.borrowTimeData} ${this.startTime}`,
|
`${this.borrowTimeData.replace('年','-').replace('月','-').replace('日','')} ${this.startTime.replace('时',':').replace('分','')}`,
|
||||||
endTime: this.isSelfStudy ? this.endTime : `${this.borrowTimeData} ${this.endTime}`,
|
endTime: this.isSelfStudy ? this.endTime.replace('年','-').replace('月','') : `${this.borrowTimeData.replace('年','-').replace('月','-').replace('日','')} ${this.endTime.replace('时',':').replace('分','')}`,
|
||||||
counter: this.counter,
|
counter: this.counter,
|
||||||
num: this.num,
|
num: this.num,
|
||||||
// applyType:this.applyType
|
// applyType:this.applyType
|
||||||
@ -789,15 +748,25 @@
|
|||||||
concatName: this.concatName,
|
concatName: this.concatName,
|
||||||
concatPhone: this.concatPhone,
|
concatPhone: this.concatPhone,
|
||||||
companyName: this.companyName,
|
companyName: this.companyName,
|
||||||
startTime: this.isSelfStudy ? this.startTime :
|
startTime: this.isSelfStudy ? this.startTime.replace('年','-').replace('月','') :
|
||||||
`${this.borrowTimeData} ${this.startTime}`,
|
`${this.borrowTimeData.replace('年','-').replace('月','-').replace('日','')} ${this.startTime.replace('时',':').replace('分','')}`,
|
||||||
endTime: this.isSelfStudy ? this.endTime : `${this.borrowTimeData} ${this.endTime}`,
|
endTime: this.isSelfStudy ? this.endTime.replace('年','-').replace('月','') : `${this.borrowTimeData.replace('年','-').replace('月','-').replace('日','')} ${this.endTime.replace('时',':').replace('分','')}`,
|
||||||
counter: this.counter,
|
counter: this.counter,
|
||||||
num: this.num,
|
num: this.num,
|
||||||
stampUrl: this.stampUrl,
|
stampUrl: this.stampUrl,
|
||||||
// applyType:this.applyType
|
// applyType:this.applyType
|
||||||
}
|
}
|
||||||
await this.validateObject(userApplyInfo, this.applyRules)
|
const applyRules=Object.assign(this.applyRules,{num: {
|
||||||
|
name: '申请场次',
|
||||||
|
reg: /^[1-9]\d*$/,
|
||||||
|
errMsg: '申请场次不能空且是正整数'
|
||||||
|
},
|
||||||
|
counter: {
|
||||||
|
name: '申请人数',
|
||||||
|
reg: /^[1-9]\d*$/,
|
||||||
|
errMsg: '申请人数不能空且是正整数'
|
||||||
|
},})
|
||||||
|
await this.validateObject(userApplyInfo, applyRules)
|
||||||
const applyInfo = Object.assign(bookingInfo, userApplyInfo)
|
const applyInfo = Object.assign(bookingInfo, userApplyInfo)
|
||||||
await this.validateBorrowTime(applyInfo)
|
await this.validateBorrowTime(applyInfo)
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user