index.js 5.3 KB

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