From 3fb674916994deff93d3335e263e07dfb5946a8d Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 21 八月 2025 17:47:52 +0800
Subject: [PATCH] 优化

---
 small-program/pages/freight/freight.vue |  172 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 111 insertions(+), 61 deletions(-)

diff --git a/small-program/pages/freight/freight.vue b/small-program/pages/freight/freight.vue
index 7fc5791..b575336 100644
--- a/small-program/pages/freight/freight.vue
+++ b/small-program/pages/freight/freight.vue
@@ -92,8 +92,10 @@
 						<view class="list-item-row-label">杩愯緭閲嶉噺/鏁伴噺<b>*</b></view>
 						<view class="list-item-row-val">
 							<input type="text" v-model="form.transportNum" placeholder="璇疯緭鍏�" />
-							<text @click="show4 = true">{{form.transportUnit}}</text>
-							<u-icon name="arrow-down" color="#111111" size="16"></u-icon>
+							<view @click="show4 = true" style="width: 100%; flex-shrink: 0; display: flex; align-items: center; justify-content: flex-end;">
+								<text>{{form.transportUnit}}</text>
+								<u-icon name="arrow-down" color="#111111" size="16"></u-icon>
+							</view>
 						</view>
 					</view>
 					<view class="list-item-row" v-if="viewStatus">
@@ -126,7 +128,7 @@
 						<text>璐圭敤</text>
 					</view>
 					<view class="list-item-cate">
-						<view :class="item.id === form.carType ? 'list-item-cate-item active' : 'list-item-cate-item'" v-for="(item, index) in ff" :key="index" @click="form.carType = item.id">鎸夊ぉ浠樿垂</view>
+						<view :class="item.id === form.carType ? 'list-item-cate-item active' : 'list-item-cate-item'" v-for="(item, index) in ff" :key="index" @click="form.carType = item.id">{{item.name}}</view>
 					</view>
 					<view class="list-item-row">
 						<view class="list-item-row-label">澶╂暟</view>
@@ -302,16 +304,18 @@
 				this.$u.api.getDetail({
 					orderId: option.id
 				}).then(res => {
-					this.info = res.data
-					for (const key in this.form) {
-						this.form[key] = res.data[key]
-					}
-					this.form.price = Number(this.form.price) / 100
-					if (!this.form.multifileList) {
-						this.form.multifileList = []
-					}
-					if (!this.form.wayInfoDTOList) {
-						this.form.wayInfoDTOList = []
+					if (res.code === 200) {
+						this.info = res.data
+						for (const key in this.form) {
+							this.form[key] = res.data[key]
+						}
+						this.form.price = Number(this.form.price) / 100
+						if (!this.form.multifileList) {
+							this.form.multifileList = []
+						}
+						if (!this.form.wayInfoDTOList) {
+							this.form.wayInfoDTOList = []
+						}
 					}
 				})
 			} else {
@@ -340,6 +344,9 @@
 			},
 			// 鎻愪氦璁㈠崟
 			submit() {
+				if (!this.form.carUnit) {
+					return uni.showToast({ title: '璇烽�夋嫨璐ц溅鍨嬪彿', icon: 'none' })
+				}
 				if (!this.form.transportTypeName) {
 					return uni.showToast({ title: '璇烽�夋嫨杩愯緭鍝佺', icon: 'none' })
 				}
@@ -355,52 +362,87 @@
 				if (!this.form.linkPhone) {
 					return uni.showToast({ title: '璇疯緭鍏ヨ仈绯荤數璇�', icon: 'none' })
 				}
-				this.$u.api.release({ 
-					...this.form,
-					price: Number(this.form.price) * 100,
-					wayInfoDTOList: [
-						{
-							lat: this.form.lat,
-							lgt: this.form.lgt,
-							location: this.form.location
-						},
-						...this.form.wayInfoDTOList,
-						{
-							lat: this.form.latEnd,
-							lgt: this.form.lgtEnd,
-							location: this.form.locationEnd
+				if (!this.form.id) {
+					this.$u.api.release({
+						...this.form,
+						price: Number(this.form.price) * 100,
+						wayInfoDTOList: [
+							{
+								lat: this.form.lat,
+								lgt: this.form.lgt,
+								location: this.form.location
+							},
+							...this.form.wayInfoDTOList,
+							{
+								lat: this.form.latEnd,
+								lgt: this.form.lgtEnd,
+								location: this.form.locationEnd
+							}
+						]
+					}).then(res => {
+						if (res.code == 200) {
+							uni.navigateTo({
+								url: `/pages/success/success?orderId=${res.data.id}`
+							})
 						}
-					]
-				}).then(res => {
-					if (res.code == 200) {
-						uni.navigateTo({
-							url: `/pages/success/success?orderId=${res.data.id}`
-						})
-					}
-				})
+					})
+				} else {
+					this.$u.api.updateOrder({
+						...this.form,
+						price: Number(this.form.price) * 100,
+						wayInfoDTOList: [
+							{
+								lat: this.form.lat,
+								lgt: this.form.lgt,
+								location: this.form.location
+							},
+							...this.form.wayInfoDTOList,
+							{
+								lat: this.form.latEnd,
+								lgt: this.form.lgtEnd,
+								location: this.form.locationEnd
+							}
+						]
+					}).then(res => {
+						if (res.code == 200) {
+							uni.showToast({
+								title: '缂栬緫鎴愬姛',
+								icon: 'success',
+								mask: true,
+								duration: 2000
+							})
+							setTimeout(() => {
+								uni.navigateBack({ delta: 1 });
+								// uni.$emit('refresh')
+							}, 1500)
+							
+						}
+					})
+				}
 			},
 			uploadImg() {
 				var that = this;
 				uni.chooseImage({
 					success: (chooseImageRes) => {
-						const tempFilePaths = chooseImageRes.tempFilePaths;
-						uni.uploadFile({
-							url: this.$baseUrl + '/web/public/upload',
-							filePath: tempFilePaths[0],
-							name: 'file',
-							formData: {
-								'folder': 'orders'
-							},
-							success: (uploadFileRes) => {
-								const res = JSON.parse(uploadFileRes.data)
-								that.form.multifileList.push({
-									fileurl: res.data.imgaddr,
-									name: res.data.originname,
-									url: res.data.url,
-									type: 0
-								})
-							}
-						});
+						for (let i = 0; i < chooseImageRes.tempFilePaths.length; i++) {
+							uni.uploadFile({
+								url: this.$baseUrl + '/web/public/upload',
+								filePath: chooseImageRes.tempFilePaths[i],
+								name: 'file',
+								formData: {
+									'folder': 'orders'
+								},
+								success: (uploadFileRes) => {
+									const res = JSON.parse(uploadFileRes.data)
+									that.form.multifileList.push({
+										fileurl: res.data.imgaddr,
+										name: res.data.originname,
+										url: res.data.url,
+										type: 0
+									})
+								}
+							});
+						}
 					}
 				});
 			},
@@ -414,23 +456,31 @@
 						priceNum2: this.form.priceNum2,
 						type: 1
 					}).then(res => {
-						this.form.estimatedAccount = res.data
+						if (res.code === 200) {
+							this.form.estimatedAccount = res.data
+						}
+						
 					})
 				}
 			},
 			getCategoryLists() {
 				this.$u.api.getCategoryList({ type: 1 })
 					.then(res => {
-						this.car = [res.data]
-						res.data.forEach(item => {
-							if (item.id === this.form.categoryId) {
-								this.carArr = [item.detailList]
-							}
-						})
+						if (res.code === 200) {
+							this.car = [res.data]
+							res.data.forEach(item => {
+								if (item.id === this.form.categoryId) {
+									this.carArr = [item.detailList]
+								}
+							})
+						}
+						
 					})
 				this.$u.api.getCategoryList({ type: 0 })
 					.then(res => {
-						this.variety = [res.data]
+						if (res.code === 200) {
+							this.variety = [res.data]
+						}
 					})
 			},
 			confirmCategary(e) {

--
Gitblit v1.9.3