Sfoglia il codice sorgente

feat:明日预约BUG修改

zhanghui 2 anni fa
parent
commit
ba649fcd95
1 ha cambiato i file con 85 aggiunte e 34 eliminazioni
  1. 85 34
      orderPages/bookService/index.vue

+ 85 - 34
orderPages/bookService/index.vue

@@ -260,6 +260,19 @@
 					})
 					return
 				}
+
+				let flag = false
+				this.orderParam.childService.forEach(i=>{
+					if (!i.serviceStartTime || i.serviceStartTime == ''){
+						uni.$u.toast('有服务对象没有选择服务时段')
+						flag=true
+						return
+					}
+				})
+				if (flag){
+					return;
+				}
+
 				uni.requestSubscribeMessage({
 					tmplIds: this.templateId,
 					success: (res) =>{
@@ -416,17 +429,35 @@
 						date: this.periodDate.label,
 						storeId:this.store.storeId
 					}).then(res => {
+						item.select = !item.select
+
+						let selectServiceObjectList = this.orderParam.childService
+						let periodTimeList = res.data.data
+
 						if (!res.data.data || res.data.data.length==0){
-							uni.showToast({
-								icon: 'none',
-								duration: 2000,
-								title: '暂无可预约排班'
-							});
+							//这里只为了断开技师列表的应用关系
+							let serviceTeacherListStr = JSON.stringify(this.serviceTeacherList)
+							let serviceTeacherList = JSON.parse(serviceTeacherListStr)
+
+							let childService ={
+								serviceObjectId: item.id,
+								facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
+								nickName:item.nickName, //回显需要,不做参数
+								serviceUserId: serviceTeacherList[0].personId,
+								fee:0,//回显需要,不做参数
+								serviceStartTime:  '',
+								serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
+								serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
+							}
+							this.orderParam.childService.push(childService)
+							this.price = 0
+							for (let childService of this.orderParam.childService) {
+								this.price =  this.price * 1 + childService.fee * 1
+								this.price = this.price.toFixed(2)
+							}
 							return
 						}
-						item.select = !item.select
-						let periodTimeList = res.data.data
-						let selectServiceObjectList = this.orderParam.childService
+
 
 
 						//选择服务对象时,获取的排班时间为全部技师的排班时间,所以只要某个时段被选过,那么这个时段的数量-1
@@ -480,7 +511,7 @@
 							nickName:item.nickName, //回显需要,不做参数
 							serviceUserId: serviceTeacherList[0].personId,
 							fee:serviceTeacherList[0].fee,//回显需要,不做参数
-							serviceStartTime: date.label,
+							serviceStartTime:  date.label,
 							serviceTeacherList:serviceTeacherList,//服务人员列表,回显需要,不做参数
 							serviceTimeList:periodTimeList//服务时段列表,回显需要,不做参数
 						}
@@ -508,35 +539,52 @@
 					storeId:this.store.storeId
 				}).then(res => {
 					let serviceTimeList = res.data.data
-					let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
-							(selectServiceObject.serviceUserId === items[index1].personId
-							&& selectServiceObject.serviceObjectId !== this.orderParam.childService[index].serviceObjectId)
-							|| selectServiceObject.serviceUserId === -1
-					)
-					selectServiceObjectList.forEach(selectServiceObject =>{
-						serviceTimeList.forEach(periodTime =>{
-							if (selectServiceObject.serviceStartTime === periodTime.label ){
-								if (selectServiceObject.serviceUserId === -1){
-									selectServiceObject.serviceTimeList.forEach(t=>{
-										if (t.label == periodTime.label && t.total === 1){
-											periodTime.total = periodTime.total - 1
-										}
-									})
-								}else {
-									periodTime.total = periodTime.total - 1
+
+					if (!serviceTimeList || serviceTimeList.length == 0){
+						this.orderParam.childService[index].serviceStartTime = ''
+						this.orderParam.childService[index].periodTimeList = []
+						this.orderParam.childService[index].fee = 0
+						this.price = 0
+						for (let childService of this.orderParam.childService) {
+							this.price =  this.price * 1 + childService.fee * 1
+							this.price = this.price.toFixed(2)
+						}
+						console.log(this.price)
+						this.$forceUpdate()
+					}else {
+						let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
+								(selectServiceObject.serviceUserId === items[index1].personId
+										&& selectServiceObject.serviceObjectId !== this.orderParam.childService[index].serviceObjectId)
+								|| selectServiceObject.serviceUserId === -1
+						)
+						selectServiceObjectList.forEach(selectServiceObject =>{
+							serviceTimeList.forEach(periodTime =>{
+								if (selectServiceObject.serviceStartTime === periodTime.label ){
+									if (selectServiceObject.serviceUserId === -1){
+										selectServiceObject.serviceTimeList.forEach(t=>{
+											if (t.label == periodTime.label && t.total === 1){
+												periodTime.total = periodTime.total - 1
+											}
+										})
+									}else {
+										periodTime.total = periodTime.total - 1
+									}
 								}
-							}
+							})
 						})
-					})
-					for (const time of serviceTimeList) {
-						if (time.total>0){
-							time.select = true
-							break
+						for (const time of serviceTimeList) {
+							if (time.total>0){
+								time.select = true
+								break
+							}
 						}
+						serviceTimeList[0].select = true
+						this.orderParam.childService[index].serviceStartTime= serviceTimeList[0].label,
+								this.orderParam.childService[index].serviceTimeList= serviceTimeList
 					}
-					serviceTimeList[0].select = true
-					this.orderParam.childService[index].serviceStartTime= serviceTimeList[0].label,
-					this.orderParam.childService[index].serviceTimeList= serviceTimeList
+
+
+
 				})
 				this.price = 0
 				for (let childService of this.orderParam.childService) {
@@ -627,6 +675,9 @@
 						uni.$u.toast('请选择服务对象')
 						return;
 					}
+
+
+
 					if (this.requestStatus) {
 						return;
 					}