|
@@ -31,8 +31,13 @@ Page({
|
|
|
markers: [],
|
|
|
|
|
|
//
|
|
|
- start:'',
|
|
|
- end:'',
|
|
|
+ start: '',
|
|
|
+ end: '',
|
|
|
+
|
|
|
+ //
|
|
|
+ show: false,
|
|
|
+ date_start1: '',
|
|
|
+ date_end1:'',
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -88,14 +93,14 @@ Page({
|
|
|
objectId,
|
|
|
daysBetween,
|
|
|
istoday,
|
|
|
- start:Start,
|
|
|
- end:End,
|
|
|
+ start: Start,
|
|
|
+ end: End,
|
|
|
})
|
|
|
console.log('istoday', this.data.istoday);
|
|
|
this.gethomestay()
|
|
|
this.getroom()
|
|
|
this.getpic()
|
|
|
-
|
|
|
+ this.getcurrentdate()
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -336,7 +341,7 @@ Page({
|
|
|
date_start: this.data.start,
|
|
|
date_end: this.data.end,
|
|
|
};
|
|
|
- console.log('info',info);
|
|
|
+ console.log('info', info);
|
|
|
|
|
|
// 将信息转为查询字符串
|
|
|
var queryString = Object.keys(info)
|
|
@@ -350,4 +355,68 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+ //获取今日明日日期
|
|
|
+ getcurrentdate() {
|
|
|
+ const today = new Date();
|
|
|
+ const tomorrow = new Date();
|
|
|
+ tomorrow.setDate(today.getDate() + 1);
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ date_start1: this.formatDate(today),
|
|
|
+ date_end1: this.formatDate(tomorrow),
|
|
|
+ });
|
|
|
+ console.log(this.data.start, this.data.end);
|
|
|
+ },
|
|
|
+ //转换日期
|
|
|
+ formatDate(date) {
|
|
|
+ date = new Date(date);
|
|
|
+ return `${date.getMonth() + 1}月${date.getDate()}日`;
|
|
|
+ },
|
|
|
+ // 计算两个日期之间的天数
|
|
|
+ calculateDaysBetween(startDate, endDate) {
|
|
|
+ const start = new Date(startDate);
|
|
|
+ const end = new Date(endDate);
|
|
|
+ const timeDifference = end - start; // 计算时间差(毫秒)
|
|
|
+ const daysDifference = timeDifference / (1000 * 3600 * 24); // 转换为天数
|
|
|
+ return daysDifference; // 返回天数差
|
|
|
+ },
|
|
|
+ //开日历
|
|
|
+ onDisplay() {
|
|
|
+ this.setData({
|
|
|
+ show: true
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //关日历
|
|
|
+ onClose() {
|
|
|
+ this.setData({
|
|
|
+ show: false
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //选好日期点击完成后
|
|
|
+ onConfirm(event) {
|
|
|
+ const [start, end] = event.detail;
|
|
|
+ const daysBetween = this.calculateDaysBetween(start, end); // 计算天数差
|
|
|
+ this.setData({
|
|
|
+ show: false,
|
|
|
+ start,
|
|
|
+ end,
|
|
|
+ decodedDateStartart: `${this.formatDate(start)} `,
|
|
|
+ decodedDateEnd: `${this.formatDate(end)}`,
|
|
|
+ daysBetween
|
|
|
+ });
|
|
|
+ if (this.data.decodedDateStartart.trim() == this.data.date_start1.trim() && this.data.decodedDateEnd.trim() == this.data.date_end1.trim()) {
|
|
|
+ this.setData({
|
|
|
+ istoday: 'true'
|
|
|
+ })
|
|
|
+ console.log(this.data.istoday);
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ istoday: 'false'
|
|
|
+ })
|
|
|
+ console.log(this.data.istoday);
|
|
|
+ }
|
|
|
+ console.log(`入住日期: ${this.data.decodedDateStartart}, 离店日期: ${this.data.decodedDateEnd}, 天数差: ${daysBetween}天`);
|
|
|
+ },
|
|
|
+
|
|
|
})
|