<template> <dm-pop-view ref='popView' title="选择时段" :isShowConfirm="true" :maskTapHide='maskTapHide' @confirm="confirmAction"> <view class="content"> <uni-calendar :insert="true" :lunar="true" :range = "true" :startDate = "afterDate" :end-date="nowDate" @change="change" /> </view> </dm-pop-view> </template> <script> import dmPopView from './dmPopView.vue' import uniCalendar from '../uni-calendar/uni-calendar.vue' import moment from '../../static/moment.min.js' export default { props: { maskTapHide: { type: Boolean, default: true }, dataList: Array, }, data() { return { nowDate:'', afterDate:'', startDate: '', endDate: '' } }, created() { // this.nowDate = moment('2020-08-20').day(5).format("YYYY-MM-DD"); // this.afterDate = moment('2020-08-20').day(-5).format('YYYY-MM-DD'); // // console.log("日期1", this.nowDate, this.afterDate); }, mounted() { // 控制只能选择之前90天 // this.nowDate = moment('2020-08-20').day(5).format("YYYY-MM-DD"); // this.afterDate = moment('2020-08-20').day(-5).format('YYYY-MM-DD'); // // console.log("日期2", this.nowDate, this.afterDate); }, methods: { show() { this.$refs.popView.show() }, confirmAction() { if(this.startDate=="" || this.endDate==""){ return uni.showToast({ icon:'none', title:'请选择时间范围' }); } const param = { startDate:this.startDate, endDate:this.endDate } this.$emit('confirmSelDate',param) }, change(e) { // console.log(e); this.startDate = e.range.before; this.endDate = e.range.after; } }, components: { dmPopView, uniCalendar } } </script> <style scoped lang="scss"> .content { width: 100%; height: 776rpx; font-family: Verdana; padding-bottom: 100rpx; .list-content { margin-top: 20rpx; border-radius: 20rpx; background-color: #FFFFFF; margin-left: 20rpx; width: 670rpx; display: flex; flex-direction: column; padding: 30rpx 20rpx; .list-title { color: #333333; font-size: 28rpx; font-weight: bold; } .list-content-detail { margin-top: 14rpx; color: #333333; font-size: 24rpx; line-height: 46rpx; } } } </style>