123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- // 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() {
- }
- })
|