index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. // pages/meeting/detail/index.js
  2. import {
  3. appointmentDateRecordList
  4. } from '../../../utils/api/meeting'
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. StatusBar: app.globalData.StatusBar, //胶囊按钮位置
  12. CustomBar: app.globalData.CustomBar,
  13. itemData: {},
  14. type: '',
  15. chooseId: 0,
  16. subscribeList: [],
  17. appointmentList: [],
  18. },
  19. // 获取日期
  20. getDate() {
  21. let num = this.data.itemData.meetingLargestDayNum
  22. let subscribeList = []
  23. for (let i = 0; i < num; i++) {
  24. let time = this.getDay(i)
  25. let data = {
  26. id: i,
  27. year: time,
  28. month: time.slice(5)
  29. }
  30. subscribeList.push(data)
  31. }
  32. this.setData({
  33. subscribeList
  34. })
  35. },
  36. getDay(day) {
  37. var today = new Date();
  38. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  39. today.setTime(targetday_milliseconds); //注意,这行是关键代码
  40. var tYear = today.getFullYear();
  41. var tMonth = today.getMonth();
  42. var tDate = today.getDate();
  43. tMonth = this.doHandleMonth(tMonth + 1);
  44. tDate = this.doHandleMonth(tDate);
  45. return tYear + "-" + tMonth + "-" + tDate;
  46. },
  47. doHandleMonth(month) {
  48. var m = month;
  49. if (month.toString().length == 1) {
  50. m = "0" + month;
  51. }
  52. return m;
  53. },
  54. goBack() {
  55. wx.navigateBack({
  56. delta: 1,
  57. })
  58. },
  59. goto(e) {
  60. let url
  61. let itemData = JSON.stringify(this.data.itemData)
  62. let {
  63. type,
  64. subscribeList,
  65. appointmentList,
  66. chooseId
  67. } = this.data
  68. const length = subscribeList.length;
  69. let subscribeYear = subscribeList[chooseId].year
  70. appointmentList = JSON.stringify(appointmentList)
  71. switch (e.currentTarget.dataset.id) {
  72. case '1':
  73. url = '/pages/meeting/subscribe/index?itemData=' + itemData + '&type=' + type + '&endDate=' + subscribeList[length - 1].year + '&appointmentList=' + appointmentList + '&subscribeYear=' + subscribeYear
  74. break;
  75. default:
  76. break;
  77. }
  78. wx.navigateTo({
  79. url
  80. })
  81. },
  82. goDetail(e) {
  83. let item = e.currentTarget.dataset.item
  84. let {
  85. itemData
  86. } = this.data
  87. item = Object.assign(item, itemData)
  88. item = JSON.stringify(e.currentTarget.dataset.item)
  89. wx.navigateTo({
  90. url: '/pages/meeting/appointmentDetail/index?item=' + item + '&type=' + this.data.type
  91. })
  92. },
  93. clickDate(e) {
  94. let item = e.currentTarget.dataset.item
  95. this.setData({
  96. chooseId: item.id
  97. })
  98. this.appointmentDateRecordList(item.year)
  99. },
  100. // 本会议室预约的会议列表
  101. appointmentDateRecordList(year) {
  102. let data = {
  103. appointmentDate: year,
  104. meetingRoomId: this.data.itemData.meetingRoomId
  105. }
  106. appointmentDateRecordList(data).then(res => {
  107. this.setData({
  108. appointmentList: res.data
  109. })
  110. })
  111. },
  112. preview(event) {
  113. let currentUrl = event.currentTarget.dataset.src
  114. wx.previewImage({
  115. current: currentUrl, // 当前显示图片的http链接
  116. urls: this.data.itemData.imgList // 需要预览的图片http链接列表
  117. })
  118. },
  119. /**
  120. * 生命周期函数--监听页面加载
  121. */
  122. onLoad(options) {
  123. this.setData({
  124. userInfo: wx.getStorageSync('userInfo'),
  125. })
  126. if (options.type) {
  127. this.setData({
  128. type: options.type,
  129. itemData: JSON.parse(options.item)
  130. })
  131. }
  132. this.getDate()
  133. this.appointmentDateRecordList(this.data.subscribeList[0].year)
  134. },
  135. /**
  136. * 生命周期函数--监听页面初次渲染完成
  137. */
  138. onReady() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面显示
  142. */
  143. onShow() {
  144. },
  145. /**
  146. * 生命周期函数--监听页面隐藏
  147. */
  148. onHide() {
  149. },
  150. /**
  151. * 生命周期函数--监听页面卸载
  152. */
  153. onUnload() {
  154. },
  155. /**
  156. * 页面相关事件处理函数--监听用户下拉动作
  157. */
  158. onPullDownRefresh() {
  159. },
  160. /**
  161. * 页面上拉触底事件的处理函数
  162. */
  163. onReachBottom() {
  164. },
  165. /**
  166. * 用户点击右上角分享
  167. */
  168. onShareAppMessage() {
  169. }
  170. })