// pages/appointment/appointment.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { hasAddress: false, address: '', calendarcolor: '#45A6B5', timeActive: '0', dialogsShow: false, appointmentSuccess: false, newDate: '', curYear: '-', curMonth: '-', maxDate: '', defaultDate: '', formatter(day) { const time = day.date.getTime(); const cDate = new Date() const cyear = cDate.getFullYear() const cmonth = cDate.getMonth() + 1; const cdate = cDate.getDate(); const str = cyear + '-' + cmonth + '-' + cdate if (time == new Date(str).getTime() || time == new Date(str).getTime() - 86400000) { day.text = '约满' day.type = 'disabled' day.className = 'calendar-all-full' } return day; } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面显示 */ onShow() { if (app.globalData.navigateBackParams.address ) { this.setData({ hasAddress: true, address: app.globalData.navigateBackParams.address }) } this.handleDate() }, // 处理日期 handleDate () { const date = new Date() const time = date.getTime() const year = date.getFullYear() const month = date.getMonth() + 1 const day = date.getDate() const str = year + '-' + month + '-' + day const _maxDate= 2592000000 + time const _defaultDate = new Date(str).getTime() + 86400000 this.setData({ curYear: year, curMonth: month, maxDate: _maxDate, defaultDate: _defaultDate }) }, /** * 选择地址 */ handleChoseAddress() { wx.navigateTo({ url: '/pages/address/address?form=appointment&back=1', }) }, handleChangeAddress () { if (!this.data.appointmentSuccess) { wx.navigateTo({ url: '/pages/address/address?form=appointment&back=1', }) } }, handleSelect (val) { var selectMonth = new Date(val.detail).getMonth() + 1 var selectYear = new Date(val.detail).getFullYear() this.setData({ curYear: selectYear, curMonth: selectMonth }) }, handleTime (e) { console.log(e); var timeActiveIndex = e.currentTarget.dataset.time this.setData({ timeActive: timeActiveIndex }) }, // 激活卡片 handleActiveCard () { wx.navigateTo({ url: '/pages/scan/scan?form=appointment', }) }, // 去充值 handleCharge () {}, // 确定 handleConfirm () { if (!this.data.hasAddress) { wx.showToast({ title: '请选择地址', icon: 'error', mask: true }) } else { var itt = this wx.showLoading({ title: '预约中...' }) setTimeout(() => { wx.hideLoading({ success: (res) => { wx.showToast({ title: '预约成功', }) itt.setData({ appointmentSuccess: true }) } }) }, 1200); } } })