<view class="form-group">
<label class="label">使用时间:</label>
<view class="input-container" style="width: 77%;">
<input class="input" name="sysj" value="{{dateValue}}" placeholder="请选择日期" readonly bind:tap="handleCalendar" />
<t-calendar visible="{{visible}}" bind:confirm="handleConfirm" bind:close="onClose" value="{{mm}}" minDate="{{minDate}}"/>
</view>
</view>
Page({
data: {
visible: false, // 控制日历的显示和隐藏
dateValue: '请选择日期', // 存储选中的日期
minDate:1643644800000 ,
mm:new Date().getTime()
},
onLoad() {
// 获取当前日期
const currentDate = new Date();
// 设置当前日期为六个月前
currentDate.setMonth(currentDate.getMonth() - 2);
// 获取六个月前的时间戳(毫秒)
const sixMonthsAgoTimestamp = currentDate.getTime();
this.setData({
minDate: sixMonthsAgoTimestamp
})
}
})