date.vue 919 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <view class="container">
  3. <wd-calendar-view v-model="timeValue" custom-class="customClass" @change="handleChange" />
  4. </view>
  5. </template>
  6. <script setup>
  7. import { ref, onMounted } from 'vue'
  8. import dayjs from 'dayjs'
  9. // 当前日期
  10. const timeValue = ref(0)
  11. onMounted(() => {
  12. const bus_date = uni.getStorageSync('bus_date')
  13. if (bus_date) {
  14. timeValue.value = dayjs(bus_date).valueOf()
  15. } else {
  16. timeValue.value = Date.now()
  17. }
  18. })
  19. // 选中日期的回调
  20. function handleChange({ value }) {
  21. // console.log(value)
  22. const date = dayjs(value).format('YYYY-MM-DD')
  23. uni.setStorageSync('bus_date', date)
  24. uni.reLaunch({
  25. url: `/pages/home/home`
  26. })
  27. }
  28. </script>
  29. <style lang="scss" scoped>
  30. .container {
  31. height: 100vh;
  32. :deep(.customClass .wd-month-panel__container) {
  33. height: 100vh !important;
  34. }
  35. :deep(.customClass .is-selected .wd-month__day-text) {
  36. background-color: #ff8205;
  37. }
  38. }
  39. </style>