城市会客厅预约模式更改
This commit is contained in:
parent
554c35e9c5
commit
6f1b01847f
@ -106,7 +106,29 @@
|
||||
<u-icon name="clock" size="30" color="#2979ff"></u-icon>
|
||||
<text class="section-title">借用时间</text>
|
||||
</view>
|
||||
<view class="time-picker">
|
||||
<view class="time-picker" v-if="!isSelfStudy">
|
||||
<view class="time-selector" @click="borrowTimeShow = true">
|
||||
<text class="time-label">日期</text>
|
||||
<view class="time-display">{{ borrowTimeData }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="time-picker" v-if="!isSelfStudy">
|
||||
<view class="time-selector" @click="noIsSelfStudy = true;pickerType=1">
|
||||
<text class="time-label">开始</text>
|
||||
<view class="time-display">
|
||||
{{ startTime }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="time-separator">—</view>
|
||||
<view class="time-selector" @click="noIsSelfStudy = true;pickerType=2">
|
||||
<text class="time-label">结束</text>
|
||||
<view class="time-display">
|
||||
{{ endTime }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="time-picker" v-if="isSelfStudy">
|
||||
<view class="time-selector" @click="showStartTimePicker = true">
|
||||
<text class="time-label">开始</text>
|
||||
<view class="time-display">
|
||||
@ -180,22 +202,19 @@
|
||||
@confirm="handleDateConfirm" @close="showCalendar = false" :mask-close-able="true"></u-calendar>
|
||||
|
||||
<!-- 时间选择器 -->
|
||||
<u-datetime-picker :show="showStartTimePicker"
|
||||
<u-picker :show="noIsSelfStudy" :columns="startTimeColumns" @confirm="borrowTimeConfirm"
|
||||
@cancel="noIsSelfStudy=false"></u-picker>
|
||||
<u-datetime-picker :show="borrowTimeShow" v-model="borrowTime" mode="date" :min-date="Date.now()"
|
||||
@confirm="handleborrowTimeConfirm" @cancel="borrowTimeShow = false"></u-datetime-picker>
|
||||
<!-- <u-datetime-picker :show="showStartTimePicker"
|
||||
v-model="startTimePickerValue"
|
||||
:min-date="Date.now()"
|
||||
:mode="mode"
|
||||
@confirm="handleStartTimeConfirm"
|
||||
@cancel="showStartTimePicker = false"
|
||||
ref="startTimePicker"></u-datetime-picker>
|
||||
|
||||
<u-datetime-picker
|
||||
:show="showEndTimePicker"
|
||||
v-model="endTimePickerValue"
|
||||
:min-date="Date.now()"
|
||||
:mode="mode"
|
||||
@confirm="handleEndTimeConfirm"
|
||||
@cancel="showEndTimePicker = false"
|
||||
ref="endTimePicker">
|
||||
ref="startTimePicker"></u-datetime-picker> -->
|
||||
<u-datetime-picker :show="showEndTimePicker" v-model="endTimePickerValue" :min-date="Date.now()" :mode="mode"
|
||||
@confirm="handleEndTimeConfirm" @cancel="showEndTimePicker = false" ref="endTimePicker">
|
||||
</u-datetime-picker>
|
||||
<u-picker :show="showApplyType" :columns="applyTypeColumns" @confirm="applyConfirm"
|
||||
@cancel="showApplyType=false"></u-picker>
|
||||
@ -256,21 +275,76 @@
|
||||
if (endHours >= 24) endHours = 0;
|
||||
|
||||
return {
|
||||
noIsSelfStudy:false,
|
||||
pickerType: 1,
|
||||
borrowTimeData: '',
|
||||
borrowTimeShow: false,
|
||||
borrowTime: Number(new Date()),
|
||||
companyName: '',
|
||||
startTimeColumns: [
|
||||
['08', '09', '10', '11', '13', '14', '15', '16', '17'],
|
||||
['00', '30']
|
||||
],
|
||||
readShow: false,
|
||||
hasReaded: true,
|
||||
signUrl: '',
|
||||
signShow: false,
|
||||
applyRules: {
|
||||
userPhone: '申请人手机号',
|
||||
userName: '申请人姓名',
|
||||
userCardId: '申请人身份证号',
|
||||
userAddress: '申请人地址',
|
||||
concatName: '负责人姓名',
|
||||
concatPhone: '负责人电话',
|
||||
companyName: '公司名称',
|
||||
startTime: '开始时间',
|
||||
endTime: '结束时间'
|
||||
userPhone: {
|
||||
name: '申请人手机号',
|
||||
reg: /^1[3-9]\d{9}$/,
|
||||
errMsg: '请输入正确的手机号码格式'
|
||||
},
|
||||
userName: {
|
||||
name: '申请人姓名',
|
||||
reg: /^.+$/,
|
||||
errMsg: '申请人姓名不能为空'
|
||||
},
|
||||
userCardId: {
|
||||
name: '申请人身份证号',
|
||||
reg: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
|
||||
errMsg: '身份证格式不正确'
|
||||
},
|
||||
userAddress: {
|
||||
name: '申请人地址',
|
||||
reg: /^.+$/,
|
||||
errMsg: '申请人地址不能为空'
|
||||
},
|
||||
concatName: {
|
||||
name: '负责人姓名',
|
||||
reg: /^.+$/,
|
||||
errMsg: '负责人姓名不能为空'
|
||||
},
|
||||
concatPhone: {
|
||||
name: '负责人电话',
|
||||
reg: /^1[3-9]\d{9}$/,
|
||||
errMsg: '请输入正确的手机号码格式'
|
||||
},
|
||||
companyName: {
|
||||
name: '公司名称',
|
||||
reg: /^.+$/,
|
||||
errMsg: '公司名称不能为空'
|
||||
},
|
||||
startTime: {
|
||||
name: '开始时间',
|
||||
reg: /^.+$/,
|
||||
errMsg: '开始时间不能为空'
|
||||
},
|
||||
endTime: {
|
||||
name: '结束时间',
|
||||
reg: /^.+$/,
|
||||
errMsg: '结束时间不能空'
|
||||
},
|
||||
counter: {
|
||||
name: '申请场次',
|
||||
reg: /^[1-9]\d*$/,
|
||||
errMsg: '申请场次不能空且是正整数'
|
||||
},
|
||||
num: {
|
||||
name: '申请人数',
|
||||
reg: /^[1-9]\d*$/,
|
||||
errMsg: '申请人数不能空且是正整数'
|
||||
},
|
||||
},
|
||||
// userName: '谢雨晴',
|
||||
// userPhone: "15189809052",
|
||||
@ -296,7 +370,7 @@
|
||||
detail: {},
|
||||
signatureShow: false,
|
||||
isSelfStudy: true, //dateTime,yearmonth
|
||||
mode: 'datetime',
|
||||
mode: 'date',
|
||||
precision: null,
|
||||
concatPhone: '',
|
||||
reason: '',
|
||||
@ -374,9 +448,9 @@
|
||||
const year = now.getFullYear();
|
||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||
const day = now.getDate().toString().padStart(2, '0');
|
||||
|
||||
this.startTime = `${year}-${month}-${day} 09:00`;
|
||||
this.endTime = `${year}-${month}-${day} 10:00`;
|
||||
this.borrowTimeData = `${year}-${month}-${day} `
|
||||
this.startTime = `09:00`;
|
||||
this.endTime = `10:00`;
|
||||
this.startTimePickerValue = this.startTime;
|
||||
this.endTimePickerValue = this.endTime;
|
||||
}
|
||||
@ -408,6 +482,16 @@
|
||||
} else {
|
||||
return '个人申请'
|
||||
}
|
||||
},
|
||||
borrowMinDate() {
|
||||
// 今年1月1日 00:00:00 的时间戳
|
||||
const year = new Date().getFullYear();
|
||||
return new Date(year, 0, 1).getTime();
|
||||
},
|
||||
borrowMaxDate() {
|
||||
// 明年12月31日 23:59:59 的时间戳
|
||||
const year = new Date().getFullYear() + 1;
|
||||
return new Date(year, 11, 31, 23, 59, 59).getTime();
|
||||
}
|
||||
},
|
||||
|
||||
@ -519,7 +603,15 @@
|
||||
|
||||
this.showStartTimePicker = false;
|
||||
},
|
||||
|
||||
borrowTimeConfirm(e) {
|
||||
console.log(e)
|
||||
if (this.pickerType === 1) {
|
||||
this.startTime = `${e.value[0]}:${e.value[1]}`
|
||||
} else {
|
||||
this.endTime = `${e.value[0]}:${e.value[1]}`
|
||||
}
|
||||
this.noIsSelfStudy=false
|
||||
},
|
||||
handleEndTimeConfirm(e) {
|
||||
if (this.isSelfStudy) {
|
||||
// 自习室模式处理年月
|
||||
@ -544,7 +636,14 @@
|
||||
|
||||
this.showEndTimePicker = false;
|
||||
},
|
||||
|
||||
handleborrowTimeConfirm(e) {
|
||||
const date = new Date(e.value);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
this.borrowTimeData = `${year}-${month}-${day}`;
|
||||
this.borrowTimeShow = false
|
||||
},
|
||||
adjustEndTime() {
|
||||
console.log(this.startTime)
|
||||
const [startH, startM] = this.startTime.split(':').map(Number);
|
||||
@ -579,44 +678,54 @@
|
||||
/**
|
||||
* 验证对象属性是否为空(Promise版)
|
||||
* @param {Object} obj - 要验证的对象
|
||||
* @param {Object} applyRules - 验证规则对象
|
||||
* @param {Object} rules - 验证规则对象 (每个 rule.reg 应为 RegExp 对象)
|
||||
* @returns {Promise} 返回Promise,resolve通过验证,reject失败信息
|
||||
*/
|
||||
validateObject(obj, applyRules = {}) {
|
||||
validateObject(obj, rules = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 参数校验
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return reject(new Error('参数必须是一个对象'));
|
||||
if (!obj || typeof obj !== 'object' || obj === null) {
|
||||
return reject(new Error('第一个参数必须是一个非空对象'));
|
||||
}
|
||||
if (!rules || typeof rules !== 'object') {
|
||||
return reject(new Error('第二个参数(验证规则)必须是一个对象'));
|
||||
}
|
||||
|
||||
const keys = Object.keys(obj);
|
||||
let firstInvalidKey = null;
|
||||
console.log(keys);
|
||||
// 遍历检查每个属性
|
||||
for (const item of keys) {
|
||||
console.log(item)
|
||||
const value = obj[item];
|
||||
console.log(value);
|
||||
// 检查空值且该属性在验证规则中
|
||||
if ((value === '' || value === null) && applyRules.hasOwnProperty(item)) {
|
||||
firstInvalidKey = item;
|
||||
break;
|
||||
// 建议:只检查规则中定义的字段,而不是所有 obj 的 key
|
||||
// 这样更可控,避免验证不存在的规则
|
||||
for (const field of keys) {
|
||||
const rule = rules[field];
|
||||
if (!rule) {
|
||||
continue;
|
||||
}
|
||||
const errMsg = rule.errMsg
|
||||
const value = obj[field]; // 获取该字段的值
|
||||
// 检查该字段是否有规则定义
|
||||
if (!rule || !rule.reg || !rule.name) {
|
||||
console.warn(`验证规则 ${field} 不完整`);
|
||||
continue; // 跳过不完整的规则
|
||||
}
|
||||
// 确保 rule.reg 是一个 RegExp 对象
|
||||
if (!(rule.reg instanceof RegExp)) {
|
||||
reject(new Error(`${rule.name} 的验证规则不是有效的正则表达式`));
|
||||
return;
|
||||
}
|
||||
// 执行验证
|
||||
// 注意:这里也应处理 undefined 或 null 的情况
|
||||
const stringValue = value == null ? '' : String(value); // 转为字符串并处理 null/undefined
|
||||
if (!rule.reg.test(stringValue)) {
|
||||
return reject(new Error(errMsg)); // 找到第一个错误就立即 reject
|
||||
}
|
||||
}
|
||||
console.log(firstInvalidKey)
|
||||
if (firstInvalidKey) {
|
||||
// 返回具体的错误信息
|
||||
const errorMsg = `${applyRules[firstInvalidKey]}不能为空`;
|
||||
reject(new Error(errorMsg));
|
||||
} else {
|
||||
// 如果循环完成,说明所有验证都通过了
|
||||
resolve('所有属性验证通过');
|
||||
}
|
||||
});
|
||||
},
|
||||
async handleBook() {
|
||||
try {
|
||||
this.readShow = false
|
||||
console.log(this.applyType);
|
||||
// console.log(this.applyType);
|
||||
let bookingInfo = {
|
||||
roomId: this.Id,
|
||||
applyType: this.applyType,
|
||||
@ -630,11 +739,11 @@
|
||||
userPhone: this.userPhone,
|
||||
userAddress: this.userAddress,
|
||||
userCardId: this.userCardId,
|
||||
startTime: this.startTime,
|
||||
endTime: this.endTime,
|
||||
startTime: this.isSelfStudy?this.startTime:`${this.borrowTimeData} ${this.startTime}`,
|
||||
endTime: this.isSelfStudy?this.endTime:`${this.borrowTimeData} ${this.endTime}`,
|
||||
counter: this.counter,
|
||||
num: this.num,
|
||||
applyType:this.applyType
|
||||
// applyType:this.applyType
|
||||
}
|
||||
await this.validateObject(userApplyInfo, this.applyRules)
|
||||
const applyInfo = Object.assign(bookingInfo, userApplyInfo)
|
||||
@ -654,12 +763,12 @@
|
||||
concatName: this.concatName,
|
||||
concatPhone: this.concatPhone,
|
||||
companyName: this.companyName,
|
||||
startTime: this.startTime,
|
||||
endTime: this.endTime,
|
||||
startTime: this.isSelfStudy?this.startTime:`${this.borrowTimeData} ${this.startTime}`,
|
||||
endTime: this.isSelfStudy?this.endTime:`${this.borrowTimeData} ${this.endTime}`,
|
||||
counter: this.counter,
|
||||
num: this.num,
|
||||
stampUrl: this.stampUrl,
|
||||
applyType:this.applyType
|
||||
// applyType:this.applyType
|
||||
}
|
||||
await this.validateObject(userApplyInfo, this.applyRules)
|
||||
const app = getApp()
|
||||
@ -862,7 +971,8 @@
|
||||
|
||||
}
|
||||
|
||||
.upload-item, .upload-btn {
|
||||
.upload-item,
|
||||
.upload-btn {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
margin: 5rpx;
|
||||
@ -874,7 +984,8 @@
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
|
||||
image, video {
|
||||
image,
|
||||
video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@
|
||||
}
|
||||
|
||||
// 如果是自习室,先弹出提示确认框
|
||||
if (item.roomType == 2 ) {
|
||||
if (item.roomType == 2&&item.num!==4 ) {
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '自习室预约时间按月为单位,单次预约最长两个月,请确认是否继续?',
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// export const BASE_URL = 'http://10.10.1.6:8071';
|
||||
// export const IMAGE_BASE_URL = `http://10.10.1.6:8071`;
|
||||
export const BASE_URL = 'https://jinshan.nantong.info';
|
||||
export const IMAGE_BASE_URL = `https://jinshan.nantong.info`;
|
||||
export const BASE_URL = 'http://10.10.1.6:8071';
|
||||
export const IMAGE_BASE_URL = `http://10.10.1.6:8071`;
|
||||
// export const BASE_URL = 'https://jinshan.nantong.info';
|
||||
// export const IMAGE_BASE_URL = `https://jinshan.nantong.info`;
|
||||
export const WS_BASE_URL = `wss://jinshan.nantong.info`;
|
||||
// export const WS_BASE_URL = 'ws://10.10.1.6:8071';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user