From ea2fb93a0dfcde8f5b66825b20f9d9b835a28acc Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期五, 22 五月 2026 10:54:09 +0800
Subject: [PATCH] 提交
---
app/pages/order-detail/order-detail.vue | 153 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 105 insertions(+), 48 deletions(-)
diff --git a/app/pages/order-detail/order-detail.vue b/app/pages/order-detail/order-detail.vue
index 7fb7fe5..69ba6a6 100644
--- a/app/pages/order-detail/order-detail.vue
+++ b/app/pages/order-detail/order-detail.vue
@@ -22,9 +22,6 @@
:enable-zoom="true"
:enable-scroll="true"
></map>
- <view class="order-detail-page__map-bubble">
- <text class="order-detail-page__map-bubble-text">{{ distance > 0 ? `鍓╀綑${(distance / 1000).toFixed(1)}km锛岀害${Math.ceil(duration / 60)}鍒嗛挓` : '姝e湪鑾峰彇浣嶇疆淇℃伅...' }}</text>
- </view>
</view>
<view class="order-detail-page__status-bar">
@@ -60,7 +57,7 @@
</view>
<view class="order-detail-page__summary-right">
- <text class="order-detail-page__price">楼{{ orderDetail.platformRewardAmount ? (orderDetail.driverFee + orderDetail.platformRewardAmount) / 100 : (orderDetail.driverFee / 100).toFixed(2) }}</text>
+ <text class="order-detail-page__price">楼{{ orderDetail.platformRewardAmount ? ((orderDetail.driverFee + orderDetail.platformRewardAmount) / 100).toFixed(2) : (orderDetail.driverFee / 100).toFixed(2) }}</text>
<text v-if="orderDetail.platformRewardAmount" class="order-detail-page__extra">鍚姞鎬ヂ{ (orderDetail.platformRewardAmount / 100).toFixed(2) }}</text>
</view>
</view>
@@ -76,9 +73,9 @@
</view>
<view class="order-detail-page__done-summary-right">
<view class="order-detail-page__done-price-row">
- <text class="order-detail-page__price">楼{{ (orderDetail.driverFee / 100).toFixed(1) }}</text>
+ <text class="order-detail-page__price">楼{{ (orderDetail.driverFee / 100).toFixed(2) }}</text>
</view>
- <text v-if="orderDetail.isUrgent === 1" class="order-detail-page__extra">鍚姞鎬ヂ{ orderDetail.urgentAmount / 100 }}</text>
+ <text v-if="orderDetail.isUrgent === 1" class="order-detail-page__extra">鍚姞鎬ヂ{ (orderDetail.urgentAmount / 100).toFixed(2) }}</text>
</view>
</view>
@@ -122,7 +119,7 @@
<image class="order-detail-page__qrcode-image" :src="'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=' + orderDetail.driverVerifyCode" mode="aspectFit"></image>
</view>
<text class="order-detail-page__qrcode-value">{{ orderDetail.driverVerifyCode }}</text>
- <text class="order-detail-page__qrcode-label">鍙栬揣鐮�</text>
+ <text class="order-detail-page__qrcode-label">{{ orderDetail.status === 3 ? '鍙栬揣鐮�' : '瀛樹欢鐮�' }}</text>
</view>
</view>
@@ -287,7 +284,7 @@
</template>
<script>
-import image from 'uview-ui/libs/config/props/image';
+ import { mapState } from 'vuex'
export default {
data() {
@@ -306,8 +303,10 @@
showGrabModal: false,
currentLocation: null,
routePoints: [],
+ locationTimer: null,
distance: 0,
duration: 0,
+ isWithinOperationRadius: true,
statusTextMap: {
2: '寰呮帴鍗�',
3: '寰呭彇璐�',
@@ -321,6 +320,7 @@
}
},
computed: {
+ ...mapState(['userInfo']),
formattedRemainTime() {
const minutes = this.orderDetail.remainMinutes
if (!minutes) return null
@@ -335,11 +335,9 @@
return this.orderDetail.status === 3 || this.orderDetail.status === 4
},
mapData() {
- const startPoint = this.currentLocation || { latitude: 31.829512, longitude: 117.239211 }
+ const startPoint = this.currentLocation || { latitude: this.orderDetail.navigateLat, longitude: this.orderDetail.navigateLng }
const hasEndPoint = this.orderDetail.navigateLat && this.orderDetail.navigateLng
- const endPoint = hasEndPoint
- ? { latitude: this.orderDetail.navigateLng, longitude: this.orderDetail.navigateLat }
- : { latitude: 31.841268, longitude: 117.278695 }
+ const endPoint = { latitude: this.orderDetail.navigateLng, longitude: this.orderDetail.navigateLat }
let center
let scale = 12
@@ -373,7 +371,7 @@
} else if (this.currentLocation) {
center = this.currentLocation
} else {
- center = { latitude: 31.83539, longitude: 117.258953 }
+ center = { latitude: this.orderDetail.navigateLat, longitude: this.orderDetail.navigateLng }
}
const markers = [
@@ -384,10 +382,6 @@
const routePoints = this.routePoints.length > 0 ? this.routePoints : [
startPoint,
- { latitude: 31.831624, longitude: 117.247836 },
- { latitude: 31.834918, longitude: 117.255467 },
- { latitude: 31.838214, longitude: 117.265358 },
- { latitude: 31.840126, longitude: 117.272481 },
endPoint
]
@@ -459,10 +453,60 @@
this.getOrderDetail()
}
},
+
+ onUnload() {
+ if (this.locationTimer) {
+ clearInterval(this.locationTimer)
+ this.locationTimer = null
+ }
+ },
+
methods: {
handleBack() {
uni.navigateBack({ delta: 1 });
},
+ initOperationRadius() {
+ console.log('initOperationRadius')
+ return new Promise((resolve) => {
+ uni.getLocation({
+ type: 'gcj02',
+ success: (res) => {
+ this.$u.api.checkDriverOperationRadius({
+ lat: res.latitude,
+ lng: res.longitude,
+ orderId: this.orderId
+ }).then(res => {
+ if (res.code === 200) {
+ this.isWithinOperationRadius = res.data
+ console.log(res.data)
+ if (!this.isWithinOperationRadius) {
+ uni.showToast({
+ title: '鎮ㄥ綋鍓嶄綅缃笌鏀惰揣鍦板潃璺濈瓒呭嚭鑼冨洿锛岃鍦ㄥ湴鍧�闄勮繎閲嶆柊鎷嶇収',
+ icon: 'none'
+ })
+ resolve(false)
+ } else {
+ resolve(true)
+ }
+ } else {
+ resolve(false)
+ }
+ }).catch(() => {
+ resolve(false)
+ })
+ },
+ fail: () => {
+ this.isWithinOperationRadius = false
+ uni.showToast({
+ title: '鎮ㄥ綋鍓嶄綅缃潈闄愭病鏈夊紑鍚紝璇峰厛寮�鍚悗鍐嶆潵鎿嶄綔',
+ icon: 'none'
+ })
+ resolve(false)
+ }
+ })
+ })
+ },
+
getOrderDetail() {
this.$u.api.orderDetail({ orderId: this.orderId }).then(res => {
if (res.code === 200) {
@@ -480,6 +524,13 @@
},
getCurrentLocation() {
+ this.fetchLocation()
+ this.locationTimer = setInterval(() => {
+ this.fetchLocation()
+ }, 60000)
+ },
+
+ fetchLocation() {
uni.getLocation({
type: 'gcj02',
success: (res) => {
@@ -502,14 +553,15 @@
}
const from = `${this.currentLocation.latitude},${this.currentLocation.longitude}`
const to = `${this.orderDetail.navigateLng},${this.orderDetail.navigateLat}`
+ console.log('driverType', this.userInfo.driverType)
this.$u.api.directionInfo({
from,
to,
- mode: 'driving'
+ mode: this.userInfo.driverType
}).then(res => {
- console.log('directionInfo success:', res)
- if (res && res.paths && res.paths.length > 0) {
- const path = res.paths[0]
+ console.log('paths success:', res.data.route.paths[0])
+ if (res.code === 200) {
+ const path = res.data.route.paths[0]
this.distance = path.distance
this.duration = path.duration
const points = []
@@ -526,11 +578,7 @@
})
this.routePoints = points
this.$forceUpdate()
- } else {
- console.log('No route data returned:', res)
}
- }).catch(err => {
- console.log('璺緞瑙勫垝澶辫触', err)
})
},
@@ -597,10 +645,14 @@
}
if (action === 'pickup' || action === 'deliver') {
- this.uploadedPhotos = []
- this.photoRemark = ''
- this.photoPopupMode = action
- this.showPhotoPopup = true
+ this.initOperationRadius().then((isValid) => {
+ console.log(isValid)
+ if (!isValid) return
+ this.uploadedPhotos = []
+ this.photoRemark = ''
+ this.photoPopupMode = action
+ this.showPhotoPopup = true
+ })
return
}
@@ -638,6 +690,7 @@
if (res.code === 200) {
uni.showToast({ title: '鎺ュ崟鎴愬姛', icon: 'success' })
this.getOrderDetail()
+ uni.$emit('jiedanSuccess')
setTimeout(() => {
uni.navigateBack()
}, 1500)
@@ -671,15 +724,31 @@
return
}
uni.showLoading({ title: '涓婁紶涓�...' })
+ uni.getLocation({
+ type: 'gcj02',
+ success: (locationRes) => {
+ this.doUploadPhotos(locationRes.latitude, locationRes.longitude)
+ },
+ fail: () => {
+ this.doUploadPhotos(null, null)
+ }
+ })
+ },
+
+ doUploadPhotos(latitude, longitude) {
const uploadTasks = this.uploadedPhotos.map(path => {
return new Promise((resolve, reject) => {
+ const formData = { folder: 'orders' }
+ if (latitude && longitude) {
+ formData.latitude = latitude
+ formData.longitude = longitude
+ }
+ console.log('formData:', formData)
uni.uploadFile({
url: this.$baseUrl + 'web/public/upload',
filePath: path,
name: 'file',
- formData: {
- folder: 'order'
- },
+ formData: formData,
success: (uploadRes) => {
const data = JSON.parse(uploadRes.data)
if (data.code === 200) {
@@ -701,6 +770,10 @@
images: images.map(img => img.imgaddr),
orderId: this.orderId,
remark: this.photoRemark
+ }
+ if (latitude && longitude) {
+ params.latitude = latitude
+ params.longitude = longitude
}
return this.$u.api[api](params)
}).then(res => {
@@ -771,22 +844,6 @@
&__map {
width: 750rpx;
height: 500rpx;
- }
-
- &__map-bubble {
- position: absolute;
- left: 34rpx;
- bottom: 32rpx;
- padding: 12rpx 18rpx;
- border-radius: 14rpx;
- background: rgba(255, 255, 255, 0.96);
- box-shadow: 0 8rpx 18rpx rgba(23, 74, 163, 0.12);
- }
-
- &__map-bubble-text {
- font-size: 24rpx;
- font-weight: 600;
- color: #2f6ff2;
}
&__status-bar {
--
Gitblit v1.9.3