Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
meihua-island-book
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2023-12-21 14:08:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a49442d7a7ac0cb5cdf658107c09a920916ab7a2
a49442d7
1 parent
bbe26b59
fix
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
6 deletions
src/components/roomCard.vue
src/pages/confirm/index.vue
src/components/roomCard.vue
View file @
a49442d
<!--
* @Date: 2023-12-13 13:42:23
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-12-21 1
3:57:59
* @LastEditTime: 2023-12-21 1
4:07:08
* @FilePath: /meihuaApp/src/components/roomCard.vue
* @Description: 房间详情组件
-->
...
...
@@ -32,6 +32,46 @@
import { ref, defineProps, onMounted, watch } from 'vue'
import Taro from '@tarojs/taro'
/**
* 获取今天和明天日期
*/
const getTodayAndTomorrow = () => {
var today = new Date(); // 获取当前日期
var todayYear = today.getFullYear();
var todayMonth = today.getMonth() + 1; // 月份从0开始,所以要加1
var todayDay = today.getDate();
var tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000); // 获取明天日期
var tomorrowYear = tomorrow.getFullYear();
var tomorrowMonth = tomorrow.getMonth() + 1; // 月份从0开始,所以要加1
var tomorrowDay = tomorrow.getDate();
// 跨年处理
if (tomorrowYear > todayYear) {
tomorrowMonth = '01';
tomorrowDay = '01';
}
// 跨月处理
if (tomorrowMonth > 12) {
tomorrowMonth = '01';
tomorrowYear = todayYear + 1;
}
// 格式化为两位数
todayMonth = todayMonth < 10 ? '0' + todayMonth : todayMonth;
todayDay = todayDay < 10 ? '0' + todayDay : todayDay;
tomorrowMonth = tomorrowMonth < 10 ? '0' + tomorrowMonth : tomorrowMonth;
tomorrowDay = tomorrowDay < 10 ? '0' + tomorrowDay : tomorrowDay;
return {
today: todayYear + '-' + todayMonth + '-' + todayDay,
tomorrow: tomorrowYear + '-' + tomorrowMonth + '-' + tomorrowDay
};
}
const props = defineProps({
data: {
type: Object,
...
...
@@ -46,8 +86,8 @@ const props = defineProps({
},
});
const startDate = ref(
props.calenderInfo.startDate
);
const endDate = ref(
props.calenderInfo.endDate
);
const startDate = ref(
''
);
const endDate = ref(
''
);
watch(
() => props.calenderInfo,
...
...
@@ -61,6 +101,9 @@ watch(
}
);
// 调用方法获取今天和明天的日期
const dates = getTodayAndTomorrow();
const handleTap = () => {
Taro.navigateTo({
url: `../detail/index?id=abc&start_date=${startDate.value}&end_date=${endDate.value}`,
...
...
@@ -68,6 +111,13 @@ const handleTap = () => {
}
onMounted(() => {
if (props.calenderInfo) {
startDate.value = props.calenderInfo.startDate;
endDate.value = props.calenderInfo.endDate;
} else {
startDate.value = dates.today;
endDate.value = dates.tomorrow;
}
// console.warn('选择的日期', props.calenderInfo);
// console.warn('房间详情的属性', props.data);
})
...
...
src/pages/confirm/index.vue
View file @
a49442d
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-12-21 1
2:26:1
3
* @LastEditTime: 2023-12-21 1
4:02:4
3
* @FilePath: /meihuaApp/src/pages/confirm/index.vue
* @Description: 确认订单页面
-->
...
...
@@ -204,13 +204,13 @@ onMounted(() => {
year: check_in[0],
month: check_in[1],
day: check_in[2],
day_of_week:
JSON.parse(start_date_week)
day_of_week:
start_date_week ? JSON.parse(start_date_week) : ''
}
booking_info.value.check_out = {
year: check_out[0],
month: check_out[1],
day: check_out[2],
day_of_week:
JSON.parse(end_date_week)
day_of_week:
end_date_week ? JSON.parse(end_date_week) : ''
}
});
...
...
Please
register
or
login
to post a comment