Pārlūkot izejas kodu

用户端订单金额修改

贾宇博 4 mēneši atpakaļ
vecāks
revīzija
c7c0709cf8
1 mainītis faili ar 80 papildinājumiem un 77 dzēšanām
  1. 80 77
      pages/goodsDetails/goodsDetails.vue

+ 80 - 77
pages/goodsDetails/goodsDetails.vue

@@ -13,6 +13,7 @@
 							<view class="info-item">服务项目:{{listData.projectName}}</view>
 							<view v-if="serviceSubjectName != null" class="info-item">类别:{{ listData.projectTypeName }}
 							</view>
+							<view class="Telephone">服务时长:{{listData.businessDuration}}</view>
 							<view class="Telephone">科目:{{listData.serviceSubjectName}}</view>
 							<view class="Telephone">电话:{{listData.phonenumber}}</view>
 						</view>
@@ -30,7 +31,8 @@
 			<up-card title="证书" :thumb="thumb" :head-style="{ height: '80rpx', padding: '20rpx',}">
 				<template #body>
 					<view class="certificate">
-						<image  v-for="item in certificationPictures" :key="item" :src="item" mode="" style="width: 100%;" class="certificate-img"></image>
+						<image v-for="item in certificationPictures" :key="item" :src="item" mode=""
+							style="width: 100%;" class="certificate-img"></image>
 					</view>
 				</template>
 			</up-card>
@@ -59,8 +61,9 @@
 				<up-divider></up-divider>
 				<view class="Wrap-content1">
 					<up-avatar :src="src"></up-avatar>
-					<text style="margin-top: 15rpx;">¥{{onePrice}}</text>
+					<text style="margin-top: 15rpx;">¥{{listData.businessPrice}}</text>
 				</view>
+				<!--  -->
 				<view class="Wrap-info">
 					<text style="margin-left: 10rpx;">服务类别:</text>
 					<up-text type="info" text="家庭教育"></up-text>
@@ -173,7 +176,7 @@
 
 
 	const src = ref('http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg')
-	const onePrice = ref(400)
+	const businessPrice = ref() //价格
 	const volunteerId = ref(''); // 存储志愿者ID
 	const serviceCategory = ref('') //存储大类别
 	const businessManagementId = ref('') //具体分类id
@@ -194,11 +197,11 @@
 	const remark = ref('') //备注
 
 	const computeMoney = computed(() => {
-		return totalTimes.value * onePrice.value
+		return totalTimes.value * businessPrice.value
 	})
 
-	const certificationPictures =computed(()=>{
-		if(listData.value.certificationPicture){
+	const certificationPictures = computed(() => {
+		if (listData.value.certificationPicture) {
 			return listData.value.certificationPicture.split(',')
 		}
 		return []
@@ -299,26 +302,23 @@
 
 	// 获取传递的参数
 	onLoad(async (options) => {
-		// 解析传递过来的参数对象
 		const params = JSON.parse(options.params);
 		const {
 			volunteerId: id,
 			serviceCategory: categoy,
 			businessManagementId: manage
 		} = params;
-
-		// 将volunteerId赋值给响应式变量
 		volunteerId.value = id;
-		serviceCategory.value = categoy
-		// 使用传递的参数调用 API
+		serviceCategory.value = categoy;
+
 		const res = await getDetailsvolunteerId({
 			volunteerId: id,
 			serviceCategory: categoy,
 			businessManagementId: manage,
 		});
 
-		// 将获取到的结果赋值给响应式变量
 		listData.value = res.data || {};
+		businessPrice.value = listData.value.businessPrice || 0;
 	});
 
 
@@ -326,81 +326,82 @@
 	const getListTime = async () => {
 		const params = {
 			volunteerId: Number(volunteerId.value),
+		};
+		const res = await volunteerwork(params);
+
+		if (res.data && res.data.length > 0) {
+			doorToDoorTimeArr.value = res.data;
+			const newRes = [res.data[0], res.data[res.data.length - 1]];
+			doorToDoorTime.value = newRes;
+			startDisabled.value = doorToDoorTime.value[0];
+			endDisabled.value = doorToDoorTime.value[1];
+
+			// 默认加载第一个日期的排班时间
+			getByDate(res.data[0]);
+		} else {
+			console.error('接口返回的日期范围为空');
+			doorToDoorTimeArr.value = [];
+			timeHostArr.value = []; // 清空时间段
 		}
-		const res = await volunteerwork(params)
-		if (res.data) {
-			console.log(res.data, '>>>>>res.data333');
-			doorToDoorTimeArr.value = res.data
-			const newRes = [res.data[0], res.data[res.data.length - 1]]
-			doorToDoorTime.value = newRes
-			startDisabled.value = doorToDoorTime.value[0]
-			endDisabled.value = doorToDoorTime.value[1]
-		}
-	}
+	};
 
 
 	// 获取志愿者排班时间
 	const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
-		console.log(date, '获取日期2')
+		// 检查日期是否为空
+		if (!date) {
+			console.error('日期为空,跳过获取排班时间');
+			return;
+		}
+
 		if (!volunteerId.value) {
 			console.error('volunteerId 为空');
 			return;
 		}
+
 		const params = {
 			volunteerId: volunteerId.value,
-			date
+			date,
 		};
+
 		try {
 			const res = await volunteergetTimesByDate(params);
-			const TArr = res.data.map(item => {
-				return {
-					...item,
-					hours: item.reservationTime,
-					timeStamp: new Date(date + ' ' + item.reservationTime).getTime() / 1000
-				}
-			})
-			let arr = []
-			doorToDoorTimeArr.value.forEach(() => {
-				arr.push(TArr)
-			})
-			timeHostArr.value = arr
+			const TArr = res.data.map((item) => ({
+				...item,
+				hours: item.reservationTime,
+				timeStamp: new Date(`${date} ${item.reservationTime}`).getTime() / 1000,
+			}));
+
+			// 如果 doorToDoorTimeArr.value 为空,直接返回
+			if (!doorToDoorTimeArr.value.length) {
+				console.error('可选的日期范围为空');
+				return;
+			}
 
+			// 填充时间段数组
+			timeHostArr.value = Array(doorToDoorTimeArr.value.length).fill(TArr);
 		} catch (error) {
 			console.error('获取排班时间失败:', error);
 		}
 	};
-
-	// 点击具体时间触发
-	// const getByTime = (timeObj) => {
-	// 	 // 检查 timeObj 是否已经被点击过
-	// 	    if (timeObj.clicked) {
-	// 	        console.log('>>>>>> 已经点击过此时间');
-	// 	        return;  // 如果已经点击过,就直接返回,后续操作不执行
-	// 	    }
-	// 	console.log('>>>>>>触发111');
-	// 	currentDate.value.push(timeObj.yearToDate)
-	// 	currentTime.value = timeObj.hours
-	// 	totalTimes.value += 1 // 记录点击次数
-	// 	  // 标记该时间已点击
-	// 	    timeObj.clicked = true;
-	// }
+	
 	const getByTime = (timeObj) => {
-	  if (timeObj.clicked) {
-	    console.log('>>>>>> 已经点击过此时间');
-	    return;
-	  }
-	  
-	  // 标记为已点击
-	  timeObj.clicked = true;
-	  
-	  // 添加到已选时间数组
-	  selectedTimes.value.push({
-	    date: timeObj.yearToDate,
-	    time: timeObj.hours,
-	    timestamp: timeObj.timeStamp
-	  });
-	  
-	  totalTimes.value = selectedTimes.value.length; // 更新点击次数
+		if (timeObj.clicked) {
+			console.log('>>>>>> 已经点击过此时间');
+			return;
+		}
+
+		// 标记为已点击
+		timeObj.clicked = true;
+
+		// 添加到已选时间数组
+		selectedTimes.value.push({
+			date: timeObj.yearToDate,
+			time: timeObj.hours,
+			timestamp: timeObj.timeStamp
+		});
+
+		totalTimes.value = selectedTimes.value.length; // 更新点击次数
 	}
 
 	// 立即购买显示时执行
@@ -415,7 +416,7 @@
 		// 定义要发送的数据
 		const orderData = {
 			orders: {
-				serviceOnePrice: onePrice.value, //需要传400死值返回给后端
+				serviceOnePrice: businessPrice.value,
 				serviceTotalPrice: computeMoney.value, //需要传获取到的总价
 				serviceCategory: serviceCategory.value, //大类别参数
 				totalTimes: totalTimes.value, //点击的次数
@@ -442,14 +443,14 @@
 		// 	})
 		// })
 		// 转换所有选择的时间
-		  selectedTimes.value.forEach(item => {
-		    orderData.workDateList.push({
-		      workDate: item.date,
-		      workStartTime: item.time
-		    });
-		  });
-		
-		
+		selectedTimes.value.forEach(item => {
+			orderData.workDateList.push({
+				workDate: item.date,
+				workStartTime: item.time
+			});
+		});
+
+
 
 
 		try {
@@ -467,7 +468,7 @@
 
 	onMounted(async () => {
 		await getListTime()
-		getByDate()
+		// getByDate()
 	})
 </script>
 
@@ -670,11 +671,13 @@
 	.confirm-button {
 		margin-top: 40rpx;
 	}
+
 	.certificate {
 		display: flex;
 		flex-direction: column;
 
 	}
+
 	.certificate-img {
 		margin-bottom: 24rpx;
 	}