Преглед изворни кода

用户订单时间禁用修改/支付交互

贾宇博 пре 3 недеља
родитељ
комит
72088bc960

+ 34 - 47
components/its-calendar/its-calendar.vue

@@ -8,16 +8,18 @@
 					<view class="day_x_b">{{item.days}}</view>
 				</view>
 			</view>
-			<view scroll-y class="calendar_time">
-			
-				<view class="time_x" :class="host_index == item?.timeStamp ? 'time_x_sty' : ''"
-					v-for="(item, index) in timeHostArr[day_index]" :key="index"
-					@click="(nowTimes < item?.timeStamp && item.hasReservation !== 1) ? hosts(item) : ''"
-					:style="{'color': ((nowTimes > item?.timeStamp || item.hasReservation === 1) ? '#999999' : '')}">
+			<view class="calendar_time">
+				<view class="time_x" :class="{
+		      'time_x_sty': host_index == item?.timeStamp, 
+		      'disabled-time': isTimeDisabled(item?.timeStamp) // 新增: 添加禁用类
+		    }" v-for="(item, index) in timeHostArr[day_index]" :key="index"
+					@click="(nowTimes < item?.timeStamp && item.hasReservation !== 1 && !isTimeDisabled(item?.timeStamp)) ? hosts(item) : ''"
+					:style="{
+		      'color': ((nowTimes > item?.timeStamp || item.hasReservation === 1 || isTimeDisabled(item?.timeStamp)) ? '#999999' : '')
+		    }">
 					<text>{{item?.hours}}</text>
 					<text v-if="item.hasReservation === 1" class="hasRe-text">已预约</text>
-
-					</view>
+				</view>
 			</view>
 		</view>
 		<!-- <view class="sub" @click="sub()">
@@ -33,12 +35,12 @@
 				type: Array,
 				default: () => []
 			},
-			
-			timeHostArr:{
+
+			timeHostArr: {
 				type: Array,
 				default: () => []
 			},
-		
+
 		},
 		data() {
 			return {
@@ -48,13 +50,14 @@
 				host_index: '',
 				host_All: [],
 				nowTimes: '',
-				frequency:'',
+				frequency: '',
+				disableAfterTime: null, //记录当前时间
 			}
 		},
 		watch: {
 			timeArr: {
 				handler(newVal) {
-					
+
 					let dateArr = newVal.map(item => {
 						let day = new Date(item)
 						const daysOfWeek = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
@@ -63,38 +66,7 @@
 							days: item.slice(5)
 						}
 					})
-					
 					this.dayArr = dateArr
-					
-					
-					
-					// let timeArr = []
-					// for (let i = 0; i < 4; i++) {
-					// 	// let as = new Date(new Date().toLocaleDateString()).getTime() / 1000
-					// 	let as = new Date(new Date().toLocaleDateString()).getTime() / 1000 + i * 60 * 60 * 24
-					// 	let staTime = 9 * 60 * 60 + as
-					// 	let endTime = 18 * 60 * 60 + as
-					// 	let int = 15 * 60
-					// 	let timeArr_s = []
-						
-					// 	console.log(staTime, '>>>>staTime99999');
-					// 	for (staTime; staTime < endTime - int; staTime + int) {
-					// 		console.log(staTime, '>>>>>staTime');
-					// 		staTime = staTime + int
-					// 		let hours = this.times(staTime)
-					// 		let asb = {
-					// 			hours,
-					// 			timeStamp: staTime
-					// 		}
-					// 		timeArr_s.push(asb)
-					// 	}
-						
-					// 	timeArr.push(timeArr_s)
-					// }
-					
-					// console.log(timeArr, '>>>>>>>999>');
-					// this.hostArr = timeArr
-					
 				},
 				immediate: true
 			}
@@ -111,8 +83,12 @@
 				this.host_All = e
 				this.host_index = e.timeStamp
 				this.host_All.yearToDate = this.timeArr[this.day_index]
+				this.disableAfterTime = e.timeStamp //记录当前选择时间戳
 				this.$emit('getByTime', this.host_All)
 			},
+			isTimeDisabled(timeStamp) {
+				return this.disableAfterTime && timeStamp > this.disableAfterTime;
+			},
 			// 点击立即预约
 			sub() {
 				if (this.host_index == '') {
@@ -140,7 +116,7 @@
 				m = m < 10 ? ('0' + m) : m; //分钟补0
 				return h + ':' + m
 			},
-			time(data, type){
+			time(data, type) {
 				let date = new Date(data * 1000);
 				//时间戳为10位需*1000,时间戳为13位的话不需乘1000
 				let y = date.getFullYear();
@@ -216,9 +192,10 @@
 			margin: 10rpx 0;
 			font-size: 30rpx;
 			color: #333333;
-			
+
 			display: flex;
 			flex-direction: column;
+
 			.hasRe-text {
 				font-size: 20rpx;
 				color: #999999;
@@ -243,4 +220,14 @@
 		font-size: 36rpx;
 		background-color: #FE3B3C;
 	}
-</style>
+
+
+	.disabled-time {
+		background-color: #f2f2f2;
+		/* 灰色背景 */
+		color: #999999;
+		/* 灰色文字 */
+		pointer-events: none;
+		/* 禁用点击事件 */
+	}
+</style>

+ 29 - 35
pages_home/pages/Volunteerside/goodsDetails.vue

@@ -87,7 +87,7 @@
 				<view class="Wrap-detils-btn">
 					<up-button type="primary" shape="circle" :customStyle="wrapqx" @click="handlCancel">取消</up-button>
 					<up-button type="error" shape="circle" :customStyle="wrapqx" @click="handleBuy">
-						购买¥{{ computeMoney }}
+						预约¥{{ computeMoney }}
 					</up-button>
 				</view>
 			</up-popup>
@@ -130,18 +130,7 @@
 					</view>
 				</up-cell-group>
 			</view>
-			<view class="Wrap-detils-btn">
-				<up-button type="primary" shape="circle" :customStyle="wrapqx" @click="closeSecond">取消</up-button>
-				<up-button type="error" shape="circle" :customStyle="wrapqx" @click="handleSecond">
-					购买¥{{ computeMoney }}
-				</up-button>
-			</view>
-
-		</up-popup>
-
-
 
-		<up-popup v-model:show="showSum">
 			<view class="Wrap-Payment">
 				<!-- 支付金额 -->
 				<view class="payment-header">
@@ -187,14 +176,19 @@
 					我同意购买守则,取消政策和退款政策,我也同意支付以下所示的总金额(含服务费)。
 				</view>
 
-				<!-- 确认按钮 -->
-				<view class="confirm-button">
-					<up-button type="primary" :text="`确认购买 · ¥${computeMoney}`"
-						@click="handlConfiRmpurchase"></up-button>
-				</view>
+
+			</view>
+			<view class="Wrap-detils-btn">
+				<up-button type="primary" shape="circle" :customStyle="wrapqx" @click="closeSecond">取消</up-button>
+				<up-button type="error" shape="circle" :customStyle="wrapqx" @click="handlConfiRmpurchase">
+					购买¥{{ computeMoney }}
+				</up-button>
 			</view>
+
 		</up-popup>
 
+
+
 		<view v-if="addressFlag" class="box">
 			<addressComponent :modelValue="addressFlag" @update:modelValue="val => addressFlag = val"
 				:addressInfo="addressInfo" @update:addressInfo="handleAddressUpdate"></addressComponent>
@@ -271,33 +265,20 @@
 		// 关闭逻辑,设置 show 为 false  
 		show.value = false;
 	}
-	
+
 	// 第一个弹框逻辑
 	const handleBuy = () => {
 		show.value = false; // 关闭第一个弹框
 		showSecond.value = true; // 打开第二个弹框
 	};
 
-	
+
 	// 第二层弹框取消
 	function closeSecond() {
 		// 关闭逻辑,设置 show 为 false  
 		showSecond.value = false;
 		show.value = true; // 打开第一个弹框
 	}
-	
-	// 第二层弹框打开第三层
-	function handleSecond() {
-		showSum.value = true;
-	}
-	
-	// 第三层弹框
-	// function openSum() {
-	// 	// 打开逻辑,比如设置 show 为 true  
-	// 	showSum.value = true;
-	// }
-
-	
 
 	const handlCancel = () => {
 		show.value = false; // 关闭第一个弹框
@@ -527,12 +508,25 @@
 		try {
 			const res = await ordersCreateOrder(orderData);
 			if (res.code == 200) {
-				uni.reLaunch({
-					url: '/pages/index'
+				uni.showToast({
+					title: '支付成功',
+					icon: 'success', // 或者 'none'
+					duration: 1500, // 显示时间,单位毫秒,默认1500
+					mask: true, // 是否显示透明蒙层,防止触摸穿透,默认false
 				});
+				setTimeout(() => {
+					uni.reLaunch({
+						url: '/pages/index'
+					});
+				}, 1500)
 			}
 		} catch (error) {
-			console.error('支付失败', error);
+			uni.showToast({
+				title: '支付失败',
+				icon: 'success', // 或者 'none'
+				duration: 1500, // 显示时间,单位毫秒,默认1500
+				mask: true, // 是否显示透明蒙层,防止触摸穿透,默认false
+			});
 		}
 	};
 

+ 1 - 1
pages_mine/pages/setupUser/Address.vue

@@ -40,7 +40,7 @@
 		params.forEach(async (obj) => {
 			const res = await useraDdressData(obj)
 			if (res.code == 200) {
-				wx.showToast({
+				uni.showToast({
 					title: '新增成功',
 					icon: 'success', // 或者 'none'
 					duration: 1500, // 显示时间,单位毫秒,默认1500