const _my = require("../../../__antmove/api/index.js")(my); const wx = _my; // pages/meeting/detail/index.js import { appointmentDateRecordList, meetingRecordDateData } from "../../../utils/api/meeting"; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { StatusBar: app.globalData.StatusBar, //胶囊按钮位置 CustomBar: app.globalData.CustomBar, itemData: {}, type: "", chooseId: 0, subscribeList: [], appointmentList: [], statusItem: '', //会议室已约会议的详情 meetingNum: [],//会议数量列表 }, // 获取日期 getDate() { let num = this.data.itemData.meetingLargestDayNum; let subscribeList = []; for (let i = 0; i < num; i++) { let time = this.getDay(i); let data = { id: i, year: time, month: time.slice(5), num: 0 }; subscribeList.push(data); } this.data.meetingNum.forEach(item => { subscribeList = subscribeList.map(v => { if (item.appointmentDate == v.year) { return { ...v, num: item.hadMeetingTimes } } else { return v } }) }) this.setData({ subscribeList }); }, getDay(day) { var today = new Date(); var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day; today.setTime(targetday_milliseconds); //注意,这行是关键代码 var tYear = today.getFullYear(); var tMonth = today.getMonth(); var tDate = today.getDate(); tMonth = this.doHandleMonth(tMonth + 1); tDate = this.doHandleMonth(tDate); return tYear + "-" + tMonth + "-" + tDate; }, doHandleMonth(month) { var m = month; if (month.toString().length == 1) { m = "0" + month; } return m; }, goBack() { wx.navigateBack({ delta: 1 }); }, goto(e) { let url; let itemData = JSON.stringify(this.data.itemData); let { type, subscribeList, appointmentList, chooseId } = this.data; const length = subscribeList.length; let subscribeYear = subscribeList[chooseId].year; appointmentList = JSON.stringify(appointmentList); app.data.meettingInfo = { itemData, type, endDate: subscribeList[length - 1].year, appointmentList, subscribeYear } switch (e.currentTarget.dataset.id) { case "1": url = "/pages/meeting/subscribe/index"; break; default: break; } wx.navigateTo({ url }); }, goDetail(e) { let item = e.currentTarget.dataset.item; let { itemData } = this.data; item = Object.assign(item, itemData); // item = JSON.stringify(e.currentTarget.dataset.item); app.data.roomContentInfo = item wx.navigateTo({ url: "/pages/meeting/appointmentDetail/index?&type=" + this.data.type }); }, clickDate(e) { let item = e.currentTarget.dataset.item; this.setData({ chooseId: item.id }); this.appointmentDateRecordList(item.year); }, appointmentDateRecordList(year) { let data = { appointmentDate: year, meetingRoomId: this.data.itemData.meetingRoomId }; appointmentDateRecordList(data).then(res => { this.setData({ appointmentList: res.data }); }); }, // 会议预约-获取日期和预约数量 _meetingRecordDateData() { let data = { meetingRoomId: this.data.itemData.meetingRoomId } meetingRecordDateData(data).then(res => { this.setData({ meetingNum: res.data }) this.getDate() this.appointmentDateRecordList(this.data.subscribeList[0].year) }) }, preview(event) { // console.log(event); let currentUrl = event.currentTarget.dataset.src // console.log(currentUrl); wx.previewImage({ current: currentUrl, // 当前显示图片的http链接 urls: currentUrl // 需要预览的图片http链接列表 }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ userInfo: wx.getStorageSync("userInfo") }); if (options.type) { let roomInfo = JSON.parse(JSON.stringify(app.data.roomInfo)); app.data.roomInfo = null; this.setData({ type: options.type, itemData: roomInfo }); } if (options.statusItem) { this.setData({ statusItem: options.statusItem, }) } if (this.data.userInfo && !this.data.userInfo.appointmentAuth && !this.data.userInfo.checkAuth && this.data.userInfo.serivceAuth) { this.setData({ statusItem: 1, }) } this._meetingRecordDateData() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { }, antmoveAction: function () { //执行时动态赋值,请勿删除 } });