From 17ecbaae8d036bb1f59b1d74b153fa9dfe542f3f Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 27 三月 2025 14:17:36 +0800
Subject: [PATCH] 解决h5访客申请bug

---
 h5/pages/driver/reserved.vue |   99 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 75 insertions(+), 24 deletions(-)

diff --git a/h5/pages/driver/reserved.vue b/h5/pages/driver/reserved.vue
index 3477489..b5ff413 100644
--- a/h5/pages/driver/reserved.vue
+++ b/h5/pages/driver/reserved.vue
@@ -7,17 +7,17 @@
 					<text>*</text>
 					<text>鍏ュ洯鍘熷洜</text>
 				</view>
-				<view class="value" @click="showReason = true">
-					<text class="mr6" :style="{ color: param.inReason ? '#000000' : '#999999' }">{{ param.inReason ? param.inReason : '璇烽�夋嫨' }}</text>
+				<view class="value" @click="reasonClick">
+					<text class="mr6" :class="{gray: param.id}" :style="{ color: param.inReason ? '#000000' : '#999999' }">{{ param.inReason ? param.inReason : '璇烽�夋嫨' }}</text>
 					<u-icon name="arrow-right" color="#CCCCCC" size="16"></u-icon>
 				</view>
 			</view>
 			<view class="line">
 				<view class="label">
 					<text>*</text>
-					<text>鍚堝悓鍙�</text>
+					<text>鍚堝悓/鍗曟嵁缂栧彿</text>
 				</view>
-				<view class="value"><input type="text" placeholder="璇疯緭鍏ユ偍鐨勫悎鍚屽彿" v-model="param.contractNum" placeholder-style="color: #999999;" /></view>
+				<view class="value"><input type="text" placeholder="璇疯緭鍏ユ偍鐨勫悎鍚�/鍗曟嵁缂栧彿" v-model="param.contractNum" placeholder-style="color: #999999;" /></view>
 			</view>
 			<!--  -->
 			<view class="line">
@@ -33,7 +33,7 @@
 			<view class="line">
 				<view class="label">
 					<text>*</text>
-					<text>鍏ュ簱绫诲瀷</text>
+					<text>浣滀笟绫诲瀷</text>
 				</view>
 				<view class="value">
 					<view class="btns">
@@ -48,14 +48,14 @@
 					<text>鎬昏繍杈撻噺</text>
 				</view>
 				<view class="value">
-					<input type="number" placeholder="璇疯緭鍏ユ�昏繍杈撻噺" v-model="param.totalNum" placeholder-style="color: #999999;" />
+					<input type="number" @blur="checkSurplus" placeholder="璇疯緭鍏ユ�昏繍杈撻噺" v-model="param.totalNum" placeholder-style="color: #999999;" />
 					<text class="unit">涓囨敮</text>
 				</view>
 			</view>
 			<view class="line">
 				<view class="label">
 					<text>*</text>
-					<text>鍑嗚繍璇佺収鐗�</text>
+					<text>鍑嗚繍璇�/杩愬崟鐓х墖</text>
 				</view>
 				<view class="value" @click="handleUpload">
 					<image v-if="param.transportImgFull" class="upload_wrap" :src="param.transportImgFull" alt="">
@@ -98,19 +98,22 @@
 				</view>
 			</view>
 			<view class="copy" @click="copy">澶嶅埗杞﹀墠鐗岀収鍙�</view>
-			<view class="perch"></view>
-			<view class="handle_sub" @click="onSubmit">
-				鎻愪氦
+			<view class="footer">
+				<view class="handle_sub" @click="onSubmit">
+					鎻愪氦
+				</view>
 			</view>
 		</view>
 		
 		<!--  -->
-		<u-picker :show="showReason" keyName="reason" :columns="reasonList" @confirm="reasonConfirm"></u-picker>
+		<u-picker :show="showReason" keyName="reason" closeOnClickOverlay @close="showReason = false"
+			@cancel="showReason = false" :columns="reasonList" @confirm="reasonConfirm"></u-picker>
 		<u-datetime-picker
 			:show="showDatetime"
 			closeOnClickOverlay
 			:minDate="new Date().getTime()"
 			mode="datetime"
+			 :formatter="formatter"
 			@close="showDatetime = false"
 			@cancel="showDatetime = false"
 			@confirm="setinDate"
@@ -121,7 +124,7 @@
 
 <script>
 import keyboardInput from '@/components/keyboard-input/keyboard-input.vue';
-import { uploadUrl, driverCarApply,driverCarApplyEdit, driverReasonList, driverApplyDetail } from '@/api';
+import { uploadUrl, driverCarApply,driverCarApplyEdit, driverReasonList, driverApplyDetail, checkSurplusNum } from '@/api';
 import dayjs from 'dayjs'
 export default {
 	components: {
@@ -149,17 +152,56 @@
 		this.initData()
 	},
 	methods: {
+		formatter(type, value) {
+			if (type === 'year') {
+				return `${value}骞碻
+			}
+			if (type === 'month') {
+				return `${value}鏈坄
+			}
+			if (type === 'day') {
+				return `${value}鏃
+			}
+			if (type === 'hour') {
+				return `${value}鏃禶
+			}
+			if (type === 'minute') {
+				return `${value}鍒哷
+			}
+			return value
+		},
+		checkSurplus() {
+		      const { arriveDate, reasonId, totalNum } = this.param
+		      if(!arriveDate || !reasonId || !totalNum) return
+		      checkSurplusNum({
+		        arriveDate: arriveDate + ':00',
+		        reasonId,
+		        totalNum
+		      }).then(res => {
+		        console.log('res', res);
+		        
+		        if( res.data == 0 ||  res.data < Number(totalNum)){
+		          this.showToast(`褰撴棩鍓╀綑鍙绾︿綔涓氶噺涓嶈冻璇烽�夋嫨鍏朵粬鍒板満鏃ユ湡`)
+		        }
+		      })
+		    },
+		reasonClick() {
+			if(this.param.id){
+				return
+			}
+			this.showReason = true
+		},
 		onSubmit() {
 			const param = { ...this.param }
 			if (!param.arriveDate) return this.showToast('璇烽�夋嫨鍒板満鏃堕棿')
-			if (!param.inType && param.inType != 0) return this.showToast('璇烽�夋嫨鍏ュ簱绫诲瀷')
-			if (!param.contractNum) return this.showToast('璇疯緭鍏ュ悎鍚屽彿')
+			if (!param.inType && param.inType != 0) return this.showToast('璇烽�夋嫨浣滀笟绫诲瀷')
+			if (!param.contractNum) return this.showToast('璇疯緭鍏ュ悎鍚�/鍗曟嵁缂栧彿')
 			if (!param.totalNum) return this.showToast('璇疯緭鍏ユ�昏繍杈撻噺')
 			if (!param.driverName) return this.showToast('璇疯緭鍏ュ徃鏈哄鍚�')
 			if (!param.driverPhone) return this.showToast('璇疯緭鍏ユ墜鏈哄彿')
 			if (!param.carCodeFront) return this.showToast('璇疯緭鍏ヨ溅鍓嶇墝鍙�')
 			if (!param.carCodeBack) return this.showToast('璇疯緭鍏ヨ溅鍚庣墝鍙�')
-			if (!param.transportImgFull) return this.showToast('璇蜂笂浼犲噯杩愯瘉鐓х墖')
+			if (!param.transportImgFull) return this.showToast('璇蜂笂浼犲噯杩愯瘉/杩愬崟鐓х墖')
 			param.arriveDate = param.arriveDate + ':00'
 			let fn = param.id ? driverCarApplyEdit : driverCarApply
 			fn({...param}).then(res => {
@@ -167,7 +209,9 @@
 					setTimeout(() => {
 						this.showToast('棰勭害鐢宠鎴愬姛')
 					})
-					this.$jump('/pages/driver/reservedRecord')
+					uni.redirectTo({
+						url: '/pages/driver/index'
+					})
 				}
 			})
 		},
@@ -189,10 +233,12 @@
 			const index = e.indexs[0]
 			this.$set(this.param, 'inReason', reasonList[index].reason)
 			this.$set(this.param, 'reasonId', reasonList[index].id)
+			this.checkSurplus()
 			this.showReason = false
 		},
 		setinDate(e) {
 			this.$set(this.param, 'arriveDate', dayjs(e.value).format('YYYY-MM-DD HH:mm'))
+			this.checkSurplus()
 			this.showDatetime = false
 		},
 		inTypeClick(e) {
@@ -211,12 +257,14 @@
 			this.$forceUpdate();
 			this.closeInput();
 		},
+		closeInput() {
+			this.$refs.keyboard.close();
+		},
 		copy(){
 			if(this.param.carCodeFront){
 				this.$set(this.param, 'carCodeBack', this.param.carCodeFront)
 				this.showToast('澶嶅埗鎴愬姛');
 			}
-			
 		},
 		handleUpload() {
 			let token = uni.getStorageSync('token') || ''
@@ -260,9 +308,6 @@
 			  }
 			})
 		},
-		closeInput() {
-			this.$refs.keyboard.close();
-		}
 	}
 };
 </script>
@@ -298,6 +343,9 @@
 			display: flex;
 			align-items: center;
 			justify-content: flex-end;
+			.gray{
+				color: #999999 !important;
+			}
 			.btns {
 				display: flex;
 				align-items: center;
@@ -351,12 +399,14 @@
 	}
 }
 .main_app {
-	// padding-top: 10rpx;
+	padding-top: 10rpx;
+	.footer{
+		background-color: #f7f7f7;
+		padding: 20rpx 30rpx 30rpx;
+		margin: 0 -30rpx;
+	}
 	.handle_sub{
-		position: fixed;
-		bottom: 64rpx;
 		width: 690rpx;
-		left: 30rpx;
 		background-color: #4d99a8;
 		height: 88rpx;
 		line-height: 88rpx;
@@ -374,6 +424,7 @@
 		background-color: #f7f7f7;
 		display: flex;
 		margin: 0 -30rpx;
+		width: 750rpx;
 		justify-content: flex-end;
 		padding: 12rpx 30rpx;
 		font-size: 26rpx;

--
Gitblit v1.9.3