|
@@ -1,4 +1,5 @@
|
|
|
// pages/appointment/appointment.js
|
|
|
+const app = getApp()
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -6,9 +7,30 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
hasAddress: false,
|
|
|
+ address: '',
|
|
|
calendarcolor: '#45A6B5',
|
|
|
- timeActive: '9',
|
|
|
- dialogsShow: true
|
|
|
+ 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;
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -17,7 +39,35 @@ Page({
|
|
|
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
|
|
|
+ })
|
|
|
+ },
|
|
|
/**
|
|
|
* 选择地址
|
|
|
*/
|
|
@@ -26,12 +76,20 @@ Page({
|
|
|
url: '/pages/address/address?form=appointment&back=1',
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow() {
|
|
|
-
|
|
|
+ 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);
|
|
@@ -47,5 +105,32 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
// 去充值
|
|
|
- handleCharge () {}
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|