| | |
| | | </template> |
| | | |
| | | <script> |
| | | import image from 'uview-ui/libs/config/props/image'; |
| | | import { mapState } from 'vuex' |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | showGrabModal: false, |
| | | currentLocation: null, |
| | | routePoints: [], |
| | | locationTimer: null, |
| | | distance: 0, |
| | | duration: 0, |
| | | statusTextMap: { |
| | |
| | | } |
| | | }, |
| | | computed: { |
| | | ...mapState(['userInfo']), |
| | | formattedRemainTime() { |
| | | const minutes = this.orderDetail.remainMinutes |
| | | if (!minutes) return null |
| | |
| | | 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 |
| | |
| | | } 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 = [ |
| | |
| | | |
| | | 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 |
| | | ] |
| | | |
| | |
| | | this.getOrderDetail() |
| | | } |
| | | }, |
| | | onUnload() { |
| | | if (this.locationTimer) { |
| | | clearInterval(this.locationTimer) |
| | | this.locationTimer = null |
| | | } |
| | | }, |
| | | methods: { |
| | | handleBack() { |
| | | uni.navigateBack({ delta: 1 }); |
| | |
| | | }, |
| | | |
| | | getCurrentLocation() { |
| | | this.fetchLocation() |
| | | this.locationTimer = setInterval(() => { |
| | | this.fetchLocation() |
| | | }, 60000) |
| | | }, |
| | | |
| | | fetchLocation() { |
| | | uni.getLocation({ |
| | | type: 'gcj02', |
| | | success: (res) => { |
| | |
| | | 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 = [] |
| | |
| | | }) |
| | | this.routePoints = points |
| | | this.$forceUpdate() |
| | | } else { |
| | | console.log('No route data returned:', res) |
| | | } |
| | | }).catch(err => { |
| | | console.log('路径规划失败', err) |
| | | }) |
| | | }, |
| | | |
| | |
| | | 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) { |
| | |
| | | orderId: this.orderId, |
| | | remark: this.photoRemark |
| | | } |
| | | if (latitude && longitude) { |
| | | params.latitude = latitude |
| | | params.longitude = longitude |
| | | } |
| | | return this.$u.api[api](params) |
| | | }).then(res => { |
| | | uni.hideLoading() |