list.js 3.7 KB

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