From 066c0cbdfeef58058789cd52106ce7933eda7051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=BF=94=E5=AE=87-=E6=97=85=E7=AE=A1=E5=AE=B6?= <153298343@qq.com> Date: Thu, 26 May 2022 15:24:35 +0800 Subject: [PATCH] up --- .../uview-ui/components/u-calendar/month.vue | 2 +- pages/activity/book.vue | 4 +- pages/index/index.vue | 96 +++++++++++------ pages/park/book.vue | 24 +++-- pages/visit/book.vue | 100 +++++++++++------- 5 files changed, 141 insertions(+), 85 deletions(-) diff --git a/node_modules/uview-ui/components/u-calendar/month.vue b/node_modules/uview-ui/components/u-calendar/month.vue index c20937f..b168872 100644 --- a/node_modules/uview-ui/components/u-calendar/month.vue +++ b/node_modules/uview-ui/components/u-calendar/month.vue @@ -281,7 +281,7 @@ methods: { init() { // 初始化默认选中 - this.$emit('monthSelected', this.selected) + //this.$emit('monthSelected', this.selected) this.$nextTick(() => { // 这里需要另一个延时,因为获取宽度后,会进行月份数据渲染,只有渲染完成之后,才有真正的高度 // 因为nvue下,$nextTick并不是100%可靠的 diff --git a/pages/activity/book.vue b/pages/activity/book.vue index 066995a..ee8db5c 100644 --- a/pages/activity/book.vue +++ b/pages/activity/book.vue @@ -80,13 +80,13 @@ - 添加观众 + 添加参与人 - 批量导入观众 + 批量导入参与人 diff --git a/pages/index/index.vue b/pages/index/index.vue index c058504..270f961 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -75,13 +75,16 @@ + :class="{'book-box-row-timeitem-on':item.checked,'timeitem-none':item.remain_count==0}" + :key="index" @click="handleSelectTime(index)"> {{item.start_time+'-'+item.end_time}} - {{item.remain_count}}张 + + {{item.remain_count}}张 + + 售罄 @@ -195,8 +198,7 @@ this.showCalendar = false; }, handleSelectDate(e) { - console.log(e) - if (e.length != 0 && (e[0] != this.currentDate.date)) { + if (e.length != 0) { this.load3Day(e[0]); this.showCalendar = false; } @@ -242,26 +244,24 @@ m.checked = false; } cdate.checked = true; - let i = 0; - for (var m of cdate.rules) { - m.checked = false; - m.checked = i == 0 - if (m.checked) { - this.currentTime = m; - } - i++; - } + + this.loadDefaultTime(cdate.rules); this.currentDate = cdate; this.listDatePrice = list; this.$forceUpdate(); }, handleSelectTime(index) { + var mod = this.currentDate.rules[index]; + if (mod.remain_count == 0) { + this.util.toast("该时段已售罄"); + return false + } for (var m of this.currentDate.rules) { m.checked = false; } - this.currentDate.rules[index].checked = true; - this.currentTime = this.currentDate.rules[index]; + mod.checked = true; + this.currentTime = mod; this.$forceUpdate(); }, openActivity() { @@ -317,6 +317,15 @@ this.showBook = false; }, tobook(type) { + + if (this.util.isNull(this.currentDate.date)) { + this.util.toast("请选择预约的日期"); + return false; + } + if (this.util.isNull(this.currentTime.id)) { + this.util.toast("请选择预约的时段"); + return false; + } uni.navigateTo({ url: "/pages/visit/book?from=" + type + "¤tDate=" + JSON.stringify(this.currentDate) + "¤tTime=" + JSON.stringify(this.currentTime) @@ -378,26 +387,47 @@ m.week = "后天"; } else { m.week = week; - } - - if (m.date == selectDate ) { - m.checked = true; - that.currentDate = m; - that.currentIndex = i; - let idx = 0; - for (var mod of m.rules) { - mod.checked = false; - mod.checked = idx == 0; - if (mod.checked) { - that.currentTime = mod; - } - idx++; + } + + if (m.date == selectDate) { + if (m.is_open == 1) { + m.checked = true; + that.currentDate = m; + that.currentIndex = i; + that.loadDefaultTime(m.rules); + } else { + + uni.showToast({ + icon: "none", + title: selectDate + "不可以预约", + complete() { + setTimeout(function() { + that.load3Day(that.$moment(selectDate).add('days', 1) + .format("yyyy-MM-DD")) + }, 2000) + } + }, 2000) } - } + } i++; } }) }, + loadDefaultTime(rules) { + var that = this; + that.currentTime = {}; + let isDefault = false; + for (var mod of rules) { + mod.checked = false; + + if (!isDefault && mod.remain_count > 0) { + isDefault = true; + mod.checked = true; + that.currentTime = mod; + } + } + + }, loadCalendar(sdate, edate, cb) { var that = this; this.util.request({ @@ -422,7 +452,9 @@ @import url("@/static/css/bookbox.css"); - + .timeitem-none { + color: #ccc; + } .content { diff --git a/pages/park/book.vue b/pages/park/book.vue index d7b4b3d..1e0b363 100644 --- a/pages/park/book.vue +++ b/pages/park/book.vue @@ -67,7 +67,10 @@ - 请认真阅读、知悉并遵守《实训基地预约停车须知》 + + 活动时间:{{item.activity.start_time}} + 报名数量:{{item.total}} + @@ -101,7 +104,9 @@ checkUser: false, car_type: 1, type: "1", - car_park_id: 0 + car_park_id: 0, + activity_order_id: "", + visit_order_id: "" }, listOrder: [], listActivtyOrder: [], @@ -148,17 +153,19 @@ index].time this.form.time = this.$moment(this.listOrder[index].date + " " + this.listOrder[ index].time.split("-")[0]).format("YYYY-MM-DD hh:mm:ss"); - this.orderid = this.listOrder[index].id; + this.form.visit_order_id = this.orderid = this.listOrder[index].id; + } else { - this.listActivtyOrder[index].checked = false - this.selectInfo = this.$moment(this.listActivtyOrder[index].date).format("MM月DD日") + " " + this - .listActivtyOrder[index].time - this.orderid = this.listActivtyOrder[index].id; + this.listActivtyOrder[index].checked = true + this.selectInfo = this.$moment(this.listActivtyOrder[index].activity.start_time).format("MM月DD日 hh:mm") + + this.form.time = this.$moment(this.listActivtyOrder[index].activity.start_time).format("YYYY-MM-DD hh:mm:ss"); + this.form.activity_order_id = this.orderid = this.listActivtyOrder[index].id; } this.orderType = type; }, openselectorder() { - this.showSelectorder = false; + this.showSelectorder = true; }, closeorder() { this.showSelectorder = false; @@ -251,7 +258,6 @@ data: this.form, method: "POST", utilSuccess: function(res) { - console.log(res) uni.showToast({ icon: "none", title: "下单成功", diff --git a/pages/visit/book.vue b/pages/visit/book.vue index 7ffc7b5..f01d366 100644 --- a/pages/visit/book.vue +++ b/pages/visit/book.vue @@ -44,12 +44,16 @@ + :class="{'book-box-row-timeitem-on':item.checked,'timeitem-none':item.remain_count==0}" + :key="index" @click="handleSelectTime(index)"> {{item.start_time+'-'+item.end_time}} - {{item.remain_count}}张 + + {{item.remain_count}}张 + + 售罄 @@ -340,8 +344,8 @@ } else { that.maxCount = res.team_max_count; that.minCount = res.team_min_count; - } - + } + that.form.total = that.minCount; }, utilFail: function(res) { @@ -549,7 +553,7 @@ this.showCalendar = false; }, handleSelectDate(e) { - if (this.showCalendar && e.length != 0 && e[0] != this.currentDate.date) { + if (this.showCalendar && e.length != 0 ) { this.load3Day(e[0]); this.showCalendar = false; } @@ -601,27 +605,24 @@ m.checked = false; } cdate.checked = true; - let i = 0; - for (var m of cdate.rules) { - m.checked = false; - - m.checked = i == 0 - if (m.checked) { - this.currentTime = m; - } - i++; - } + + this.loadDefaultTime(cdate.rules); this.currentDate = cdate; this.listDatePrice = list; this.$forceUpdate(); }, handleSelectTime(index) { - for (var m of this.currentDate.rules) { - m.checked = false; - } - this.currentDate.rules[index].checked = true; - this.currentTime = this.currentDate.rules[index]; + var mod = this.currentDate.rules[index]; + if (mod.remain_count == 0) { + this.util.toast("该时段已售罄"); + return false + } + for (var m of this.currentDate.rules) { + m.checked = false; + } + mod.checked = true; + this.currentTime = mod; this.$forceUpdate(); }, load3Day(sdate) { //加载7天数据 @@ -653,27 +654,25 @@ m.week = week; } - if (m.date == selectDate && m.is_open == 1) { - m.checked = true; - that.currentDate = m; - that.currentIndex = i; - let idx = 0; - for (var mod of m.rules) { - mod.checked = false; - if (that.bcurrentTime) { - if (mod.id == that.bcurrentTime.id) - mod.checked = true; - that.currentTime = that.bcurrentTime; - } else { - mod.checked = idx == 0 - if (mod.checked) { - that.currentTime = mod; - } - } - idx++; - } - } else { - selectDate = that.$moment(selectDate).add('days', 1).format("yyyy-MM-DD"); + if (m.date == selectDate) { + if (m.is_open == 1) { + m.checked = true; + that.currentDate = m; + that.currentIndex = i; + that.loadDefaultTime(m.rules); + } else { + + uni.showToast({ + icon: "none", + title: selectDate + "不可以预约", + complete() { + setTimeout(function() { + that.load3Day(that.$moment(selectDate).add('days', 1) + .format("yyyy-MM-DD")) + }, 2000) + } + }, 2000) + } } i++; } @@ -695,6 +694,21 @@ } }) }, + loadDefaultTime(rules) { + var that = this; + that.currentTime = {}; + let isDefault = false; + for (var mod of rules) { + mod.checked = false; + + if (!isDefault && mod.remain_count > 0) { + isDefault = true; + mod.checked = true; + that.currentTime = mod; + } + } + + }, closeAdd() { this.showAdd = false }, @@ -716,6 +730,10 @@