list.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // pages/clock/clock-tongji/list.js
  2. import {
  3. getCenterInfo,
  4. weekSettlement,
  5. monthSettlement
  6. } from '../../../services/index.js'
  7. import {
  8. imgServerUrl
  9. } from '../../../config/config.js'
  10. Page({
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. avatar: wx.getStorageSync('userInfo').avatarUrl,
  16. imgServerUrl,
  17. mouthNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`,
  18. mouthLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`,
  19. weekNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`,
  20. weekLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`,
  21. mouthData: {},
  22. weekData: {},
  23. mouth: '',
  24. defaultmouth: '',
  25. week: '本周'
  26. },
  27. getMouth(month_type) {
  28. monthSettlement({ month_type }).then(data => {
  29. this.setData({
  30. mouthData: data.data.currentSettlement
  31. })
  32. })
  33. },
  34. getWeek(week_type) {
  35. weekSettlement({ week_type }).then(data => {
  36. this.setData({
  37. weekData: data.data.currentSettlement
  38. })
  39. })
  40. },
  41. mouthNext() {
  42. if (this.data.mouth < this.data.defaultmouth) {
  43. this.setData({
  44. mouth: new Date().getMonth() + 1,
  45. mouthNext: `${imgServerUrl}/images/clock/clock-arrow-righr-disabled.png`,
  46. mouthLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`,
  47. }, _ => {
  48. this.getMouth(1)
  49. })
  50. }
  51. },
  52. mouthLast() {
  53. if (this.data.mouth === this.data.defaultmouth) {
  54. if (new Date().getMonth() - 1 < 0) {
  55. this.setData({
  56. mouth: 12,
  57. year: this.data.year - 1
  58. }, _ => {
  59. this.getMouth(2)
  60. })
  61. } else {
  62. this.setData({
  63. mouth: new Date().getMonth()
  64. }, _ => {
  65. this.getMouth(2)
  66. })
  67. }
  68. this.setData({
  69. mouthNext: `${imgServerUrl}/images/clock/clock-arrow-righr.png`,
  70. mouthLast: `${imgServerUrl}/images/clock/clock-arrow-left-disabled.png`,
  71. })
  72. }
  73. },
  74. weekLast() {
  75. if (this.data.week === '本周') {
  76. this.setData({
  77. week: '上周',
  78. weekNext: `${imgServerUrl}/images/clock/clock-arrow-righr.png`,
  79. weekLast: `${imgServerUrl}/images/clock/clock-arrow-left-disabled.png`,
  80. })
  81. this.getWeek(2)
  82. }
  83. },
  84. weekNext() {
  85. if (this.data.week === '上周') {
  86. this.setData({
  87. week: '本周',
  88. weekLast: `${imgServerUrl}/images/clock/clock-arrow-left.png`,
  89. weekNext: `${imgServerUrl}/images/clock/clock-arrow-right-disabled.png`,
  90. })
  91. this.getWeek(1)
  92. }
  93. },
  94. /**
  95. * 生命周期函数--监听页面加载
  96. */
  97. onLoad: function (options) {
  98. },
  99. /**
  100. * 生命周期函数--监听页面初次渲染完成
  101. */
  102. onReady: function () {
  103. },
  104. /**
  105. * 生命周期函数--监听页面显示
  106. */
  107. onShow: function () {
  108. getCenterInfo().then(data => {
  109. let {
  110. approveStatus
  111. } = data.data
  112. this.setData({
  113. approveStatus, // 认证状态(0:未认证 1:等待认证 2:未通过 3:已认证) ,
  114. })
  115. })
  116. this.getMouth(1)
  117. this.getWeek(1)
  118. const date = new Date()
  119. let month = date.getMonth() + 1
  120. let year = date.getFullYear()
  121. this.setData({
  122. defaultmouth: month,
  123. mouth: month,
  124. year
  125. })
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面卸载
  134. */
  135. onUnload: function () {
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh: function () {
  141. },
  142. /**
  143. * 页面上拉触底事件的处理函数
  144. */
  145. onReachBottom: function () {
  146. },
  147. /**
  148. * 用户点击右上角分享
  149. */
  150. onShareAppMessage: function () {
  151. }
  152. })