You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.5 KiB

const {
httpUtil,
formatTime
} = require("../../../utils/util");
// pages/index/calendar/calendar.js
Page({
/**
* 页面的初始数据
*/
data: {
min_date: new Date().setDate(1),
max_date: new Date().setMonth((new Date().getMonth() + 6), 0),
today_:new Date().getTime(),
show_today:[]
},
select_date:function(event){
console.log(event)
let day_ = event.detail.getDate()
let month_ = event.detail.getMonth()+1
let year_ = event.detail.getFullYear()
let show_today=[]
for(let item of this.data.show_list){
if(day_==item.day&&month_==item.month&&year_==item.year){
show_today.push(item)
}
}
this.setData({show_today})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
var city_id=options.city_id
let cur_date = new Date()
let cur_year = cur_date.getFullYear()
let cur_month = cur_date.getMonth() + 1
httpUtil("/api/v1/lately-show" + "?city_id="+city_id , "get").then(res => {
let show_list = res.show_list
let show_today=[]
for(let item of show_list){
if(cur_date.getDate()==item.day&&cur_month==item.month&&cur_year==item.year){
show_today.push(item)
}
}
that.setData({
show_list,show_today,
formatter: function (day) {
const month = day.date.getMonth() + 1;
const date = day.date.getDate();
const year = day.date.getFullYear();
for (let item of show_list) {
if (month == item.month) {
if (date == item.day) {
day.bottomInfo = " "
}
}
}
if( day.bottomInfo != " "){
day.type = 'disabled'
}
if (date === cur_date.getDate()&&month===cur_month&&year==cur_year) {
day.text = '今天';
}
return day;
}
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})