95 lines
2.3 KiB
Vue
95 lines
2.3 KiB
Vue
<template>
|
|
<view class="page-content">
|
|
<nut-calendar title="选择想要的日期" :show-sub-title="false" :poppable="false" :default-value="date"
|
|
:start-date="startDate" :end-date="endDate" @choose="onChoose" @select="onSelect"></nut-calendar>
|
|
</view>
|
|
</template>
|
|
<script setup>
|
|
import {
|
|
onMounted,
|
|
reactive,
|
|
ref
|
|
} from 'vue';
|
|
import {
|
|
onLoad,
|
|
onShow
|
|
} from '@dcloudio/uni-app';
|
|
import {
|
|
navigateTo,
|
|
} from '@/utils/helper';
|
|
import {
|
|
fetchOrderList,
|
|
} from '@/api/index';
|
|
|
|
|
|
|
|
// 获取上月的第一天
|
|
const getLastMonthFirstDay = () => {
|
|
const date = new Date();
|
|
date.setMonth(date.getMonth() - 1); // 设置为上个月
|
|
date.setDate(1); // 设置为本月的第一天
|
|
return formatDate(date);
|
|
};
|
|
|
|
// 获取本月的最后一天
|
|
const getCurrentMonthLastDay = () => {
|
|
const date = new Date();
|
|
date.setMonth(date.getMonth() + 1); // 设置为下个月
|
|
date.setDate(0); // 设置为下个月的最后一天
|
|
return formatDate(date);
|
|
};
|
|
|
|
// 格式化日期为 Y-m-d 格式
|
|
const formatDate = (date) => {
|
|
const year = date.getFullYear();
|
|
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 获取月份并确保是两位数
|
|
const day = date.getDate().toString().padStart(2, '0'); // 获取日期并确保是两位数
|
|
return `${year}-${month}-${day}`;
|
|
};
|
|
|
|
// 获取上月的第一天和本月的最后一天
|
|
const startDate = ref(getLastMonthFirstDay());
|
|
const endDate = ref(getCurrentMonthLastDay());
|
|
// const date = ref(formatDate(new Date())); // 获取今天的日期并格式化为 Y-m-d 格式
|
|
const date = ref('');
|
|
|
|
const onChoose = (e) => {
|
|
console.log('onChoose', e);
|
|
}
|
|
const onSelect = (e) => {
|
|
console.log('onSelect', e);
|
|
uni.navigateTo({
|
|
url: `/pages/data/list?date=${e[3]}`
|
|
})
|
|
}
|
|
|
|
|
|
|
|
onLoad((options) => {
|
|
// current_tab_idx.value = parseInt(options.tab)
|
|
})
|
|
|
|
/**
|
|
* 页面显示生命周期钩子
|
|
* 每次页面显示时都会执行
|
|
*/
|
|
onShow(() => {
|
|
// 获取配置
|
|
// getConfig()
|
|
// if (paging.value) {
|
|
// // paging.value.pageNo = 1;
|
|
// paging.value.refresh();
|
|
// // paging.value.refreshToPage(1)
|
|
// // paging.value.reload();
|
|
// }
|
|
})
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
.page-content {
|
|
min-height: 100vh;
|
|
background-color: #f2f3f5;
|
|
}
|
|
</style> |