123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- // 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);
- }
- }
- })
|