list.js 4.0 KB

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