|
@@ -26,7 +26,10 @@ Page({
|
|
|
currentWeek: '',
|
|
|
currentYear: '',
|
|
|
appusername: '',
|
|
|
- appuserheadimg: ''
|
|
|
+ appuserheadimg: '',
|
|
|
+ durationOne: false,
|
|
|
+ durationTwo: false,
|
|
|
+ durationThree: false
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -58,6 +61,52 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ // 获取当天可预约的次数
|
|
|
+ getResetNumberFn (data) {
|
|
|
+ var that = this
|
|
|
+ var data = {
|
|
|
+ province: this.data.province,
|
|
|
+ city: this.data.city,
|
|
|
+ county: this.data.county,
|
|
|
+ appointmentDate: data
|
|
|
+ }
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加载中...',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ getResetNumber(data).then(res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ const response = res.data.carDurationConfigs
|
|
|
+ console.log(response)
|
|
|
+ response.forEach(item => {
|
|
|
+ console.log(item);
|
|
|
+ if (item.duration == 1) {
|
|
|
+ that.setData({
|
|
|
+ durationOne: item.isBusy
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (item.duration == 2) {
|
|
|
+ that.setData({
|
|
|
+ durationTwo: item.isBusy
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (item.duration == 3) {
|
|
|
+ that.setData({
|
|
|
+ durationThree: item.isBusy
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(e => {
|
|
|
+ wx.hideLoading()
|
|
|
+ wx.showModal({
|
|
|
+ content: e,
|
|
|
+ confirmColor: '#333',
|
|
|
+ showCancel: false
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
onPullDownRefresh () {
|
|
|
wx.vibrateShort({
|
|
|
type: 'medium'
|
|
@@ -125,7 +174,8 @@ Page({
|
|
|
date: bDate.getDate(),
|
|
|
dateStr: bDate.getFullYear() + '-' + _month + '-' + _day,
|
|
|
disabled: true,
|
|
|
- status: ''
|
|
|
+ status: '',
|
|
|
+ busy: false
|
|
|
})
|
|
|
}
|
|
|
that.setData({
|
|
@@ -136,15 +186,43 @@ Page({
|
|
|
},
|
|
|
setCalendarItem () {
|
|
|
var that = this
|
|
|
+ console.log(this.data.currentWeek, 'that.data.currentWeek');
|
|
|
+ console.log(that.data.weekList, 'that.data.weekList');
|
|
|
var _mapWeekList = that.data.weekList
|
|
|
_mapWeekList.map((item, index) => {
|
|
|
const baseDate = new Date((index - that.data.currentWeek) * 86400000 + that.data.currentTime)
|
|
|
const _month = Number(baseDate.getMonth() + 1) < 10 ? '0' + Number(baseDate.getMonth() + 1) : baseDate.getMonth() + 1
|
|
|
const _year = baseDate.getFullYear()
|
|
|
const _day = Number(baseDate.getDate()) < 10 ? '0' + baseDate.getDate() : baseDate.getDate()
|
|
|
+ const _week = baseDate.getDay()
|
|
|
+ item.week = _week
|
|
|
+ if (_week == 0) {
|
|
|
+ item.weekStr = '周日'
|
|
|
+ item.busy = true
|
|
|
+ }
|
|
|
+ if (_week == 1) {
|
|
|
+ item.weekStr = '周一'
|
|
|
+ }
|
|
|
+ if (_week == 2) {
|
|
|
+ item.weekStr = '周二'
|
|
|
+ }
|
|
|
+ if (_week == 3) {
|
|
|
+ item.weekStr = '周三'
|
|
|
+ }
|
|
|
+ if (_week == 4) {
|
|
|
+ item.weekStr = '周四'
|
|
|
+ }
|
|
|
+ if (_week == 5) {
|
|
|
+ item.weekStr = '周五'
|
|
|
+ }
|
|
|
+ if (_week == 6) {
|
|
|
+ item.weekStr = '周六'
|
|
|
+ item.busy = true
|
|
|
+ }
|
|
|
if (index > that.data.currentWeek) {
|
|
|
if (index == that.data.currentWeek + 1) {
|
|
|
item.date = '约满'
|
|
|
+ item.busy = false
|
|
|
item.disabled = true
|
|
|
that.setData({
|
|
|
curYear: _year,
|
|
@@ -154,10 +232,7 @@ Page({
|
|
|
item.date = baseDate.getDate()
|
|
|
}
|
|
|
if (index == that.data.currentWeek + 2) {
|
|
|
- item.active = true
|
|
|
- if (that.data.currentWeek == 4 || that.data.currentWeek == 5) {
|
|
|
- item.busy = true
|
|
|
- }
|
|
|
+ // item.active = true
|
|
|
that.setData({
|
|
|
choseDate: _year + '-' + _month + '-' + _day
|
|
|
})
|
|
@@ -165,9 +240,11 @@ Page({
|
|
|
item.dateStr = _year + '-' + _month + '-' + _day
|
|
|
} else {
|
|
|
item.disabled = true
|
|
|
+ item.busy = false
|
|
|
item.dateStr = baseDate.getFullYear() + '-' + _month + '-' + _day
|
|
|
if (index == that.data.currentWeek) {
|
|
|
item.date = '约满'
|
|
|
+
|
|
|
} else {
|
|
|
item.date = baseDate.getDate()
|
|
|
}
|
|
@@ -197,34 +274,35 @@ Page({
|
|
|
|
|
|
// 选择日期
|
|
|
handleSelectDate (e) {
|
|
|
- const disabled = e.currentTarget.dataset.disabled
|
|
|
- if (!disabled) {
|
|
|
- const cDate = e.currentTarget.dataset.date
|
|
|
- const index = e.currentTarget.dataset.index
|
|
|
- console.log(cDate, 'cDate', new Date(cDate).getDay(), index);
|
|
|
- const _year = cDate.split('-')[0]
|
|
|
- const _month = cDate.split('-')[1]
|
|
|
- const _weeklist = this.data.weekList
|
|
|
- //_weeklist[index].active = true
|
|
|
- _weeklist.map((item, i) => {
|
|
|
- if (index == i ) {
|
|
|
- item.active = true
|
|
|
- if (new Date(cDate).getDay() == 6 || new Date(cDate).getDay() == 0) {
|
|
|
- item.busy = true
|
|
|
+ if (!this.data.hasAddress) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择地址',
|
|
|
+ icon: 'error',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const disabled = e.currentTarget.dataset.disabled
|
|
|
+ if (!disabled) {
|
|
|
+ const cDate = e.currentTarget.dataset.date
|
|
|
+ const index = e.currentTarget.dataset.index
|
|
|
+ const _year = cDate.split('-')[0]
|
|
|
+ const _month = cDate.split('-')[1]
|
|
|
+ const _weeklist = this.data.weekList
|
|
|
+ _weeklist.map((item, i) => {
|
|
|
+ if (index == i ) {
|
|
|
+ item.active = true
|
|
|
} else {
|
|
|
- item.busy = false
|
|
|
+ item.active = false
|
|
|
}
|
|
|
- } else {
|
|
|
- item.active = false
|
|
|
- item.busy = false
|
|
|
- }
|
|
|
- })
|
|
|
- this.setData({
|
|
|
- curYear: _year,
|
|
|
- curMonth: _month,
|
|
|
- weekList: _weeklist,
|
|
|
- choseDate: cDate
|
|
|
- })
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ curYear: _year,
|
|
|
+ curMonth: _month,
|
|
|
+ weekList: _weeklist,
|
|
|
+ choseDate: cDate
|
|
|
+ })
|
|
|
+ this.getResetNumberFn(cDate)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -279,27 +357,7 @@ Page({
|
|
|
mask: true
|
|
|
})
|
|
|
} else {
|
|
|
- var itt = this
|
|
|
- wx.showLoading({
|
|
|
- title: '预约中...'
|
|
|
- })
|
|
|
- var data = {
|
|
|
- province: this.data.province,
|
|
|
- city: this.data.city,
|
|
|
- county: this.data.county,
|
|
|
- appointmentDate: this.data.choseDate
|
|
|
- }
|
|
|
- getResetNumber(data).then(res => {
|
|
|
- wx.hideLoading()
|
|
|
- itt.submitAppointmentFn()
|
|
|
- }).catch(e => {
|
|
|
- wx.hideLoading()
|
|
|
- wx.showModal({
|
|
|
- content: e,
|
|
|
- confirmColor: '#333',
|
|
|
- showCancel: false
|
|
|
- })
|
|
|
- })
|
|
|
+ this.submitAppointmentFn()
|
|
|
}
|
|
|
},
|
|
|
// 提交预约信息
|
|
@@ -309,6 +367,9 @@ Page({
|
|
|
duration: this.data.timeActive,
|
|
|
addressId: this.data.addressId
|
|
|
}
|
|
|
+ wx.showLoading({
|
|
|
+ title: '预约中...'
|
|
|
+ })
|
|
|
var timer = null
|
|
|
submitAppointment(data).then(res => {
|
|
|
wx.hideLoading()
|