Răsfoiți Sursa

版本更新

liuguofeng 6 luni în urmă
părinte
comite
f7f3c11075

+ 2 - 2
jiaoyu_mp/pages/course/index.vue

@@ -33,10 +33,10 @@
 				</view>
 				<view class="btn_title">
 					<view class="title">
-						上课地址:{{}}
+						上课地址:{{item.address}}
 					</view>
 					<view class="btn">
-						<navigator url="/pagesA/course/reservation">
+						<navigator :url="`/pagesA/course/reservation?orders_product_id=${item.orders_product_id}course_id=${item.course_id}`">
 							<view class="course_make_btn">
 								预约上课
 							</view>

+ 231 - 105
jiaoyu_mp/pagesA/course/reservation.vue

@@ -2,22 +2,22 @@
 	<view class="reservation_layout">
 		<view class="header_title">
 			<view class="left">
-				<view class="title">少儿架子鼓进阶课程</view>
-				<view class="subtitle">擅长架子鼓、播音主持等</view>
+				<view class="title">{{course_name}}</view>
+				<view class="subtitle">{{teacher_desc}}</view>
 			</view>
 			<view class="right">
-				<image src="../../static/logo2.jpg" class="image" mode=""></image>
+				<image :src="course_image" class="image" mode=""></image>
 			</view>
 		</view>
 		<view class="teacher_list">
-			<view class="teacher_item" v-for="(item,index) in data" :key="index">
+			<view class="teacher_item" v-for="(item,index) in data" :key="index" @click="selectTeacher(index,item)" :class="index === teacherActive? 'active':''">
 				<text>{{item.teacher_name}}</text>
 			</view>
 		</view>
 		<view class="course">
-			<scroll-view :scroll-x="true" >
+			<scroll-view scroll-x >
 				<view class="days">
-				  <view class="day" v-for="(item, index) in dateArr" :key="index" @click="selectDateEvent(index,item)" :style="{color:index==dateActive?selectedTabColor:'#333'}">
+				  <view class="day" v-for="(item, index) in dateArr" :key="index" @click="selectDateEvent(index,item)" :class="{ borderb: index==dateActive}" :style="{color:index==dateActive?selectedTabColor:'#333'}">
 				    <text>{{ item.week }}</text>
 					<view>{{item.date}}</view>
 				  </view>
@@ -27,56 +27,37 @@
 			    <view class="times">
 			      <view class="time_list">
 					  	<view class="day" v-for="(item,_index) in timeArr" :key="_index" :class="{'disable':item.disable,
-						'active':isMultiple?item.isActive:_index==timeActive}" :style="{color:isMultiple?item.isActive? selectedItemColor:'#333'
-						 :_index==timeActive?selectedItemColor:'#333'}" @click="selectTimeEvent(_index,item)">
+						'active':isMultiple?item.isActive:_index==timeActive}" :style="{color:isMultiple?item.isActive? '#fff':'#333'
+						 :_index==timeActive?'#fff':'#333',backgroundColor:isMultiple?item.isActive? selectedItemColor:''
+						 :_index==timeActive?selectedItemColor:''}" @click="selectTimeEvent(_index,item)">
 					  	  <text>{{item.disable?disableText:undisableText}}</text>
 					  		<view>{{item.time}}</view>
+							<view >{{item.sum}}</view>
 					  	</view>
 			      </view>
 			    </view>
 		</view>
-<!-- 		<uni-popup ref="popup" :safe-area="false">
-			<view class="popup_layout">
-				<view class="title">
-					2024-10-24 周三上午
-				</view>
-				<view class="time_list">
-					<view class="time_item">
-						9:30
-					</view>
-					<view class="time_item">
-						9:30
-					</view>
-					<view class="time_item">
-						9:30
-					</view>
-					<view class="time_item">
-						9:30
-					</view>
-				</view>
-				<button @click="outcomePopup()" class="confirm_button" >确认</button>
-			</view>
-		</uni-popup> -->
-		
-		<uni-popup ref="outcomePopup" >
+		<view class="">
+			预约时间:{{orderDateTime}}
+		</view>
+		<button @click="reservationPopup()" class="confirm_button"  >确认预约</button>
+		<uni-popup ref="outcomePopup" :is-mask-click="false"  >
 			<view class="outcome_popup_layout">
 				<view class="outcome_title">
 					预约成功
 				</view>
-				<view class="outcome_text" v-for="(item,index) in isTime" :key="index">
-					你已经预约{{item}}直播主持课程
+				<view class="outcome_text" >
+					你已经预约:{{orderDateTime}}直播主持课程
 				</view>
 				<button  class="outcome_button" @click="outcomeButton()" >确认</button>
 			</view>
 		</uni-popup>
-		
-		<button @click="reservationPopup()" class="confirm_button"  >确认预约</button>
+
 	</view>
 </template>
 
 <script>
 	export default {
-		
 		props: {
 			isQuantum: {
 				type: Boolean,
@@ -84,15 +65,19 @@
 			},
 			isMultiple: { //是否多选
 				type: Boolean,
-				default: true
+				default: false
 			},
 			isSection: { //预约时间段
 				type: Boolean,
 				default: false
 			},
-			disableText: { //禁用显示的文本
+			disableText:{ //禁用显示的文本
 				type: String,
-				default: "已约满"
+				default: "已预约"
+			},
+			disableSumText:{
+				type:String,
+				default:"已约满"
 			},
 			undisableText: { //未禁用显示的文本
 				type: String,
@@ -104,11 +89,11 @@
 			},
 			selectedTabColor: { // 日期栏选中的颜色
 				type: String,
-				default: "#FB4B5C"
+				default: "#51bf81"
 			},
 			selectedItemColor: { // 时间选中的颜色
 				type: String,
-				default: "#FB4B5C"
+				default: "#51bf81"
 			},
 			beginTime: {
 				type: String,
@@ -166,7 +151,7 @@
 							"teacher_name": "张老师",
 							"teacher_desc": "擅长舞蹈",
 							"course_name": "拳击初级课",
-							"course_image": "http://kailin.com/uploads/images/1/img.jpg",
+							"course_image": "../../static/logo2.jpg",
 							"course_desc": "拳击讲解",
 							"address": "一方天地"
 						}
@@ -186,14 +171,25 @@
 					        "teacher_name": "王老师",
 					        "teacher_desc": "从业20年,资深老教室",
 					        "course_name": "拳击初级课",
-					        "course_image": "http://kailin.com/uploads/images/1/img.jpg",
+					        "course_image": "../../static/logo2.jpg",
 					        "course_desc": "拳击讲解",
 					        "address": "一方天地"
 					    }
 					}
 				],
-				start_time: 1731823931,
-				end_time: 1731324931,
+
+				course_number: 30,
+				reservation_number: 0,
+				teacher_desc: "",
+				course_name: "",
+				course_image: "",
+				start_time: 1731823931,//开始时间戳
+				end_time: 1731324931,//结束时间戳
+				orders_product_id:0,//商品id
+				course_id:0,//课程id
+				schedule_id:0,//排课id
+				teacherActive:-1,
+				
 				orderDateTime: '暂无选择', // 选中时间
 				orderTimeArr: {}, //多选的时间
 				dateArr: [], //日期数据
@@ -205,20 +201,131 @@
 				selectDate: "", //选择的日期
 				timeQuanBegin: "", //时间段开始时间
 				timeQuanEnd: "", //时间段结束时间
-				isTime:[],
+				// isTime:[],
 				
 			  // teacherList: ['王老师', '崔老师','王老师', '崔老师'],
 			  // days: ['周一', '周二', '周三', '周四', '周五'],
-			  //商品Id
-			  orders_product_id:0,
+
 			}
 		},
 		created(props) {
-			 this.selectDate = this.nowDate =this.currentTime().date
+			this.selectDate = this.nowDate =this.currentTime().date
+			 
 			this.initOnload()
 		},
+		onLoad(e) {
+			//接受url参数
+			let {orders_product_id,course_id} = e
+			
+			this.orders_product_id = orders_product_id
+			this.course_id = course_id
+		},
+		onShow() {
+			//doto 这行代码应该放在请求成功之后执行
+			this.defaultTeacherDesc()
+
+
+			if(this.orders_product_id > 0 && this.course_id > 0){
+				
+				this.$http.request('api/course/get_schedule_list',{orders_product_id:this.orders_product_id,course_id:this.course_id},'post').then((res)=>{
+					if(res.code === "success"){
+						this.data = res.data;
+						
+						
+						// this.selectDate = this.nowDate =this.currentTime().date
+						 
+						// this.initOnload()
+					}
+				})
+			}
+			
+		},
 		methods: {
+			//老师选择事件
+			selectTeacher(index,item){
+				
+				if(this.teacherActive == index)return
+				
+				this.teacherActive = index;
+				
+				if(!this.isMultiple){
+					this.orderDateTime = "暂无选择"
+				}
+				
+				if(this.data.length >0){
+
+					if(this.teacherActive == index){
+						
+						this.course_number = this.data[index]["list"].course_number
+						this.reservation_number = this.data[index]["list"].reservation_number
+						this.teacher_desc = this.data[index]["list"].teacher_desc
+						this.course_name = this.data[index]["list"].course_name
+						this.course_image = this.data[index]["list"].course_image
+						this.start_time = this.data[index]["list"].start_time
+						this.schedule_id = this.data[index]["list"].id
+						this.initOnload()
+					}
+
+				}
+				
+			},
+			
+			//默认选项
+			defaultTeacherDesc(){
+				if(this.data.length>0){
+				this.course_number = this.data[0]["list"].course_number
+				this.reservation_number = this.data[0]["list"].reservation_number
+				this.teacher_desc = this.data[0]["list"].teacher_desc
+				this.course_name = this.data[0]["list"].course_name
+				this.course_image = this.data[0]["list"].course_image
+				this.teacherActive = 0;
+				this.start_time = this.data[0]["list"].start_time
+				this.schedule_id = this.data[0]["list"].id//排课id	
+				}	
+			},
+			//预约课程事件
+			reservationPopup(){
+				  if(this.schedule_id === 0){
+					  uni.showToast({
+					  	title:"请选择老师",
+						icon:"none"
+					  })
+					  return
+				  }
+				  if(this.orderDateTime === "暂无选择"){
+					  uni.showToast({
+					  	title:"请选择预约时间",
+					  	icon:"none"
+					  })
+					  return
+				  }
+				  
+				  
+
+				  this.$http.request("api/course/get_schedule_list",{course_id:this.course_id,orders_product_id:this.orders_product_id},'post').then((res)=>{
+					  if(res.code === 'success'){
+						  if(this.reservation_number < this.course_number){
+						  	this.reservation_number++
+						  }
+						  this.handleSubmit();
+						  this.initOnload();
+						  this.$refs.outcomePopup.open("center")
+					  }else{
+						  uni.showToast({
+						  	title:`${res.msg}`,
+							icon:"error"
+						  })
+						  return
+					  }
+				  })
+					
+			   },
 			
+			   outcomeButton(){
+				   this.orderDateTime = '暂无选择'
+				   this.$refs.outcomePopup.close();
+			   },
+
 			initOnload() {
 				this.dateArr = this.initData() // 日期栏初始化
 				this.timeArr = this.initTime(this.beginTime, this.endTime, this.timeInterval, this.isQuantum) //时间选项初始化
@@ -227,6 +334,7 @@
 				let isFullTime = true
 				this.timeArr.forEach((item, index) => {
 					// 时间段
+					//todo  this.isQuantum这个逻辑以后优化可能会用到,现在是只能选着一个时间,后面如果需要优化就使用这个this.isQuantum=true这个逻辑
 					if (this.isQuantum) {
 						const cur_be_time = `${this.selectDate} ${item.begin}:00`
 						const cur_end_time = `${this.selectDate} ${item.end}:00`
@@ -254,6 +362,10 @@
 						// if (this.selectDate == this.nowDate && this.currentTime().time > item.time) {
 						// 	item.disable = true
 						// }
+						
+						if(this.reservation_number === this.course_number){
+							item.disableSum = true
+						}
 			
 						// 将预约的时间禁用
 						this.appointTime.forEach(t => {
@@ -288,21 +400,24 @@
 			
 				})
 			
-				this.orderDateTime = isFullTime ? "暂无选择" : this.selectDate
-				this.timeActive = -1
-				for (let i = 0, len = this.timeArr.length; i < len; i++) {
-					if (!this.timeArr[i].disable) {
-						this.orderDateTime = `${this.selectDate} ${this.timeArr[i].time}`
-						this.timeActive = i
-						return
-					}
-				}
+				// this.orderDateTime = isFullTime ? "暂无选择" : `${this.selectDate}`
+				 this.timeActive = -1
+				// for (let i = 0, len = this.timeArr.length; i < len; i++) {
+				// 	if (!this.timeArr[i].disable) {
+				// 		this.orderDateTime = `${this.selectDate} ${this.timeArr[i].time}`
+				// 		this.timeActive = i
+				// 		return
+				// 	}
+				// }
 			},
 			
 			// 日期选择事件
 			selectDateEvent(index, item) {
 				this.dateActive = index
 				this.selectDate = item.date
+				if(!this.isMultiple){
+					this.orderDateTime = "暂无选择"
+				}
 				this.initOnload()
 			},
 			
@@ -313,6 +428,8 @@
 			
 				}
 				if (item.disable) return
+				if(item.disableSum) return
+				
 				if (this.isMultiple) {
 					item.isActive = !item.isActive
 					this.timeArr = this.timeArr.slice()
@@ -321,6 +438,7 @@
 						return prev
 					}, [])
 				} else {
+					console.log("hhh");
 					this.timeActive = index
 					this.orderDateTime = `${this.selectDate} ${item.time}`
 				}
@@ -395,17 +513,19 @@
 				])
 			},
 			handleSubmit() {
-				if (this.isSection) {
-					this.handleChange()
-					this.$emit('change', {
-						beginTime: `${this.selectDate} ${this.timeQuanBegin}`,
-						endTime: `${this.selectDate} ${this.timeQuanEnd}`
-					})
-					return
-				}
-				console.log("我执行拉?");
-				console.log(this.orderTimeArr)
+				// if (this.isSection) {
+				// 	this.handleChange()
+				// 	this.$emit('change', {
+				// 		beginTime: `${this.selectDate} ${this.timeQuanBegin}`,
+				// 		endTime: `${this.selectDate} ${this.timeQuanEnd}`
+				// 	})
+				// 	return
+				// }
+				// console.log(this.orderDateTime)
+				
+				
 				if (this.isMultiple) {
+					//这是多选模式的时候走的逻辑
 					if (this.isQuantum) {
 						this.$emit('change', this.orderTimeArr)
 						return
@@ -416,10 +536,12 @@
 							time.push(`${date} ${item}`)
 						})
 					}
-					this.$emit('change', time)
-					this.isTime = time
+					 this.$emit('change', time)
+					//this.isTime = time
 				} else {
-					this.$emit('change', this.orderDateTime)
+					//这是单选模式
+					 this.appointTime.push(this.orderDateTime);
+					 this.$emit('change', this.orderDateTime)
 				}
 			
 			},
@@ -459,25 +581,25 @@
 				const days = [ '日', '一', '二', '三', '四', '五', '六']
 				return {
 					allDate: `${year}/${this.strFormat(month)}/${this.strFormat(date)}`,
-					date: `${this.strFormat(date)}`, //返回的日期 07-01
+					date: `${this.strFormat(year)}-${this.strFormat(month)}-${this.strFormat(date)}`, //返回的日期 07-01
 					day: `周${days[day]}`, //返回的礼拜天数  星期一
 					hour: this.strFormat(hour) + ':' + this.strFormat(min) + (isQuantum ? "" : '') //返回的时钟 08:00
 				}
 			},
 			
-			//获取最近5天的日期和礼拜天数
+			//获取最近7天的日期和礼拜天数
 			 initData() {
 				const time = []
-				const date = new Date()
-				
-				const now = date.getTime() //获取当前日期的时间戳
+				// const date = new Date()
+				 //const now = date.getTime() //获取当前日期的时间戳
+				const now = this.start_time *1000
 				let timeStr = 3600 * 24 * 1000 //一天的时间戳
 				let obj = {
 					0: "今天",
 					// 1: "明天",
 					// 2: "后天"
 				}
-				for (let i = 0; i < 5; i++) {
+				for (let i = 0; i < 7; i++) {
 					time.push({
 						date: this.timeStamp(now + timeStr * i).date, //保存日期
 						timeStamp: now + timeStr * i, //保存时间戳
@@ -498,7 +620,6 @@
 				const timeStr = 3600 * 1000 * timeInterval
 				const sum = (endTimeStamp - startTimeStamp) / timeStr
 				const count = sum % 2 == 0 ? sum : (sum - 1)
-				let num = 0
 				for (let i = startTimeStamp; i <= endTimeStamp; i = i + timeStr) {
 				
 					if (isQuantum) {
@@ -509,8 +630,11 @@
 							disable: false
 						})
 					} else {
+						
 						time.push({
 							time: this.timeStamp(i).hour,
+							sum: `${this.reservation_number}/${this.course_number}`,
+							disableSum:false,
 							disable: false
 						})
 					}
@@ -518,22 +642,6 @@
 				}
 				return time
 			},
-			   reservationPopup(){
-				  //  if(!this.this.orderTimeArr.length){
-					 //   uni.showToast({
-					 //   	title:"请选择预约时间",
-						// icon:"none"
-					 //   })
-				  //  }
-				   this.handleSubmit();
-				   this.$refs.outcomePopup.open("center")
-			   },
-			   // outcomePopup(){
-				  //  this.$refs.outcomePopup.open("center")
-			   // },
-			   outcomeButton(){
-				   this.$refs.outcomePopup.close();
-			   }
 		}
 	}
 </script>
@@ -584,37 +692,55 @@
 			border-radius: 20rpx;
 			text-align: center;
 		}
+		.teacher_item.active{
+			color: #51bf81;
+			border: 2rpx solid #51bf81;
+		}
 	}
 	.course{
 		width: 690rpx;
-		border: 2rpx solid;
+		margin: 0rpx auto;
+		// border: 2rpx solid;
+		scroll-view{
+			width: 100%;
+			white-space: nowrap;
+			height: 75px;
+			background-color: #fff;
+			position: relative;
+			padding-top: 10rpx;
+		}
 		.days{
 			display: flex;
-			// margin-left: 115rpx;
-			background-color: #ffffff;
+			 background-color: #ffffff;
 			.day{
 				display: inline-flex;
 				flex-direction: column;
 				justify-content: center;
 				align-items: center;
-				width: 115rpx;
+				margin: 0rpx 10rpx;
 				height: 115rpx;
+				text{
+					margin: 10rpx 0rpx;
+				}
+			}
+			.day.borderb {
+				border-bottom: 2px solid #51bf81;
 			}
 		}
 		.times{
-			border: 2rpx solid;
+			// border: 2rpx solid;
 			.time_list{
 					display: flex;
 					flex-wrap: wrap;
-					background-color: #ffffff;
-					border: 2rpx solid;
+					 background-color: #ffffff;
+					// border: 2rpx solid;
 					.time{
 						display: inline-flex;
 						justify-content: center;
 						align-items: center;
 						width: 115rpx;
 						height: 115rpx;
-						border: 2rpx solid;
+						// border: 2rpx solid;
 					}
 					.day{
 						display: inline-flex;
@@ -623,8 +749,8 @@
 						align-items: center;
 						width: 115rpx;
 						height: 115rpx;
-						background-color: #868686;
-						margin: 5rpx;
+						background-color: #f3f3f3;
+						margin: 10rpx;
 					}
 			}
 		}

+ 4 - 3
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pages/course/index.js

@@ -44,11 +44,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
         c: common_vendor.t(item.course_number),
         d: common_vendor.t(item.reservation_number),
         e: common_vendor.t(item.price_total),
-        f: index
+        f: common_vendor.t(item.address),
+        g: `/pagesA/course/reservation?orders_product_id=${item.orders_product_id}course_id=${item.course_id}`,
+        h: index
       };
     }),
-    b: common_assets._imports_0$2,
-    c: common_vendor.t()
+    b: common_assets._imports_0$2
   };
 }
 const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);

+ 1 - 1
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pages/course/index.wxml

@@ -1 +1 @@
-<view class="course_layout"><view class="course_list"><view wx:for="{{a}}" wx:for-item="item" wx:key="f" class="course_item"><view class="course_title"><view class="left"><image src="{{b}}"></image></view><view class="right"><view class="title">{{item.a}}</view><view class="skill">{{item.b}}</view><view class="course_option"><view class="course_num"> 课程数量:{{item.c}}</view><view class="course_num"> 总计10课堂 </view></view><view class="course_remain"><view class="remain_class"> 预约人数:{{item.d}}</view><view class="price"> ¥{{item.e}}</view></view></view></view><view class="btn_title"><view class="title"> 上课地址:{{c}}</view><view class="btn"><navigator url="/pagesA/course/reservation"><view class="course_make_btn"> 预约上课 </view></navigator><navigator url="/pagesA/course/usercourse"><view class="user_course_btn"> 我的预约 </view></navigator></view></view></view></view><view class="to_bottom">---到底啦---</view></view>
+<view class="course_layout"><view class="course_list"><view wx:for="{{a}}" wx:for-item="item" wx:key="h" class="course_item"><view class="course_title"><view class="left"><image src="{{b}}"></image></view><view class="right"><view class="title">{{item.a}}</view><view class="skill">{{item.b}}</view><view class="course_option"><view class="course_num"> 课程数量:{{item.c}}</view><view class="course_num"> 总计10课堂 </view></view><view class="course_remain"><view class="remain_class"> 预约人数:{{item.d}}</view><view class="price"> ¥{{item.e}}</view></view></view></view><view class="btn_title"><view class="title"> 上课地址:{{item.f}}</view><view class="btn"><navigator url="{{item.g}}"><view class="course_make_btn"> 预约上课 </view></navigator><navigator url="/pagesA/course/usercourse"><view class="user_course_btn"> 我的预约 </view></navigator></view></view></view></view><view class="to_bottom">---到底啦---</view></view>

+ 155 - 69
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pagesA/course/reservation.js

@@ -1,6 +1,5 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
-const common_assets = require("../../common/assets.js");
 const _sfc_main = {
   props: {
     isQuantum: {
@@ -10,7 +9,7 @@ const _sfc_main = {
     isMultiple: {
       //是否多选
       type: Boolean,
-      default: true
+      default: false
     },
     isSection: {
       //预约时间段
@@ -19,6 +18,10 @@ const _sfc_main = {
     },
     disableText: {
       //禁用显示的文本
+      type: String,
+      default: "已预约"
+    },
+    disableSumText: {
       type: String,
       default: "已约满"
     },
@@ -35,12 +38,12 @@ const _sfc_main = {
     selectedTabColor: {
       // 日期栏选中的颜色
       type: String,
-      default: "#FB4B5C"
+      default: "#51bf81"
     },
     selectedItemColor: {
       // 时间选中的颜色
       type: String,
-      default: "#FB4B5C"
+      default: "#51bf81"
     },
     beginTime: {
       type: String,
@@ -99,7 +102,7 @@ const _sfc_main = {
             "teacher_name": "张老师",
             "teacher_desc": "擅长舞蹈",
             "course_name": "拳击初级课",
-            "course_image": "http://kailin.com/uploads/images/1/img.jpg",
+            "course_image": "../../static/logo2.jpg",
             "course_desc": "拳击讲解",
             "address": "一方天地"
           }
@@ -119,14 +122,28 @@ const _sfc_main = {
             "teacher_name": "王老师",
             "teacher_desc": "从业20年,资深老教室",
             "course_name": "拳击初级课",
-            "course_image": "http://kailin.com/uploads/images/1/img.jpg",
+            "course_image": "../../static/logo2.jpg",
             "course_desc": "拳击讲解",
             "address": "一方天地"
           }
         }
       ],
+      course_number: 30,
+      reservation_number: 0,
+      teacher_desc: "",
+      course_name: "",
+      course_image: "",
       start_time: 1731823931,
+      //开始时间戳
       end_time: 1731324931,
+      //结束时间戳
+      orders_product_id: 0,
+      //商品id
+      course_id: 0,
+      //课程id
+      schedule_id: 0,
+      //排课id
+      teacherActive: -1,
       orderDateTime: "暂无选择",
       // 选中时间
       orderTimeArr: {},
@@ -147,26 +164,109 @@ const _sfc_main = {
       //选择的日期
       timeQuanBegin: "",
       //时间段开始时间
-      timeQuanEnd: "",
+      timeQuanEnd: ""
       //时间段结束时间
-      isTime: [],
+      // isTime:[],
       // teacherList: ['王老师', '崔老师','王老师', '崔老师'],
       // days: ['周一', '周二', '周三', '周四', '周五'],
-      //商品Id
-      orders_product_id: 0
     };
   },
   created(props) {
     this.selectDate = this.nowDate = this.currentTime().date;
     this.initOnload();
   },
+  onLoad(e) {
+    let { orders_product_id, course_id } = e;
+    this.orders_product_id = orders_product_id;
+    this.course_id = course_id;
+  },
+  onShow() {
+    this.defaultTeacherDesc();
+    if (this.orders_product_id > 0 && this.course_id > 0) {
+      this.$http.request("api/course/get_schedule_list", { orders_product_id: this.orders_product_id, course_id: this.course_id }, "post").then((res) => {
+        if (res.code === "success") {
+          this.data = res.data;
+        }
+      });
+    }
+  },
   methods: {
+    //老师选择事件
+    selectTeacher(index, item) {
+      if (this.teacherActive == index)
+        return;
+      this.teacherActive = index;
+      if (!this.isMultiple) {
+        this.orderDateTime = "暂无选择";
+      }
+      if (this.data.length > 0) {
+        if (this.teacherActive == index) {
+          this.course_number = this.data[index]["list"].course_number;
+          this.reservation_number = this.data[index]["list"].reservation_number;
+          this.teacher_desc = this.data[index]["list"].teacher_desc;
+          this.course_name = this.data[index]["list"].course_name;
+          this.course_image = this.data[index]["list"].course_image;
+          this.start_time = this.data[index]["list"].start_time;
+          this.schedule_id = this.data[index]["list"].id;
+          this.initOnload();
+        }
+      }
+    },
+    //默认选项
+    defaultTeacherDesc() {
+      if (this.data.length > 0) {
+        this.course_number = this.data[0]["list"].course_number;
+        this.reservation_number = this.data[0]["list"].reservation_number;
+        this.teacher_desc = this.data[0]["list"].teacher_desc;
+        this.course_name = this.data[0]["list"].course_name;
+        this.course_image = this.data[0]["list"].course_image;
+        this.teacherActive = 0;
+        this.start_time = this.data[0]["list"].start_time;
+        this.schedule_id = this.data[0]["list"].id;
+      }
+    },
+    //预约课程事件
+    reservationPopup() {
+      if (this.schedule_id === 0) {
+        common_vendor.index.showToast({
+          title: "请选择老师",
+          icon: "none"
+        });
+        return;
+      }
+      if (this.orderDateTime === "暂无选择") {
+        common_vendor.index.showToast({
+          title: "请选择预约时间",
+          icon: "none"
+        });
+        return;
+      }
+      this.$http.request("api/course/get_schedule_list", { course_id: this.course_id, orders_product_id: this.orders_product_id }, "post").then((res) => {
+        if (res.code === "success") {
+          if (this.reservation_number < this.course_number) {
+            this.reservation_number++;
+          }
+          this.handleSubmit();
+          this.initOnload();
+          this.$refs.outcomePopup.open("center");
+        } else {
+          common_vendor.index.showToast({
+            title: `${res.msg}`,
+            icon: "error"
+          });
+          return;
+        }
+      });
+    },
+    outcomeButton() {
+      this.orderDateTime = "暂无选择";
+      this.$refs.outcomePopup.close();
+    },
     initOnload() {
       this.dateArr = this.initData();
       this.timeArr = this.initTime(this.beginTime, this.endTime, this.timeInterval, this.isQuantum);
       this.timeQuanBegin = this.timeQuanEnd = "";
       console.log(this.orderTimeArr);
-      let isFullTime = true;
       this.timeArr.forEach((item, index) => {
         if (this.isQuantum) {
           const cur_be_time = `${this.selectDate} ${item.begin}:00`;
@@ -188,6 +288,9 @@ const _sfc_main = {
             }
           }
         } else {
+          if (this.reservation_number === this.course_number) {
+            item.disableSum = true;
+          }
           this.appointTime.forEach((t) => {
             let [date, time] = t.split(" ");
             if (date == this.selectDate && item.time == time) {
@@ -201,29 +304,23 @@ const _sfc_main = {
               item.disable = true;
             }
           }
-          if (!item.disable) {
-            isFullTime = false;
-          }
+          if (!item.disable)
+            ;
           this.isSection && (item.isInclude = false);
           if (this.isMultiple && (this.orderTimeArr[this.selectDate] || []).includes(item.time)) {
             item.isActive = true;
           }
         }
       });
-      this.orderDateTime = isFullTime ? "暂无选择" : this.selectDate;
       this.timeActive = -1;
-      for (let i = 0, len = this.timeArr.length; i < len; i++) {
-        if (!this.timeArr[i].disable) {
-          this.orderDateTime = `${this.selectDate} ${this.timeArr[i].time}`;
-          this.timeActive = i;
-          return;
-        }
-      }
     },
     // 日期选择事件
     selectDateEvent(index, item) {
       this.dateActive = index;
       this.selectDate = item.date;
+      if (!this.isMultiple) {
+        this.orderDateTime = "暂无选择";
+      }
       this.initOnload();
     },
     // 时间选择事件
@@ -233,6 +330,8 @@ const _sfc_main = {
       }
       if (item.disable)
         return;
+      if (item.disableSum)
+        return;
       if (this.isMultiple) {
         item.isActive = !item.isActive;
         this.timeArr = this.timeArr.slice();
@@ -241,6 +340,7 @@ const _sfc_main = {
           return prev;
         }, []);
       } else {
+        console.log("hhh");
         this.timeActive = index;
         this.orderDateTime = `${this.selectDate} ${item.time}`;
       }
@@ -313,16 +413,6 @@ const _sfc_main = {
       ]);
     },
     handleSubmit() {
-      if (this.isSection) {
-        this.handleChange();
-        this.$emit("change", {
-          beginTime: `${this.selectDate} ${this.timeQuanBegin}`,
-          endTime: `${this.selectDate} ${this.timeQuanEnd}`
-        });
-        return;
-      }
-      console.log("我执行拉?");
-      console.log(this.orderTimeArr);
       if (this.isMultiple) {
         if (this.isQuantum) {
           this.$emit("change", this.orderTimeArr);
@@ -335,8 +425,8 @@ const _sfc_main = {
           });
         }
         this.$emit("change", time);
-        this.isTime = time;
       } else {
+        this.appointTime.push(this.orderDateTime);
         this.$emit("change", this.orderDateTime);
       }
     },
@@ -372,7 +462,7 @@ const _sfc_main = {
       const days = ["日", "一", "二", "三", "四", "五", "六"];
       return {
         allDate: `${year}/${this.strFormat(month)}/${this.strFormat(date)}`,
-        date: `${this.strFormat(date)}`,
+        date: `${this.strFormat(year)}-${this.strFormat(month)}-${this.strFormat(date)}`,
         //返回的日期 07-01
         day: `周${days[day]}`,
         //返回的礼拜天数  星期一
@@ -380,18 +470,17 @@ const _sfc_main = {
         //返回的时钟 08:00
       };
     },
-    //获取最近5天的日期和礼拜天数
+    //获取最近7天的日期和礼拜天数
     initData() {
       const time = [];
-      const date = /* @__PURE__ */ new Date();
-      const now = date.getTime();
+      const now = this.start_time * 1e3;
       let timeStr = 3600 * 24 * 1e3;
       let obj = {
         0: "今天"
         // 1: "明天",
         // 2: "后天"
       };
-      for (let i = 0; i < 5; i++) {
+      for (let i = 0; i < 7; i++) {
         time.push({
           date: this.timeStamp(now + timeStr * i).date,
           //保存日期
@@ -413,7 +502,6 @@ const _sfc_main = {
       const timeStr = 3600 * 1e3 * timeInterval;
       const sum = (endTimeStamp - startTimeStamp) / timeStr;
       const count = sum % 2 == 0 ? sum : sum - 1;
-      let num = 0;
       for (let i = startTimeStamp; i <= endTimeStamp; i = i + timeStr) {
         if (isQuantum) {
           num++;
@@ -425,6 +513,8 @@ const _sfc_main = {
         } else {
           time.push({
             time: this.timeStamp(i).hour,
+            sum: `${this.reservation_number}/${this.course_number}`,
+            disableSum: false,
             disable: false
           });
         }
@@ -432,16 +522,6 @@ const _sfc_main = {
           return time;
       }
       return time;
-    },
-    reservationPopup() {
-      this.handleSubmit();
-      this.$refs.outcomePopup.open("center");
-    },
-    // outcomePopup(){
-    //  this.$refs.outcomePopup.open("center")
-    // },
-    outcomeButton() {
-      this.$refs.outcomePopup.close();
     }
   }
 };
@@ -455,42 +535,48 @@ if (!Math) {
 }
 function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
   return {
-    a: common_assets._imports_0$2,
-    b: common_vendor.f($data.data, (item, index, i0) => {
+    a: common_vendor.t($data.course_name),
+    b: common_vendor.t($data.teacher_desc),
+    c: $data.course_image,
+    d: common_vendor.f($data.data, (item, index, i0) => {
       return {
         a: common_vendor.t(item.teacher_name),
-        b: index
+        b: index,
+        c: common_vendor.o(($event) => $options.selectTeacher(index, item), index),
+        d: common_vendor.n(index === $data.teacherActive ? "active" : "")
       };
     }),
-    c: common_vendor.f($data.dateArr, (item, index, i0) => {
+    e: common_vendor.f($data.dateArr, (item, index, i0) => {
       return {
         a: common_vendor.t(item.week),
         b: common_vendor.t(item.date),
         c: index,
         d: common_vendor.o(($event) => $options.selectDateEvent(index, item), index),
-        e: index == $data.dateActive ? $props.selectedTabColor : "#333"
+        e: index == $data.dateActive ? 1 : "",
+        f: index == $data.dateActive ? $props.selectedTabColor : "#333"
       };
     }),
-    d: common_vendor.f($data.timeArr, (item, _index, i0) => {
+    f: common_vendor.f($data.timeArr, (item, _index, i0) => {
       return {
         a: common_vendor.t(item.disable ? $props.disableText : $props.undisableText),
         b: common_vendor.t(item.time),
-        c: _index,
-        d: item.disable ? 1 : "",
-        e: ($props.isMultiple ? item.isActive : _index == $data.timeActive) ? 1 : "",
-        f: $props.isMultiple ? item.isActive ? $props.selectedItemColor : "#333" : _index == $data.timeActive ? $props.selectedItemColor : "#333",
-        g: common_vendor.o(($event) => $options.selectTimeEvent(_index, item), _index)
-      };
-    }),
-    e: common_vendor.f($data.isTime, (item, index, i0) => {
-      return {
-        a: common_vendor.t(item),
-        b: index
+        c: common_vendor.t(item.sum),
+        d: _index,
+        e: item.disable ? 1 : "",
+        f: ($props.isMultiple ? item.isActive : _index == $data.timeActive) ? 1 : "",
+        g: $props.isMultiple ? item.isActive ? "#fff" : "#333" : _index == $data.timeActive ? "#fff" : "#333",
+        h: $props.isMultiple ? item.isActive ? $props.selectedItemColor : "" : _index == $data.timeActive ? $props.selectedItemColor : "",
+        i: common_vendor.o(($event) => $options.selectTimeEvent(_index, item), _index)
       };
     }),
-    f: common_vendor.o(($event) => $options.outcomeButton()),
-    g: common_vendor.sr("outcomePopup", "46f39ab6-0"),
-    h: common_vendor.o(($event) => $options.reservationPopup())
+    g: common_vendor.t($data.orderDateTime),
+    h: common_vendor.o(($event) => $options.reservationPopup()),
+    i: common_vendor.t($data.orderDateTime),
+    j: common_vendor.o(($event) => $options.outcomeButton()),
+    k: common_vendor.sr("outcomePopup", "46f39ab6-0"),
+    l: common_vendor.p({
+      ["is-mask-click"]: false
+    })
   };
 }
 const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);

+ 1 - 1
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pagesA/course/reservation.wxml

@@ -1 +1 @@
-<view class="reservation_layout"><view class="header_title"><view class="left"><view class="title">少儿架子鼓进阶课程</view><view class="subtitle">擅长架子鼓、播音主持等</view></view><view class="right"><image src="{{a}}" class="image" mode=""></image></view></view><view class="teacher_list"><view wx:for="{{b}}" wx:for-item="item" wx:key="b" class="teacher_item"><text>{{item.a}}</text></view></view><view class="course"><scroll-view scroll-x="{{true}}"><view class="days"><view wx:for="{{c}}" wx:for-item="item" wx:key="c" class="day" bindtap="{{item.d}}" style="{{'color:' + item.e}}"><text>{{item.a}}</text><view>{{item.b}}</view></view></view></scroll-view><view class="times"><view class="time_list"><view wx:for="{{d}}" wx:for-item="item" wx:key="c" class="{{['day', item.d && 'disable', item.e && 'active']}}" style="{{'color:' + item.f}}" bindtap="{{item.g}}"><text>{{item.a}}</text><view>{{item.b}}</view></view></view></view></view><uni-popup class="r" u-s="{{['d']}}" u-r="outcomePopup" u-i="46f39ab6-0" bind:__l="__l"><view class="outcome_popup_layout"><view class="outcome_title"> 预约成功 </view><view wx:for="{{e}}" wx:for-item="item" wx:key="b" class="outcome_text"> 你已经预约{{item.a}}直播主持课程 </view><button class="outcome_button" bindtap="{{f}}">确认</button></view></uni-popup><button bindtap="{{h}}" class="confirm_button">确认预约</button></view>
+<view class="reservation_layout"><view class="header_title"><view class="left"><view class="title">{{a}}</view><view class="subtitle">{{b}}</view></view><view class="right"><image src="{{c}}" class="image" mode=""></image></view></view><view class="teacher_list"><view wx:for="{{d}}" wx:for-item="item" wx:key="b" bindtap="{{item.c}}" class="{{['teacher_item', item.d]}}"><text>{{item.a}}</text></view></view><view class="course"><scroll-view scroll-x><view class="days"><view wx:for="{{e}}" wx:for-item="item" wx:key="c" bindtap="{{item.d}}" class="{{['day', item.e && 'borderb']}}" style="{{'color:' + item.f}}"><text>{{item.a}}</text><view>{{item.b}}</view></view></view></scroll-view><view class="times"><view class="time_list"><view wx:for="{{f}}" wx:for-item="item" wx:key="d" class="{{['day', item.e && 'disable', item.f && 'active']}}" style="{{'color:' + item.g + ';' + ('background-color:' + item.h)}}" bindtap="{{item.i}}"><text>{{item.a}}</text><view>{{item.b}}</view><view>{{item.c}}</view></view></view></view></view><view class=""> 预约时间:{{g}}</view><button bindtap="{{h}}" class="confirm_button">确认预约</button><uni-popup wx:if="{{l}}" class="r" u-s="{{['d']}}" u-r="outcomePopup" u-i="46f39ab6-0" bind:__l="__l" u-p="{{l}}"><view class="outcome_popup_layout"><view class="outcome_title"> 预约成功 </view><view class="outcome_text"> 你已经预约{{i}}直播主持课程 </view><button class="outcome_button" bindtap="{{j}}">确认</button></view></uni-popup></view>

+ 21 - 8
jiaoyu_mp/unpackage/dist/dev/mp-weixin/pagesA/course/reservation.wxss

@@ -44,9 +44,21 @@
   border-radius: 20rpx;
   text-align: center;
 }
+.reservation_layout .teacher_list .teacher_item.active {
+  color: #51bf81;
+  border: 2rpx solid #51bf81;
+}
 .reservation_layout .course {
   width: 690rpx;
-  border: 2rpx solid;
+  margin: 0rpx auto;
+}
+.reservation_layout .course scroll-view {
+  width: 100%;
+  white-space: nowrap;
+  height: 75px;
+  background-color: #fff;
+  position: relative;
+  padding-top: 10rpx;
 }
 .reservation_layout .course .days {
   display: flex;
@@ -57,17 +69,19 @@
   flex-direction: column;
   justify-content: center;
   align-items: center;
-  width: 115rpx;
+  margin: 0rpx 10rpx;
   height: 115rpx;
 }
-.reservation_layout .course .times {
-  border: 2rpx solid;
+.reservation_layout .course .days .day text {
+  margin: 10rpx 0rpx;
+}
+.reservation_layout .course .days .day.borderb {
+  border-bottom: 2px solid #51bf81;
 }
 .reservation_layout .course .times .time_list {
   display: flex;
   flex-wrap: wrap;
   background-color: #ffffff;
-  border: 2rpx solid;
 }
 .reservation_layout .course .times .time_list .time {
   display: inline-flex;
@@ -75,7 +89,6 @@
   align-items: center;
   width: 115rpx;
   height: 115rpx;
-  border: 2rpx solid;
 }
 .reservation_layout .course .times .time_list .day {
   display: inline-flex;
@@ -84,8 +97,8 @@
   align-items: center;
   width: 115rpx;
   height: 115rpx;
-  background-color: #868686;
-  margin: 5rpx;
+  background-color: #f3f3f3;
+  margin: 10rpx;
 }
 .reservation_layout .confirm_button {
   font-size: 40rpx;

+ 5 - 5
jiaoyu_mp/unpackage/dist/dev/mp-weixin/project.private.config.json

@@ -8,15 +8,15 @@
     "miniprogram": {
       "list": [
         {
-          "name": "pagesA/course/index",
-          "pathName": "pages/index/index",
-          "query": "",
+          "name": "pages/product/index",
+          "pathName": "pagesA/course/reservation",
+          "query": "orders_product_id=undefinedcourse_id",
           "launchMode": "default",
           "scene": null
         },
         {
-          "name": "pages/product/index",
-          "pathName": "pages/score/orders",
+          "name": "pagesA/course/index",
+          "pathName": "pages/index/index",
           "query": "",
           "launchMode": "default",
           "scene": null