zhanghui 2 lat temu
rodzic
commit
d982b53673

+ 7 - 1
components/pay/pay.vue

@@ -90,6 +90,12 @@
 				default () {
 					return true
 				}
+			},
+			orderNo: {
+				type: String,
+				default () {
+					return ''
+				}
 			}
 		},
 		data() {
@@ -135,7 +141,7 @@
 			wechatPay() {
 				// 发起微信支付
 				this.$api.wechatPay({
-					orderNo: this.subOrderNo
+					orderNo: this.orderNo
 				}).then((res) => {
 					var param = res.data.data;
 					uni.requestPayment({

+ 11 - 8
orderPages/bookService/components/chooseServiceTeacher.vue

@@ -7,8 +7,8 @@
 				</view>
 
 				<scroll-view class="scrollY" scroll-y>
-					<view class="serviceTeacherView" v-for="(item,index) in workPersonList"  @click="selectworkPerson(index)">
-						<view v-if="item.personId === -1" class="serviceTeacher  flex-col justify-center" :class="{selectBack: index == selectIndex}">
+					<view class="serviceTeacherView" v-for="(item,index) in workPersonList"  @click="selectworkPerson(item,index)">
+						<view v-if="item.personId === -1" class="serviceTeacher  flex-col justify-center" :class="{selectBack: item.personId == serviceUserId}">
 							<view class="flex-row">
 								<text class="teacherName">{{item.personName}} </text>
 								<u-icon name="rmb-circle" color="#666666"></u-icon>
@@ -17,7 +17,7 @@
 
 						</view>
 
-						<view v-else class="serviceTeacher1 flex-row" :class="{selectBack: index == selectIndex}">
+						<view v-else class="serviceTeacher1 flex-row" :class="{selectBack: item.personId == serviceUserId}">
 							<image class="teacherImg" src="/static/order/nvren.png"></image>
 							<view class="flex-col justify-around teacherR ">
 								<view class="flex-row">
@@ -36,7 +36,7 @@
 								</view>
 							</view>
 						</view>
-						<view class="serobV" v-if="index == selectIndex">
+						<view class="serobV" v-if="item.personId == serviceUserId">
 							<image class="serobVicon" src="/static/order/ud20.png"></image>
 						</view>
 					</view>
@@ -79,7 +79,8 @@
 		},
 		data() {
 			return {
-				selectIndex:0,
+				serviceUserId:'',
+				selectIndex:'',
 				workPersonList: []
 			}
 		},
@@ -94,11 +95,13 @@
 				this.$refs.chooseServiceTeacherPopup.close()
 			},
 
-			selectworkPerson(e){
-				this.selectIndex = e
+			selectworkPerson(e,index){
+				this.serviceUserId = e.personId
+				this.selectIndex = index
 			},
 
-			openPopup() {
+			openPopup(serviceUserId) {
+				this.serviceUserId = serviceUserId
 				this.$refs.chooseServiceTeacherPopup.open()
 				this.getServicePerson()
 

+ 30 - 24
orderPages/bookService/components/chooseServiceTime.vue

@@ -10,8 +10,8 @@
 				<scroll-view class="scrollY" scroll-y>
 
 					<u-grid :border="false" col="5">
-						<u-grid-item v-for="(item,index) in periodDateList" :key="index" @click="selectPeriod(index)">
-							<view class="flex-col justify-center timeItem" :class="{selectBack: index == selectIndex}">
+						<u-grid-item v-for="(item,index) in periodDateList" :key="index" @click="selectPeriod(item,index)">
+							<view class="flex-col justify-center timeItem" :class="{selectBack: item.label == label}">
 								<view class="flex-row justify-center">
 									<text class="time">{{item.label}}</text>
 								</view>
@@ -40,22 +40,9 @@
 <script>
 	export default {
 		name: 'chooseServiceTime',
-		props: {
-			personId: {
-				type: String,
-				default () {
-					return ''
-				}
-			},
-			date: {
-				type: String,
-				default () {
-					return ''
-				}
-			}
-		},
 		data() {
 			return {
+				label:'',
 				selectIndex:0,
 				periodDateList: []
 			}
@@ -71,22 +58,41 @@
 				this.$refs.chooseServiceTimePopup.close()
 			},
 
-			selectPeriod(e){
-				this.selectIndex = e
+			selectPeriod(e,index){
+				this.label = e.label
+				this.selectIndex = index
 			},
 
-			openPopup() {
+			openPopup(personId, date,storeId,childService,selectChildService,label) {
 				this.$refs.chooseServiceTimePopup.open()
-				this.getServiceTime()
+				this.label =label
+				this.getServiceTime(personId, date,storeId,childService,selectChildService)
 			},
 
 			//获取门店排班时段
-			getServiceTime(storeId, date) {
+			getServiceTime(personId, date,storeId,childService,selectChildService) {
 				this.$api.getServicePersonTime({
-					personId: this.personId,
-					date: this.date
+					personId:personId,
+					date: date,
+					storeId:storeId
 				}).then(res => {
-					this.periodDateList = res.data.data
+					let periodTimeList = res.data.data
+					let selectServiceObjectList = childService.filter(selectServiceObject =>
+							(selectServiceObject.serviceUserId === personId
+							&& selectServiceObject.serviceObjectId !== childService[selectChildService].serviceObjectId)
+							|| selectServiceObject.serviceUserId === -1
+
+				)
+					selectServiceObjectList.forEach(selectServiceObject =>{
+						periodTimeList.forEach(periodTime =>{
+							if (selectServiceObject.serviceStartTime === periodTime.label ){
+								periodTime.total = periodTime.total - 1
+							}
+						})
+					})
+					periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
+					console.log(periodTimeList)
+					this.periodDateList = periodTimeList
 					// if (this.periodTimeList.length === 0) {
 					// 	uni.$u.toast('暂无排班时段')
 					// }

+ 127 - 64
orderPages/bookService/index.vue

@@ -54,7 +54,7 @@
 				<view class="groupItemKey">
 					<text>服务人员</text>
 				</view>
-				<view class="flex-row justify-between groupItemContent" @click="chooseServiceTeacher(index)">
+				<view class="flex-row justify-between groupItemContent" @click="chooseServiceTeacher(index,item.serviceUserId)">
 					<text>{{ item.personName || '请选择服务人员' }}</text>
 					<u-icon name="arrow-right" color="#666" size="18"></u-icon>
 				</view>
@@ -103,8 +103,8 @@
 			</view>
 		</view>
 		<chooseServiceTeacher ref="chooseServiceTeacher" :storeId="store.storeId" :date="date" @getWorkPerson="getWorkPerson"></chooseServiceTeacher>
-		<chooseServiceTime ref="chooseServiceTime" :personId="personId" :date="date" @getPeriodDate="getPeriodDate"></chooseServiceTime>
-		<myPay ref="myPay" :blPay="false"></myPay>
+		<chooseServiceTime ref="chooseServiceTime"  @getPeriodDate="getPeriodDate"></chooseServiceTime>
+		<myPay ref="myPay" :blPay="false" :orderNo="subOrderNo"></myPay>
 	</view>
 </template>
 
@@ -120,6 +120,7 @@
 		},
 		data() {
 			return {
+				selectIndex:0,
 				requestStatus:false,
 				personId:'',
 				date:'',
@@ -144,18 +145,18 @@
 					serviceAttribute: 2,
 					serviceStoreId: '',
 					remark: '',
+					serviceDate:'',
 					childService:[
 							{
 								periodDate:'',//回显需要,不做参数
-						serviceObjectId: '',
-						facePhotoUrl:'', //回显需要,不做参数
-						nickName:'', //回显需要,不做参数
-						serviceUserId: '',
-						personName:'',//回显需要,不做参数
-					    fee:'',//回显需要,不做参数
-						serviceStartTime: '',
-						timeRangeId: ''
-					}
+								serviceObjectId: '',
+								facePhotoUrl:'', //回显需要,不做参数
+								nickName:'', //回显需要,不做参数
+								serviceUserId: '',
+								personName:'',//回显需要,不做参数
+								fee:'',//回显需要,不做参数
+								serviceStartTime: ''
+						}
 					]
 				}
 			}
@@ -185,6 +186,7 @@
 				}).then(res => {
 					this.periodDate = res.data.data[0]
 					this.date=this.periodDate.label
+					this.orderParam.serviceDate=this.periodDate.label
 
 					if (this.orderParam.childService.length === 1) {
 						this.orderParam.childService[0].periodDate = this.periodDate.label
@@ -220,41 +222,62 @@
 			//获取门店排班时段
 			getServiceTime(date,personId) {
 				this.$api.getServicePersonTime({
-					personId: personId === -1 ? '' : personId,
+					personId: personId,
 					date: date,
+					storeId:this.store.storeId
 				}).then(res => {
 					this.periodTime = res.data.data[0]
 					if (this.orderParam.childService.length === 1) {
 						this.orderParam.childService[0].serviceStartTime = res.data.data[0].label
-						this.orderParam.childService[0].timeRangeId = res.data.data[0].id
 					}
 				})
 			},
 
 			selectServiceObject(item) {
+				this.subOrderNo=''
 				console.log(item)
 				if (item.select) {
 					this.orderParam.childService = this.orderParam.childService.filter(selectServiceObject =>
 						selectServiceObject.serviceObjectId !== item.id)
 				} else {
-					let childService ={
-						periodDate: this.periodDate.label,
-						serviceObjectId: item.id,
-						facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
-						nickName:item.nickName, //回显需要,不做参数
-						serviceUserId: this.serviceTeacher.personId ,
-						personName:this.serviceTeacher.personName ,//回显需要,不做参数
-						fee:this.serviceTeacher.fee ,//回显需要,不做参数
-						serviceStartTime: this.periodTime.label ,
-						timeRangeId: this.periodTime.id
-					}
-					this.orderParam.childService.push(childService)
-					for (let childService of this.orderParam.childService) {
-						this.price = 0
-						this.price =  this.price * 1 + childService.fee * 1
-					}
+					this.$api.getServicePersonTime({
+						personId: this.serviceTeacher.personId,
+						date: this.periodDate.label,
+						storeId:this.store.storeId
+					}).then(res => {
+						let periodTimeList = res.data.data
+
+						let selectServiceObjectList = this.orderParam.childService
+
+						selectServiceObjectList.forEach(selectServiceObject =>{
+							periodTimeList.forEach(periodTime =>{
+								if (selectServiceObject.serviceStartTime === periodTime.label ){
+									periodTime.total = periodTime.total - 1
+								}
+							})
+						})
+						periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
+						console.log(periodTimeList)
+						let childService ={
+							periodDate: this.periodDate.label,
+							serviceObjectId: item.id,
+							facePhotoUrl:item.facePhotoUrl, //回显需要,不做参数
+							nickName:item.nickName, //回显需要,不做参数
+							serviceUserId: this.serviceTeacher.personId ,
+							personName:this.serviceTeacher.personName ,//回显需要,不做参数
+							fee:this.serviceTeacher.fee ,//回显需要,不做参数
+							serviceStartTime: periodTimeList[0].label ,
+						}
+						this.orderParam.childService.push(childService)
+
+					})
+
 				}
 				item.select = !item.select
+				this.price = 0
+				for (let childService of this.orderParam.childService) {
+					this.price =  this.price * 1 + childService.fee * 1
+				}
 			},
 
 			// 查询服务对接信息列表
@@ -308,33 +331,60 @@
 
 
 			//选择服务人员
-			chooseServiceTeacher(index) {
+			chooseServiceTeacher(index,serviceUserId) {
 				this.selectIndex = index
-				this.$refs.chooseServiceTeacher.openPopup()
+				this.$refs.chooseServiceTeacher.openPopup(serviceUserId)
 			},
 
 			//选择服务人员
 			getWorkPerson(e) {
-				this.orderParam.childService[this.selectIndex].serviceUserId = e.personId
-				this.orderParam.childService[this.selectIndex].personName = e.personName
-				this.orderParam.childService[this.selectIndex].fee = e.fee
 
-				for (let childService of this.orderParam.childService) {
-					this.price = 0
-					this.price =  this.price * 1 + childService.fee * 1
+				if (e.personId !== this.orderParam.childService[this.selectIndex].serviceUserId){
+					this.subOrderNo=''
+					this.$api.getServicePersonTime({
+						personId: e.personId,
+						date: this.periodDate.label,
+						storeId: this.store.storeId
+					}).then(res => {
+						this.orderParam.childService[this.selectIndex].serviceUserId = e.personId
+						this.orderParam.childService[this.selectIndex].personName = e.personName
+						this.orderParam.childService[this.selectIndex].fee = e.fee
+						this.orderParam.childService[this.selectIndex].serviceStartTime = ''
+						let periodTimeList = res.data.data
+						let selectServiceObjectList = this.orderParam.childService.filter(selectServiceObject =>
+								selectServiceObject.serviceUserId === e.personId
+								|| selectServiceObject.serviceUserId === -1
+						)
+						selectServiceObjectList.forEach(selectServiceObject =>{
+							periodTimeList.forEach(periodTime =>{
+								if (selectServiceObject.serviceStartTime === periodTime.label){
+									periodTime.total = periodTime.total - 1
+								}
+							})
+						})
+						periodTimeList = periodTimeList.filter(periodTime=> periodTime.total>0)
+						this.orderParam.childService[this.selectIndex].serviceStartTime = periodTimeList[0].label
+						this.price = 0
+						for (let childService of this.orderParam.childService) {
+							this.price =  this.price * 1 + childService.fee * 1
+						}
+					})
 				}
-
 			},
 
 			//选择服务时段
 			chooseServiceTime(index) {
 				this.selectIndex = index
-				this.$refs.chooseServiceTime.openPopup()
+				this.$refs.chooseServiceTime.openPopup(this.orderParam.childService[index].serviceUserId,
+						this.periodDate.label,this.store.storeId,this.orderParam.childService,index,this.orderParam.childService[index].serviceStartTime)
 			},
 			//选择服务时段
 			getPeriodDate(e) {
-				this.orderParam.childService[this.selectIndex].serviceStartTime = e.label
-				this.orderParam.childService[this.selectIndex].timeRangeId = e.id
+				if (this.orderParam.childService[this.selectIndex].serviceStartTime !== e.label){
+					this.subOrderNo=''
+					this.orderParam.childService[this.selectIndex].serviceStartTime = e.label
+					this.$set(this.orderParam)
+				}
 			},
 
 			selectChange() {
@@ -353,30 +403,43 @@
 
 			//提交订单
 			commitOrder() {
-				if(!this.selectIcon){
-				  uni.$u.toast('请阅读并同意《预约需知》')
-				  return;
-				}
-
-				if (this.orderParam.childService.length === 0) {
-				  uni.$u.toast('请选择服务对象')
-				  return;
-				}
-				if(this.requestStatus){
-					return;
-				}
-				this.requestStatus=true
-
-				this.$api.commonGeneralOrder(this.orderParam).then(res=>{
-					console.log('++++++++++++++++++订单提交+++++++++++',res)
-					this.orderNo = res.data.data.orderNo
-					this.subOrderNo = res.data.data.subOrderNo
+				if (this.subOrderNo){
 					this.$refs.myPay.openPopup()
-					this.requestStatus=false
-				}).catch(err =>{
-					this.requestStatus=false
-				})
 
+				}else {
+					if (!this.selectIcon) {
+						uni.$u.toast('请阅读并同意《预约需知》')
+						return;
+					}
+
+					if (this.orderParam.childService.length === 0) {
+						uni.$u.toast('请选择服务对象')
+						return;
+					}
+					if (this.requestStatus) {
+						return;
+					}
+					this.requestStatus = true
+
+					this.$api.commonGeneralOrder(this.orderParam).then(res => {
+						console.log('++++++++++++++++++订单提交+++++++++++', res)
+						if (res.data.data.subOrderNo) {
+							this.orderNo = res.data.data.orderNo
+							this.subOrderNo = res.data.data.subOrderNo
+							this.$refs.myPay.openPopup()
+						} else {
+							uni.$u.toast('预约成功')
+							setTimeout(() => {
+								uni.switchTab({
+									url: '/pages/order/index'
+								})
+							}, 1000)
+						}
+						this.requestStatus = false
+					}).catch(err => {
+						this.requestStatus = false
+					})
+				}
 			},