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.

120 lines
2.3 KiB

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