diff --git a/bundle/recharge/recharge.vue b/bundle/recharge/recharge.vue index e922152..cf7b7d4 100644 --- a/bundle/recharge/recharge.vue +++ b/bundle/recharge/recharge.vue @@ -26,12 +26,22 @@ + + + 我已阅读并同意充值协议 + + + + + 充值说明 a.账户充值仅限在线方式支付,充值金额实时到账; b.有问题请联系客服。 + c.充值前请先查看本协议《充值协议》 确定 @@ -67,7 +77,8 @@ return { cardPopup: false, currentType: -1, - balance: {} + balance: {}, + yxChekced: true } }, @@ -92,17 +103,55 @@ this.currentType = index; }, + checkboxChange(e) { + console.log("🚀 ~ e:", e) + this.yxChekced = e.detail.value[0] + console.log("🚀 ~ e:", this.yxChekced) + + }, + // 确认选择 confirmCard() { - if (this.currentType == -1) { + if (!this.yxChekced) { uni.showToast({ - title: '请选择充值金额', + title: '请同意充值协议', icon: 'none' }); return; } - this.wxPay() + let self = this; + uni.showLoading({ + title: '加载中' + }); + self._post('user.index/detail', { + source: self.getPlatform() + }, function(res) { + uni.hideLoading(); + console.log("🚀 ~ res:", res) + if (res.data.userInfo.mobile == '') { + uni.showModal({ + title: '提示', + content: '请先绑定手机号', + success: function(sm) { + if (sm.confirm) { + uni.switchTab({ + url: '/pages/user/index/index' + }); + } + } + }); + }else { + if (self.currentType == -1) { + uni.showToast({ + title: '请选择充值金额', + icon: 'none' + }); + return; + } + self.wxPay() + } + }); }, // 微信支付 @@ -180,6 +229,12 @@ }, 500); } }, + + see() { + uni.navigateTo({ + url: '/pages/webview/webview?url=https://xh.stnav.com/czxy.html' + }); + } } } diff --git a/bundle/reserve/confirm.vue b/bundle/reserve/confirm.vue index 7fd4978..7d9dcc1 100644 --- a/bundle/reserve/confirm.vue +++ b/bundle/reserve/confirm.vue @@ -217,9 +217,9 @@ @@ -272,7 +272,7 @@ - + 平台余额 @@ -376,8 +376,7 @@ this.orderId = args.orderId || 0; // 订单ID this.venueId = args.venueId || 0; // 场馆ID this.typeId = args.typeId || 1; // 网球场1 篮球场2 - this.basketballDate = args.date || null; // 篮球场预约时间 - console.log("🚀 ~ this.date:", this.date) + // this.basketballDate = args.date || null; // 篮球场预约时间 this.getData(); this.getRecharge() }, @@ -592,7 +591,7 @@ if (this._submitting) return; this._submitting = true; - if (this.countSelectedTime === 0) { + if (this.countSelectedTime === 0 && this.typeId == 1) { uni.showToast({title: '请选择时间后再预定', icon: 'none'}); this._submitting = false; return; diff --git a/bundle/reserve/details.vue b/bundle/reserve/details.vue index 3e9811f..faf3cf9 100644 --- a/bundle/reserve/details.vue +++ b/bundle/reserve/details.vue @@ -37,7 +37,7 @@ 使用费 - + @@ -136,7 +136,7 @@ 可预约 已选中 - 不可约 + 已约 @@ -158,23 +158,28 @@ {{ item.t }} - - - {{ item2.title }} - - - - - + + + + {{ item2.title }} + + + + + + + + @@ -198,7 +203,7 @@ 预定时间 - 默认4小时,注意闭馆时间 + 场地时间营业至22:00,注意闭馆时间 {{ date || '请选择' }} @@ -262,7 +267,11 @@ export default { venueRoomLists: [], loadding: true, timePopup: false, - date: '', + date: '', // 选择的篮球场管预约时间 + dayTitle: '', // 选择的篮球场管预约日期标题 + dayTime: '', // 选择的篮球场管预约日期 + datetimestamp: '', // 选择的篮球场管预约时间戳 + dateEndTimestamp: '', // 选择的篮球场管预约结束时间戳 showPrice: true, bill: { cdf: { @@ -353,6 +362,10 @@ export default { // 篮球场场馆-切换tab handleTabClick(idx) { this.selectedRoomIndex = idx + this.date = '' + this.datetimestamp = '' + this.bill.cdf.price = 0 + this.bill.total = 0 }, // 切换tab @@ -386,14 +399,17 @@ export default { }); }, - // 确认选择时间 + // 篮球场-确认选择时间 confirmSelectTime(e) { + console.log("🚀 ~ e:", e) + let self = this this.date = e.value - - // 计算费用明细 - uni.showLoading({ - title: '加载中' - }); + this.datetimestamp = e.timestamp + this.dateEndTimestamp = e.endtimestamp + const price = self.venueRoomLists[self.selectedRoomIndex].price + console.log("🚀 ~ price:", price) + this.bill.cdf.price = price + this.bill.total = price }, // 计算费用明细 @@ -445,94 +461,6 @@ export default { this.showPrice = true; }, - // 立即预约 - toReserve() { - let self = this - // 一进来就锁定,彻底防止高频点击 - if (self.typeId == 1) { - if (self.selectedReserveTime.length === 0) { - uni.showToast({ - title: '请选择预约时间', - icon: 'none' - }); - return; - } - uni.showLoading({ - title: '提交中', - mask: true, - }); - try { - const start = self.selectedReserveTime[0].day_time + ' ' + self.selectedReserveTime[0].end_time; - const end = self.selectedReserveTime[self.selectedReserveTime.length -1].day_time + ' ' + self.selectedReserveTime[self.selectedReserveTime.length -1].end_time; - // 转换为时间戳 - const startTimestamp = Math.floor(Date.parse(start.replace(/-/g, '/')) / 1000);; - const endTimestamp = Math.floor(Date.parse(end.replace(/-/g, '/')) / 1000);; - - // 订单提交 - self._post( - 'order.groundOrder/submitStoreOrder', - { - app_id: self.getAppId(), - ground_id: self.id, - room_list: JSON.stringify(self.selectedReserveTime), - type: self.typeId, - start_end: startTimestamp + '-' + endTimestamp, - amount_price: self.bill.total - }, - function(res) { - self.loadding = false; - if(res.code) { - // 记录费用明细到缓存中 - // uni.setStorageSync('billDetail', JSON.stringify(self.bill)); - - uni.$on('payment', params => { - console.log("🚀 ~ params:", params) - uni.showLoading({ - title: '加载中', - mask: true, - }); - setTimeout(() => { - self.loadding = false - uni.$off("payment") - if (params.result) { - uni.redirectTo({ - url: `/bundle/reserve/notice?order_id=${params.order_id}` - }) - } else { - uni.redirectTo({ - url: '/pages/order/cg-my-order' - }) - } - }, 500) - }) - - uni.navigateTo({ - url: `/bundle/reserve/confirm?venueId=${self.venue.id}&roomId=${self.id}&typeId=${self.typeId}&orderId=${res.data.lists.id}` - }); - } - } - ) - } catch (error) { - console.error('订单提交失败:', error); - uni.showToast({ - title: '订单提交失败,请重试', - icon: 'none' - }); - self.loadding = false; - } - } else { - if (!self.date) { - uni.showToast({ - title: '请选择预约时间', - icon: 'none' - }); - return; - } - uni.navigateTo({ - url: `/bundle/reserve/confirm?venueId=${self.venue.id}&roomId=${self.id}&typeId=${self.typeId}` - }); - } - }, /** * @@ -705,7 +633,161 @@ export default { } } ) - } + }, + + // 立即预约-提交订单 + toReserve() { + + let self = this + // 一进来就锁定,彻底防止高频点击 + if (self.typeId == 1) { + if (self.selectedReserveTime.length === 0) { + uni.showToast({ + title: '请选择预约时间', + icon: 'none' + }); + return; + } + uni.showLoading({ + title: '提交中', + mask: true, + }); + try { + const start = self.selectedReserveTime[0].day_time + ' ' + self.selectedReserveTime[0].end_time; + const end = self.selectedReserveTime[self.selectedReserveTime.length -1].day_time + ' ' + self.selectedReserveTime[self.selectedReserveTime.length -1].end_time; + // 转换为时间戳 + const startTimestamp = Math.floor(Date.parse(start.replace(/-/g, '/')) / 1000);; + const endTimestamp = Math.floor(Date.parse(end.replace(/-/g, '/')) / 1000);; + + // 订单提交 + self._post( + 'order.groundOrder/submitStoreOrder', + { + app_id: self.getAppId(), + ground_id: self.id, + room_list: JSON.stringify(self.selectedReserveTime), + type: self.typeId, + start_end: startTimestamp + '-' + endTimestamp, + amount_price: self.bill.total + }, + function(res) { + self.loadding = false; + if(res.code) { + // 记录费用明细到缓存中 + // uni.setStorageSync('billDetail', JSON.stringify(self.bill)); + + uni.$on('payment', params => { + console.log("🚀 ~ params:", params) + uni.showLoading({ + title: '加载中', + mask: true, + }); + setTimeout(() => { + self.loadding = false + uni.$off("payment") + if (params.result) { + uni.redirectTo({ + url: `/bundle/reserve/notice?order_id=${params.order_id}` + }) + } else { + uni.redirectTo({ + url: '/pages/order/cg-my-order' + }) + } + }, 500) + }) + + uni.navigateTo({ + url: `/bundle/reserve/confirm?venueId=${self.venue.id}&roomId=${self.id}&typeId=${self.typeId}&orderId=${res.data.lists.id}` + }); + } + } + ) + } catch (error) { + console.error('订单提交失败:', error); + uni.showToast({ + title: '订单提交失败,请重试', + icon: 'none' + }); + self.loadding = false; + } + } else { + const room = self.venueRoomLists[self.selectedRoomIndex] + if (!self.date) { + uni.showToast({ + title: '请选择预约时间', + icon: 'none' + }); + return; + } + + try { + self.loadding = true; + const roomList = [ + { + room_id: room.id, + day_time: self.datetimestamp, + day_title: self.datetimestamp, + start_time: self.datetimestamp, + end_time: self.datetimestamp, + room_price: self.bill.cdf.price, + } + ] + self._post( + 'order.GroundOrder/addBskStoreOrder', + { + app_id: self.getAppId(), + room_id: room.id, + ground_id: self.id, + room_list: JSON.stringify(roomList), + type: self.typeId, + start_end: self.datetimestamp + '-' + self.dateEndTimestamp, + }, + function(res) { + self.loadding = false; + if(res.code) { + // 记录费用明细到缓存中 + // uni.setStorageSync('billDetail', JSON.stringify(self.bill)); + + uni.$on('payment', params => { + console.log("🚀 ~ params:", params) + uni.showLoading({ + title: '加载中', + mask: true, + }); + setTimeout(() => { + self.loadding = false + uni.$off("payment") + if (params.result) { + uni.redirectTo({ + url: `/bundle/reserve/notice?order_id=${params.order_id}` + }) + } else { + uni.redirectTo({ + url: '/pages/order/cg-my-order' + }) + } + }, 500) + }) + console.log("🚀 ~ res.data.lists.id:", res.data) + console.log("🚀 ~ res.data.lists.id:", res.data.lists.id) + uni.navigateTo({ + url: `/bundle/reserve/confirm?venueId=${self.venue.id}&roomId=${self.id}&typeId=${self.typeId}&orderId=${res.data.lists.id}` + }); + } + } + ) + + } catch (error) { + console.error('订单提交失败:', error); + uni.showToast({ + title: '订单提交失败,请重试', + icon: 'none' + }); + self.loadding = false; + } + } + }, } }; @@ -844,8 +926,8 @@ page { width: 20rpx; height: 20rpx; border-radius: 100%; - background: #F7F7F7; - border: 2rpx solid #E9ECF4; + background: #41C95D; + border: 2rpx solid #41C95D; margin-right: 10rpx; } @@ -1111,24 +1193,50 @@ page { } .cg-time-block { - margin-top: 76rpx; + margin-top: 85rpx; .cg-time { font-size: 26rpx; color: #303133; height: 60rpx; - line-height: 60rpx; + // line-height: 60rpx; border: 2rpx solid transparent; - margin: 4rpx; + margin: 4rpx 4rpx 14rpx; + position: relative; } } .cg-info { margin-left: 54rpx; margin-top: 38rpx; + display: flex; + overflow-x: auto; + position: relative; + .cg-border { + position: absolute; + left: 0; + right: 0; + width: 100%; + border-bottom: 2rpx solid #FFC880; + top: 38rpx; + } + + .cg-right-border { + position: absolute; + right: -8px; + top: -12rpx; + height: 100%; + border-right: 4rpx solid #FFC880; + } + + .cg-right-border:last-of-type { + border-right: none; + } + .cg-info-time { margin: 4rpx; + margin-bottom: 14rpx; width: 120rpx; height: 60rpx; text-align: center; @@ -1137,15 +1245,20 @@ page { font-size: 26rpx; } + .cg-right-border.no-border { + border-right: none; + } + .cg-info-time-none { - background: #D4DAE6; - border: 2rpx solid #D4DAE6; + background: #BBBFC7; + border: 2rpx solid #BBBFC7; + color: #fff; } .cg-info-time-normal { - background: #F7F7F7; - border: 2rpx solid #E9ECF4; - color: #303133; + background: #41C95D; + border: 2rpx solid #41C95D; + color: #fff; } .cg-info-time-select { diff --git a/components/reserve-time.vue b/components/reserve-time.vue index 5344306..c642f7f 100644 --- a/components/reserve-time.vue +++ b/components/reserve-time.vue @@ -29,10 +29,19 @@ data: function () { const date = new Date(); const weekMap = ['日', '一', '二', '三', '四', '五', '六']; - // 生成前天、昨天、今天、明天、后天 + // 生成今天起未来7天,若当天已过22:00则不加入当天 const dateList = []; - for (let i = -2; i <= 2; i++) { + for (let i = 0; i < 7; i++) { const d = new Date(date.getFullYear(), date.getMonth(), date.getDate() + i); + // 判断当天是否已过22:00 + if (i === 0) { + const now = new Date(); + if (now.getFullYear() === d.getFullYear() && now.getMonth() === d.getMonth() && now.getDate() === d.getDate()) { + if (now.getHours() > 21 || (now.getHours() === 21 && now.getMinutes() >= 60)) { + continue; // 跳过当天 + } + } + } const mm = (d.getMonth() + 1).toString().padStart(2, '0'); const dd = d.getDate().toString().padStart(2, '0'); const week = weekMap[d.getDay()]; @@ -41,64 +50,99 @@ date: d }); } - // 小时 6-22 - const hourList = []; - for (let i = 6; i <= 22; i++) { - hourList.push(i < 10 ? `0${i}` : `${i}`); - } - // 分钟 00\10\20\30\40\50 - const minuteList = []; - for (let i = 0; i < 60; i += 10) { - minuteList.push(i < 10 ? `0${i}` : `${i}`); - } - // 默认选中今天 - let dateIndex = 2; - // 当前小时和分钟 - const now = new Date(); - let hourIndex = hourList.findIndex(h => parseInt(h) === now.getHours()); - if (hourIndex === -1) hourIndex = 0; - let minuteIndex = minuteList.findIndex(m => parseInt(m) === now.getMinutes()); - if (minuteIndex === -1) minuteIndex = 0; + // 默认选中今天、当前小时、当前分钟 return { title: 'picker-view', dateList, - hourList, - minuteList, - value: [dateIndex, hourIndex, minuteIndex], // 默认选中今天、当前小时、当前分钟 + hourList: [], + minuteList: [], + value: [0, 0, 0], visible: true, indicatorStyle: `height: 50px;` } }, mounted() { + this.updateHourAndMinuteList(0, 0); }, methods: { bindChange: function (e) { const val = e.detail.value; // 选中项索引分别为dateList、hourList、minuteList this.value = val; + // 联动更新小时和分钟 + this.updateHourAndMinuteList(val[0], val[1]); + }, + + // 联动生成小时和分钟列表 + updateHourAndMinuteList(dateIdx, hourIdx) { + const now = new Date(); + const selectedDate = this.dateList[dateIdx]?.date; + let hourList = []; + let minuteList = []; + // 判断是否为今天 + const isToday = selectedDate && + selectedDate.getFullYear() === now.getFullYear() && + selectedDate.getMonth() === now.getMonth() && + selectedDate.getDate() === now.getDate(); + if (isToday) { + // 如果当前时间已超过 22:00,则不显示任何可选时间 + if (now.getHours() > 21 || (now.getHours() === 21 && now.getMinutes() >= 60)) { + hourList = []; + minuteList = []; + } else { + for (let i = 6; i <= 21; i++) { + if (i > now.getHours()) { + hourList.push(i < 10 ? `0${i}` : `${i}`); + } else if (i === now.getHours()) { + // 当前小时,分钟要过滤 + let hasValidMinute = false; + for (let m = 0; m < 60; m += 10) { + if (m >= now.getMinutes()) { + hasValidMinute = true; + break; + } + } + if (hasValidMinute) { + hourList.push(i < 10 ? `0${i}` : `${i}`); + } + } + } + } + } else { + for (let i = 6; i <= 21; i++) { + hourList.push(i < 10 ? `0${i}` : `${i}`); + } + } + // 选中的小时 + let selectedHour = hourList[hourIdx] ? parseInt(hourList[hourIdx]) : parseInt(hourList[0]); + if (isToday && hourList.length > 0 && selectedHour === now.getHours()) { + for (let m = 0; m < 60; m += 10) { + if (m >= now.getMinutes()) { + minuteList.push(m < 10 ? `0${m}` : `${m}`); + } + } + } else if (hourList.length > 0) { + for (let m = 0; m < 60; m += 10) { + minuteList.push(m < 10 ? `0${m}` : `${m}`); + } + } else { + minuteList = []; + } + // 修正value + let value = [...this.value]; + // hourIdx/minuteIdx 越界修正 + if (value[1] >= hourList.length) value[1] = 0; + if (value[2] >= minuteList.length) value[2] = 0; + this.hourList = hourList; + this.minuteList = minuteList; + this.value = [dateIdx, value[1], value[2]]; }, // 重置 reset: function () { - const now = new Date(); - // 日期始终选中“今天” - let dateIndex = 2; - // 重新生成小时列表,确保与当前小时对齐 - const hourList = []; - for (let i = 6; i <= 21; i++) { - hourList.push(i < 10 ? `0${i}` : `${i}`); - } - let hourIndex = hourList.findIndex(h => parseInt(h) === now.getHours()); - if (hourIndex === -1) hourIndex = 0; - // 重新生成分钟列表,确保与当前分钟对齐 - const minuteList = []; - for (let i = 0; i < 60; i += 10) { - minuteList.push(i < 10 ? `0${i}` : `${i}`); - } - let minuteIndex = minuteList.findIndex(m => parseInt(m) === now.getMinutes()); - if (minuteIndex === -1) minuteIndex = 0; - this.value = [dateIndex, hourIndex, minuteIndex]; + // 重置为今天、可选的第一个小时和分钟 + this.updateHourAndMinuteList(0, 0); }, // 确认 @@ -106,15 +150,36 @@ // 获取选中索引 const [dateIdx, hourIdx, minuteIdx] = this.value; const dateObj = this.dateList[dateIdx]; + console.log("🚀 ~ dateObj:", this.value) const hour = this.hourList[hourIdx]; const minute = this.minuteList[minuteIdx]; + // 组装时间戳 + let ts = 0; + let endts = 0; + if (dateObj && hour !== undefined && minute !== undefined) { + // 构造 yyyy-mm-dd hh:mm:00 字符串 + const d = dateObj.date; + const yyyy = d.getFullYear(); + + const mm = (d.getMonth() + 1).toString().padStart(2, '0'); + const dd = d.getDate().toString().padStart(2, '0'); + const hh = hour.toString().padStart(2, '0'); + const mi = minute.toString().padStart(2, '0'); + const dateStr = `${yyyy}-${mm}-${dd} ${hh}:${mi}:00`; + const endStr = `${yyyy}-${mm}-${dd} 22:00:00`; + console.log("🚀 ~ endStr:", endStr) + ts = Math.floor(new Date(dateStr.replace(/-/g, '/')).getTime() / 1000); + endts = Math.floor(new Date(endStr.replace(/-/g, '/')).getTime() / 1000); + } // 传递给父组件 this.$emit('confirm', { date: dateObj.date, dateLabel: dateObj.label, hour, minute, - value: `${dateObj.label} ${hour}:${minute}` + value: `${dateObj.label} ${hour}:${minute}`, + timestamp: ts, + endtimestamp: endts }); this.$emit('close'); }, @@ -141,6 +206,7 @@ .item { line-height: 100rpx; text-align: center; + font-size: 32rpx; } .line { diff --git a/pages/index/index.vue b/pages/index/index.vue index 529b681..adb9463 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -637,16 +637,41 @@ export default { // 场馆预约 handleToReserve(id, typeId) { - if (typeId == 2) { - uni.showToast({ - title: '场馆暂未开放', - duration: 2000, - icon: 'none' - }); - return; - } - uni.navigateTo({ - url: `/bundle/reserve/details?id=${id}&typeId=${typeId}` + // if (typeId == 2) { + // uni.showToast({ + // title: '场馆暂未开放', + // duration: 2000, + // icon: 'none' + // }); + // return; + // } + /*是否有手机号码*/ + let self = this; + uni.showLoading({ + title: '加载中' + }); + self._post('user.index/detail', { + source: self.getPlatform() + }, function(res) { + uni.hideLoading(); + console.log("🚀 ~ res:", res) + if (res.data.userInfo.mobile == '') { + uni.showModal({ + title: '提示', + content: '请先绑定手机号', + success: function(sm) { + if (sm.confirm) { + uni.switchTab({ + url: '/pages/user/index/index' + }); + } + } + }); + }else { + uni.navigateTo({ + url: `/bundle/reserve/details?id=${id}&typeId=${typeId}` + }); + } }); }, diff --git a/pages/order/cg-my-order.vue b/pages/order/cg-my-order.vue index f76365e..9036015 100644 --- a/pages/order/cg-my-order.vue +++ b/pages/order/cg-my-order.vue @@ -59,7 +59,7 @@ 订单号:{{ item.order_sn }} - 预约时间:{{ item.trade[0].day_title }} + 预约时间:{{ ballType == 1 ? item.trade[0].day_title : item.times }} - 使用过程中有任何问题,请联系商家 + 使用过程中有任何问题,请联系客服 预约时间:{{ detail.day_time }} - 预约时长:{{ detail.hours }}小时 + 预约时长:{{ detail.hours }}小时