import todo from '../../components/calendar/plugins/todo' import selectable from '../../components/calendar/plugins/selectable' import solarLunar from '../../components/calendar/plugins/solarLunar/index' import timeRange from '../../components/calendar/plugins/time-range' import week from '../../components/calendar/plugins/week' import holidays from '../../components/calendar/plugins/holidays/index' import plugin from '../../components/calendar/plugins/index' plugin .use(todo) .use(solarLunar) .use(selectable) .use(week) .use(timeRange) .use(holidays) Page({ data: { name: '', phone: '', license_number: '', car_model: '', appoint_date: '', appoint_time: '', exchange_code:'', car_appoint_id:'', user_info_show: false, calendarConfig: { theme: 'elegant', disableMode: { // 禁用某一天之前/之后的所有日期 type: 'before', // [‘before’, 'after'] }, }, }, onLoad: function(t) { this.loadData() console.log(t,66666) getApp().page.onLoad(this, t), t.page_id || (t.page_id = -1), this.setData({ options: t }); }, onShow: function(){ var e = this; getApp().getConfig(function(t) { var a = t.store; a && a.name && -1 == e.data.options.page_id && getApp().core.setNavigationBarTitle({ title: a.name }) }) }, // 填写姓名 bindName:function(e){ console.log(e.detail.value) this.setData({ name: e.detail.value }) console.log('预约') }, // 填写电话 bindPhone:function(e){ console.log(e.detail.value) this.setData({ phone: e.detail.value }) console.log('预约') }, // 填写车牌号 bindLicense:function(e){ console.log(e.detail.value) this.setData({ license_number: e.detail.value }) console.log('预约') }, // 车辆型号 bindModel:function(e){ console.log(e.detail.value) this.setData({ car_model: e.detail.value }) console.log('预约') }, // 兑换码 bindRedemptionCode:function(e){ this.setData({ exchange_code: e.detail.value }) }, // 选中 afterTapDate(e) { console.log('afterTapDate', e.detail) if(e.detail.week == 0){ console.log('week为周日',e.detail.week) wx.showModal({ title: e.detail.date + '日为周末, 周末闭店休息', showCancel: false }) this.setData({ appoint_date: '' }) }else{ this.setData({ appoint_date: `${e.detail.year}-${e.detail.month}-${e.detail.date}` }) } }, // 确定预约 onSubmit:function(){ if(this.data.name == ''){ wx.showToast({ icon: 'none', title: '请填写预约人姓名', }) return } if(this.data.phone == ''){ wx.showToast({ icon: 'none', title: '请填写预约人电话', }) return } if(this.data.license_number == ''){ wx.showToast({ icon: 'none', title: '请填写预约人车牌号', }) return } if(this.data.car_model == ''){ wx.showToast({ icon: 'none', title: '请填写预约人车辆型号', }) return } if(this.data.appoint_time == ''){ wx.showToast({ icon: 'none', title: '请填写预约时间', }) return } if(this.data.appoint_date == ''){ wx.showToast({ icon: 'none', title: '请选择预约日期', }) return } let that = this let e = {} e.name = that.data.name e.phone = that.data.phone e.license_number = that.data.license_number e.car_model = that.data.car_model e.appoint_date = that.data.appoint_date e.exchange_code = that.data.exchange_code e.appoint_time = that.data.appoint_time getApp().request({ url: getApp().api.yuyue.submit, method: "POST", data: e, success: function (res) { console.log(res) wx.showLoading({ title: '提交中', }) if(res.code == 0){ setTimeout(function(){ wx.hideLoading(); wx.redirectTo({ url: '/pages/check-submit/check-submit?data=' + encodeURIComponent(JSON.stringify(res.data)) + '&phone='+that.data.phone, }) },1500) }else{ wx.showToast({ icon: 'none', title: res.msg, }) } }, fail: function(res){ wx.showToast({ icon: 'none', title: res.msg, }) } }) }, formatDate(date) { date = new Date(date); return `${date.getMonth() + 1}/${date.getDate()}`; }, onConfirm(event) { this.setData({ show: false, date: this.formatDate(event.detail), }); }, // bindDateChange: function(e) { // console.log('picker发送选择改变,携带值为', e.detail.value) // this.setData({ // date: e.detail.value // }) // }, bindTimeChange: function(e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ appoint_time: e.detail.value }) }, loadData: function () { var a = this; getApp().core.showLoading({ title: "正在加载", mask: !0 }), getApp().request({ url: getApp().api.share.index, success: function (e) { if (0 == e.code) { if (e.data.share_setting) var t = e.data.share_setting; else t = e.data; getApp().core.setStorageSync(getApp().const.SHARE_SETTING, t), a.setData({ share_setting: t }) a.setData({ user_info_show: false }) }else if (1 == e.code){ a.setData({ user_info_show: true }) } }, complete: function () { getApp().core.hideLoading() } }) }, });