bsrl.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // pages/minePages/bsrl/bsrl.js
  2. import getCalendar from "../../../utils/calendar"
  3. import {
  4. getCalendarListForMonth,
  5. getCalendarListForDay
  6. } from "../../../apis/smzc"
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. weeks: ["周一", "周二", "周三", "周四", "周五", "周六", "周天"],
  13. nowDate: {},
  14. calender: [],
  15. selectedDate: {},
  16. tapDate: {},
  17. tabbar: [
  18. "当日办税详情",
  19. "当月办税详情"
  20. ],
  21. tabIndex: 0,
  22. dayInfos: [],
  23. monthInfos: []
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad(options) {
  29. let that = this
  30. that.getNowDate()
  31. },
  32. getNowDate() {
  33. let that = this
  34. let date = new Date()
  35. let year = date.getFullYear()
  36. let month = date.getMonth() + 1
  37. month = month < 10 ? '0' + month : month
  38. let day = date.getDate()
  39. day = day
  40. let nowDate = `${year}-${month}-01`
  41. that.setData({
  42. nowDate: {
  43. year: year,
  44. month: month,
  45. day: day
  46. },
  47. calender: getCalendar(nowDate),
  48. selectedDate: {
  49. year: year,
  50. month: month,
  51. day: day
  52. },
  53. tapDate: {}
  54. })
  55. that.getDay()
  56. that.getMonth()
  57. },
  58. lastMonth() {
  59. let that = this
  60. let selectedDate = that.data.selectedDate
  61. let year = Number(selectedDate.month) > 1 ? selectedDate.year : Number(selectedDate.year) - 1
  62. let month = Number(selectedDate.month) > 1 ? Number(selectedDate.month) - 1 : 12
  63. month = String(month < 10 ? '0' + month : month)
  64. let date = `${year}-${month}-01`
  65. that.setData({
  66. selectedDate: {
  67. year: year,
  68. month: month,
  69. day: '01'
  70. },
  71. calender: getCalendar(date),
  72. tapDate: {}
  73. })
  74. that.getMonth()
  75. },
  76. nextMonth() {
  77. let that = this
  78. let selectedDate = that.data.selectedDate
  79. let year = Number(selectedDate.month) < 12 ? selectedDate.year : Number(selectedDate.year) + 1
  80. let month = Number(selectedDate.month) < 12 ? Number(selectedDate.month) + 1 : 1
  81. month = String(month < 10 ? '0' + month : month)
  82. let date = `${year}-${month}-01`
  83. that.setData({
  84. selectedDate: {
  85. year: year,
  86. month: month,
  87. day: '01'
  88. },
  89. calender: getCalendar(date),
  90. tapDate: {}
  91. })
  92. that.getMonth()
  93. },
  94. tapCalender(e) {
  95. let that = this
  96. let selectedDate = that.data.selectedDate
  97. let item = e.currentTarget.dataset.item
  98. that.setData({
  99. tapDate: item
  100. })
  101. if (item.month == selectedDate.month) {} else if (item.month < selectedDate.month && item.year <= selectedDate.year) {
  102. that.lastMonth()
  103. } else {
  104. that.nextMonth()
  105. }
  106. that.getDay()
  107. },
  108. tab(e) {
  109. let that = this
  110. let index = e.currentTarget.dataset.index
  111. that.setData({
  112. tabIndex: index
  113. })
  114. },
  115. getDay() {
  116. let that = this
  117. let tapDate = that.data.tapDate
  118. let selectedDate = that.data.selectedDate
  119. if (tapDate.day) {
  120. getCalendarListForDay({
  121. day: `${tapDate.year}-${tapDate.month}-${tapDate.day}`
  122. }).then(res => {
  123. if (res.code == 200) {
  124. that.setData({
  125. dayInfos: res.data
  126. })
  127. } else {
  128. wx.showToast({
  129. title: res.msg || res.message || "暂无数据",
  130. icon: "none",
  131. duration: 3000
  132. })
  133. }
  134. })
  135. } else if (selectedDate.day) {
  136. getCalendarListForDay({
  137. day: `${selectedDate.year}-${selectedDate.month}-${selectedDate.day}`
  138. }).then(res => {
  139. if (res.code == 200) {
  140. that.setData({
  141. dayInfos: res.data
  142. })
  143. } else {
  144. wx.showToast({
  145. title: res.msg || res.message || "暂无数据",
  146. icon: "none",
  147. duration: 3000
  148. })
  149. }
  150. })
  151. } else {
  152. setTimeout(() => {
  153. that.getDay()
  154. }, 500);
  155. }
  156. },
  157. getMonth() {
  158. let that = this
  159. let selectedDate = that.data.selectedDate
  160. if (selectedDate.day) {
  161. getCalendarListForMonth({
  162. year: `${selectedDate.year}-${selectedDate.month}`
  163. }).then(res => {
  164. if (res.code == 200) {
  165. that.setData({
  166. monthInfos: res.data
  167. })
  168. } else {
  169. wx.showToast({
  170. title: res.msg || res.message || "暂无数据",
  171. icon: "none",
  172. duration: 3000
  173. })
  174. }
  175. })
  176. } else {
  177. setTimeout(() => {
  178. that.getMonth()
  179. }, 500);
  180. }
  181. },
  182. /**
  183. * 生命周期函数--监听页面初次渲染完成
  184. */
  185. onReady() {
  186. },
  187. /**
  188. * 生命周期函数--监听页面显示
  189. */
  190. onShow() {
  191. },
  192. /**
  193. * 生命周期函数--监听页面隐藏
  194. */
  195. onHide() {
  196. },
  197. /**
  198. * 生命周期函数--监听页面卸载
  199. */
  200. onUnload() {
  201. },
  202. /**
  203. * 页面相关事件处理函数--监听用户下拉动作
  204. */
  205. onPullDownRefresh() {
  206. },
  207. /**
  208. * 页面上拉触底事件的处理函数
  209. */
  210. onReachBottom() {
  211. },
  212. /**
  213. * 用户点击右上角分享
  214. */
  215. onShareAppMessage() {
  216. }
  217. })