// pages/clock/clock-tongji/list.js import { getCenterInfo, weekSettlement, monthSettlement } from '../../../services/index.js' import { imgServerUrl } from '../../../config/config.js' Page({ /** * 页面的初始数据 */ data: { avatar: wx.getStorageSync('userInfo').avatarUrl, name: wx.getStorageSync('hpMember').realName, imgServerUrl, mouthNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`, mouthLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`, weekNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`, weekLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`, mouthData: {}, weekData: {}, mouth: '', defaultmouth: '', defaultDate: '', week: '本周' }, getMouth(month_type) { monthSettlement({ month_type }).then(data => { this.setData({ mouthData: data.data.currentSettlement }) }) }, getWeek(week_type) { weekSettlement({ week_type }).then(data => { this.setData({ weekData: data.data.currentSettlement }) }) }, mouthNext() { if (this.data.mouth < this.data.defaultmouth) { this.setData({ mouth: this.data.defaultDate.getMonth() + 1, mouthNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`, mouthLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`, }, _ => { this.getMouth(1) }) } }, mouthLast() { if (this.data.mouth === this.data.defaultmouth) { if (this.data.defaultDate.getMonth() - 1 < 0) { this.setData({ mouth: 12, year: this.data.year - 1 }, _ => { this.getMouth(2) }) } else { this.setData({ mouth: this.data.defaultDate.getMonth() }, _ => { this.getMouth(2) }) } this.setData({ mouthNext: `${imgServerUrl}/images/clock/clock-arrow-righr.png`, mouthLast: `${imgServerUrl}/images/clock/clock-arrow-left-disabled.png`, }) } }, weekLast() { if (this.data.week === '本周') { this.setData({ week: '上周', weekNext: `${imgServerUrl}/images/clock/clock-arrow-righr.png`, weekLast: `${imgServerUrl}/images/clock/clock-arrow-left-disabled.png`, }) this.getWeek(2) } }, weekNext() { if (this.data.week === '上周') { this.setData({ week: '本周', weekLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`, weekNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`, }) this.getWeek(1) } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ avatar: wx.getStorageSync('userInfo').avatarUrl, name: wx.getStorageSync('hpMember').realName, defaultDate: new Date(options.date) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { getCenterInfo().then(data => { let { approveStatus } = data.data this.setData({ approveStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) , }) }) this.getMouth(1) this.getWeek(1) const date = this.data.defaultDate let month = date.getMonth() + 1 let year = date.getFullYear() this.setData({ defaultmouth: month, mouth: month, year }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })