|
| 1 | +<template> |
| 2 | + <view class="calendar-page"> |
| 3 | + <cube-calendar |
| 4 | + wx:ref="calendar" |
| 5 | + height="{{height}}" |
| 6 | + defaultDate="{{defaultDate}}" |
| 7 | + bind:dateChange="dateChange" |
| 8 | + maxRange="{{maxRange}}" |
| 9 | + max="{{max}}" |
| 10 | + min="{{min}}" |
| 11 | + /> |
| 12 | + <view class="base-calendar-selected-date"> |
| 13 | + <view class="date-title">起始时间</view> |
| 14 | + <view class="single-date">年份:{{currentStartDate.year || '暂未选择'}}</view> |
| 15 | + <view class="single-date">月份:{{currentStartDate.month || '暂未选择'}}</view> |
| 16 | + <view class="single-date">天份:{{currentStartDate.day || '暂未选择'}}</view> |
| 17 | + <view class="single-date">时间戳:{{currentStartDate.date || '暂未选择'}}</view> |
| 18 | + </view> |
| 19 | + <view class="base-calendar-selected-date"> |
| 20 | + <view class="date-title">结束时间</view> |
| 21 | + <view class="single-date">年份:{{currentEndDate.year || '暂未选择'}}</view> |
| 22 | + <view class="single-date">月份:{{currentEndDate.month || '暂未选择'}}</view> |
| 23 | + <view class="single-date">天份:{{currentEndDate.day || '暂未选择'}}</view> |
| 24 | + <view class="single-date">时间戳:{{currentEndDate.date || '暂未选择'}}</view> |
| 25 | + </view> |
| 26 | + </view> |
| 27 | +</template> |
| 28 | + |
| 29 | +<script> |
| 30 | +import { createComponent } from '@mpxjs/core' |
| 31 | + |
| 32 | +createComponent({ |
| 33 | + data: { |
| 34 | + min: +new Date(2025, 1, 1), |
| 35 | + max: +new Date(2025, 7, 25), |
| 36 | + height: '270px', |
| 37 | + maxRange: 100, |
| 38 | + defaultDate: [+new Date(2025, 3, 1), +new Date(2025, 3, 2)], |
| 39 | + currentStartDate: {}, |
| 40 | + currentEndDate: {} |
| 41 | + }, |
| 42 | + methods: { |
| 43 | + dateChange(selectDate) { |
| 44 | + this.currentStartDate = selectDate.detail.startDate |
| 45 | + this.currentEndDate = selectDate.detail.endDate |
| 46 | + } |
| 47 | + } |
| 48 | +}) |
| 49 | +</script> |
| 50 | + |
| 51 | +<style lang="stylus"> |
| 52 | +.base-calendar-selected-date |
| 53 | + margin-top: 10px |
| 54 | + padding: 10px |
| 55 | + border-radius: 10px |
| 56 | + background: white |
| 57 | + white-space: break-spaces |
| 58 | +.date-title |
| 59 | + text-align: center |
| 60 | +</style> |
| 61 | + |
| 62 | +<script type="application/json"> |
| 63 | + { |
| 64 | + "usingComponents": { |
| 65 | + "base-container": "../../components/base-container/index.mpx", |
| 66 | + "cube-calendar": "@mpxjs/mpx-cube-ui/src/components/calendar/index", |
| 67 | + "cube-toast": "@mpxjs/mpx-cube-ui/src/components/toast/index", |
| 68 | + "cube-button": "@mpxjs/mpx-cube-ui/src/components/button/index.mpx" |
| 69 | + } |
| 70 | + } |
| 71 | +</script> |
0 commit comments