关于uni-app里使用uni-calendar的弹出模式时时间不可选择的处理

关于uni-app里使用uni-calendar的弹出模式时时间不可选择的处理,还设置了日历可选择的有限时间和选择时的文字标注

关于uni-app里使用uni-calendar的弹出模式时时间不可选择的处理

最近在开发智慧公寓移动端时时需要有使用日历选择订房日期的功能,uni-calendar里有插入模式和弹出模式,我需要弹出模式的样式,但是将insert为false时弹出的日历不能选择,要选择必须改为true,后面我终于想到将日历改为插入模式放入弹窗中,通过点击时间出现弹窗和日历,我还设置了日历可选择的有限时间和选择时的文字标注

设置点击位置

写好点击出现弹窗的样式并将日历放到uni-popup中弹出

		<view class="select-time" @click="openCalendar">
			<view class="select-time-one">
			  <text class="select-list">周四入住</text>
			  <text class="select-list-time">07月21日</text>
			</view>
			<view class="select-center">
				<view class="select-line1"></view>
				<view class="select-circle">1晚</view>
				<view class="select-line2"></view>
			</view>
			<view class="select-time-one">
			  <text class="select-list">周五离店</text>
			  <text class="select-list-time">07月22日</text>
			</view>
		</view>
		<uni-popup ref="popup_picker" :mask-click="true">
			<view class=popup_bg_picker>
			<uni-calendar :selected="info.selected" class="uni-calendar--hook" :clear-date="true" :date="info.date" :insert="info.insert" :lunar="info.lunar" :startDate="info.startDate"
			:endDate="info.endDate" :range="info.range" @change="change"/>
			</view>
		</uni-popup>

样式为
在这里插入图片描述
点击事件为,并给前后点击日期写好标注

// 日期选择器弹窗开启
			openCalendar() {
				this.$refs.popup_picker.open()
			},
			change(e) {
				console.log('1change 返回:', e)
				// 模拟动态打卡
				if (this.info.selected.length > 5) return
				this.info.selected.push({
					date: e.range.before,
					info: '到店'
				})
				this.info.selected.push({
					date: e.range.after,
					info: '离店'
				})
			},

可打开日历
在这里插入图片描述
需要给日历里选择的日期固定为7天内并标注选择文字
//data中定义

return {
				showCalendar: false,
				info: {
					lunar: true,
					range: true,
					insert: true,
					selected: [],
					startDate:'',
					date:'',
					endDate:''
				},
		}

设置选择的开始时间结束时间和当前默认时间

onReady() {
			this.$nextTick(() => {
				this.showCalendar = true
			})
			// TODO 模拟请求异步同步数据
			setTimeout(() => {
				this.info.date = getDate(new Date()).fullDate
				this.info.startDate = getDate(new Date()).fullDate
				this.info.endDate =  getDate(new Date(),6).fullDate
			}, 2000)
	}

这样就有一个完整点击出现日历样式了,并可标注好提示文字
在这里插入图片描述

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值