rk
10 小时以前 4f4538356403d620b9bd510fd45729a251291942
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
    <view class="guiji">
        <map
            :latitude="mapLatitude"
            :longitude="mapLongitude"
            :markers="markers"
            :polyline="polyline"
            :include-points="includePoints"
            scale="14" />
        <view class="info">
            <view class="info_title">车辆编号:{{ info.bikeCode || '-' }}</view>
            <view class="info_info">骑行开始时间:{{ info.rentDate || '-' }}</view>
            <view class="info_info">骑行结束时间:{{ info.backDate || '-' }}</view>
            <view class="info_info">骑行计费时长:{{ info.duration ? `${info.duration}分钟` : '-' }}</view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                id: null,
                info: {},
                markers: [],
                polyline: [],
                includePoints: [],
                mapLatitude: 31.8206,
                mapLongitude: 117.2272
            };
        },
        onLoad(options) {
            this.id = options.id
            this.getInfo()
        },
        methods: {
            buildMarkers(startPoint, endPoint) {
                const markers = []
 
                if (startPoint) {
                    markers.push({
                        id: 1,
                        latitude: startPoint.latitude,
                        longitude: startPoint.longitude,
                        width: 32,
                        height: 32,
                        iconPath: '/static/icon/ic_star@2x.png',
                        callout: {
                            content: '起点',
                            display: 'ALWAYS',
                            padding: 6,
                            borderRadius: 6,
                            bgColor: '#01B6AD',
                            color: '#FFFFFF',
                            fontSize: 12,
                            textAlign: 'center'
                        }
                    })
                }
 
                if (endPoint) {
                    markers.push({
                        id: 2,
                        latitude: endPoint.latitude,
                        longitude: endPoint.longitude,
                        width: 32,
                        height: 32,
                        iconPath: '/static/icon/ic_end@2x.png',
                        callout: {
                            content: '终点',
                            display: 'ALWAYS',
                            padding: 6,
                            borderRadius: 6,
                            bgColor: '#FF5A31',
                            color: '#FFFFFF',
                            fontSize: 12,
                            textAlign: 'center'
                        }
                    })
                }
 
                return markers
            },
            async getInfo() {
                const res = await this.$u.api.orderRides({
                    orderId: this.id
                })
 
                if (res.code === 200) {
                    const rideInfo = (res.data && res.data.rides && res.data.rides[0]) || {}
                    const tracks = Array.isArray(rideInfo.tracks) ? rideInfo.tracks.filter(item => item && item.latitude && item.longitude) : []
                    const startPoint = tracks.length ? tracks[0] : null
                    const endPoint = tracks.length ? tracks[tracks.length - 1] : null
                    
                    this.info = rideInfo
                    this.includePoints = tracks
                    this.markers = this.buildMarkers(startPoint, endPoint)
                    this.polyline = tracks.length ? [{
                        points: tracks,
                        color: '#01B6AD',
                        width: 6,
                        arrowLine: true,
                        borderColor: '#FFFFFF',
                        borderWidth: 1
                    }] : []
                    
                    if (startPoint) {
                        this.mapLatitude = startPoint.latitude
                        this.mapLongitude = startPoint.longitude
                    }
                }
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .guiji {
        width: 100%;
        map {
            width: 100%;
            height: calc(100vh - 206rpx);
        }
        .info {
            width: 100%;
            height: calc(206rpx + env(safe-area-inset-bottom));
            padding: 30rpx;
            box-sizing: border-box;
            background: linear-gradient( 360deg, #FFFFFF 0%, #FFFFFF 57.68%, #D0FFFD 100%);
            box-shadow: 0rpx -6rpx 16rpx 0rpx rgba(0,0,0,0.1);
            border-radius: 32rpx 32rpx 0rpx 0rpx;
            position: relative;
            top: -30rpx;
            left: 0;
            z-index: 999;
            .info_title {
                font-weight: 600;
                font-size: 32rpx;
                color: #222222;
            }
            .info_info {
                font-weight: 400;
                font-size: 26rpx;
                color: #666666;
                margin-top: 20rpx;
            }
        }
    }
</style>