城市会客厅预约模式更改

This commit is contained in:
Leo_Ding 2025-09-15 18:52:36 +08:00
parent 554c35e9c5
commit 6f1b01847f
3 changed files with 328 additions and 217 deletions

View File

@ -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">
@ -145,7 +167,7 @@
<u--input placeholder="请输入申请理由" border="null" v-model="reason"></u--input>
</view>
</view>
<!-- <view class="date-section" v-show="applyName=='个人申请'">
<!-- <view class="date-section" v-show="applyName=='个人申请'">
<view class="section-header">
<u-icon name="plus-circle" size="38" color="#2979ff"></u-icon>
<text class="section-title">签字</text>
@ -168,7 +190,7 @@
<!-- 上传照片/视频 - 完全重写的上传组件 -->
<gx-upload @upload-success="handleUploadSuccess" />
</view>
<view >
<view>
<u-button type="primary" shape="circle" @click="handleBook()">立即预订</u-button>
</view>
</view>
@ -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: '',
readShow:false,
hasReaded:true,
signUrl:'',
signShow:false,
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: '',
@ -319,7 +393,7 @@
// 使
startTimePickerValue: `${year}-${month}-${day}`,
endTimePickerValue: ``,
applyInfo:{},
applyInfo: {},
//
// selectedDate: `${year}-${month}-${day}`,
// minDate: `${year}-${month}-${day}`,
@ -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;
}
@ -402,12 +476,22 @@
return `${month}${day}${weekday}`;
}
},
applyName(){
if(this.applyType===1){
applyName() {
if (this.applyType === 1) {
return '单位申请'
}else{
} else {
return '个人申请'
}
},
borrowMinDate() {
// 11 00:00:00
const year = new Date().getFullYear();
return new Date(year, 0, 1).getTime();
},
borrowMaxDate() {
// 1231 23:59:59
const year = new Date().getFullYear() + 1;
return new Date(year, 11, 31, 23, 59, 59).getTime();
}
},
@ -415,8 +499,8 @@
this.getDetail();
},
methods: {
readChange(flag){
this.hasReaded=flag
readChange(flag) {
this.hasReaded = flag
},
showApplyTypeClick() {
@ -443,7 +527,7 @@
this.detail = {
...res.data
};
this.applyType=res.data.roomType
this.applyType = res.data.roomType
console.log(this.applyType)
} catch (err) {
console.error('获取详情失败:', err);
@ -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} 返回Promiseresolve通过验证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);
this.readShow = false
// 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)
@ -642,29 +751,29 @@
const app = getApp()
app.globalData.applyInfo = applyInfo
this.applyInfo = applyInfo
this.readShow=true
this.readShow = true
}
//
if (this.applyType === 1) {
if (!this.stampUrl) return uni.showToast({
title: '请上传印章',
icon:'none'
icon: 'none'
})
const userApplyInfo = {
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()
app.globalData.applyInfo = Object.assign(bookingInfo, userApplyInfo)
this.readShow=true
this.readShow = true
}
} catch (error) {
uni.showToast({
@ -674,8 +783,8 @@
}
},
async postApply(){
this.readShow=false
async postApply() {
this.readShow = false
uni.navigateTo({
url: `/pages/sign/sign?isSelfStudy=${this.isSelfStudy}`
})
@ -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%;
}

View File

@ -299,7 +299,7 @@
}
//
if (item.roomType == 2 ) {
if (item.roomType == 2&&item.num!==4 ) {
uni.showModal({
title: '温馨提示',
content: '自习室预约时间按月为单位,单次预约最长两个月,请确认是否继续?',

View File

@ -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';