// pages/minePages/bsrl/bsrl.js import getCalendar from "../../../utils/calendar" import { getCalendarListForMonth, getCalendarListForDay } from "../../../apis/smzc" Page({ /** * 页面的初始数据 */ data: { weeks: ["周一", "周二", "周三", "周四", "周五", "周六", "周天"], nowDate: {}, calender: [], selectedDate: {}, tapDate: {}, tabbar: [ "当日办税详情", "当月办税详情" ], tabIndex: 0, dayInfos: [], monthInfos: [] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let that = this that.getNowDate() }, getNowDate() { let that = this let date = new Date() let year = date.getFullYear() let month = date.getMonth() + 1 month = month < 10 ? '0' + month : month let day = date.getDate() day = day let nowDate = `${year}-${month}-01` that.setData({ nowDate: { year: year, month: month, day: day }, calender: getCalendar(nowDate), selectedDate: { year: year, month: month, day: day }, tapDate: {} }) that.getDay() that.getMonth() }, lastMonth() { let that = this let selectedDate = that.data.selectedDate let year = Number(selectedDate.month) > 1 ? selectedDate.year : Number(selectedDate.year) - 1 let month = Number(selectedDate.month) > 1 ? Number(selectedDate.month) - 1 : 12 month = String(month < 10 ? '0' + month : month) let date = `${year}-${month}-01` that.setData({ selectedDate: { year: year, month: month, day: '01' }, calender: getCalendar(date), tapDate: {} }) that.getMonth() }, nextMonth() { let that = this let selectedDate = that.data.selectedDate let year = Number(selectedDate.month) < 12 ? selectedDate.year : Number(selectedDate.year) + 1 let month = Number(selectedDate.month) < 12 ? Number(selectedDate.month) + 1 : 1 month = String(month < 10 ? '0' + month : month) let date = `${year}-${month}-01` that.setData({ selectedDate: { year: year, month: month, day: '01' }, calender: getCalendar(date), tapDate: {} }) that.getMonth() }, tapCalender(e) { let that = this let selectedDate = that.data.selectedDate let item = e.currentTarget.dataset.item that.setData({ tapDate: item }) if (item.month == selectedDate.month) {} else if (item.month < selectedDate.month && item.year <= selectedDate.year) { that.lastMonth() } else { that.nextMonth() } that.getDay() }, tab(e) { let that = this let index = e.currentTarget.dataset.index that.setData({ tabIndex: index }) }, getDay() { let that = this let tapDate = that.data.tapDate let selectedDate = that.data.selectedDate if (tapDate.day) { getCalendarListForDay({ day: `${tapDate.year}-${tapDate.month}-${tapDate.day}` }).then(res => { if (res.code == 200) { that.setData({ dayInfos: res.data }) } else { wx.showToast({ title: res.msg || res.message || "暂无数据", icon: "none", duration: 3000 }) } }) } else if (selectedDate.day) { getCalendarListForDay({ day: `${selectedDate.year}-${selectedDate.month}-${selectedDate.day}` }).then(res => { if (res.code == 200) { that.setData({ dayInfos: res.data }) } else { wx.showToast({ title: res.msg || res.message || "暂无数据", icon: "none", duration: 3000 }) } }) } else { setTimeout(() => { that.getDay() }, 500); } }, getMonth() { let that = this let selectedDate = that.data.selectedDate if (selectedDate.day) { getCalendarListForMonth({ year: `${selectedDate.year}-${selectedDate.month}` }).then(res => { if (res.code == 200) { that.setData({ monthInfos: res.data }) } else { wx.showToast({ title: res.msg || res.message || "暂无数据", icon: "none", duration: 3000 }) } }) } else { setTimeout(() => { that.getMonth() }, 500); } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })