yangan
2025-04-10 f1950b48fec6421b50580f2a8899b360b314b73c
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
    <div class="warp">
       <view class="listBox" v-for="item,i in listBox" @click="todoBasMap(item)">
        <view class="left">
            <h4>{{ item.deptName }}</h4>
            <p>{{ item.position }}</p>
        </view>
        <view class="right">
            <img :src="`${onlineurl}/appimg/image/司机端首页/形状 1.jpg`" alt="" style="width: 30rpx;height: 30rpx;">
            <span>{{ item.distance }}</span>
        </view>
       </view>
    </div>
</template>
 
<script>
import { onlineurl } from '@/api/request.js'
import {BaseUrl} from '@/api/request.js'
export default {
    data() {
        return {
            property: 'value',
            listBox:[],
            longitude:'',
            latitude:'',
 
        };
    },
    onload(){
      
 
    },
    onShow(){
        this.init();
        this.getLocation();
    },
    computed:{
        userId() {
                return uni.getStorageSync('userId');
            }
    },
    methods: {
        init(){
            this.$reqGet('getCoalFiled',
                                {userId:uni.getStorageSync('userId'),
                                latitude: '38.04606544104117',
                                longitude:'114.48735479816793'
                                }
                                ).then((result) => {
                                    console.log(result,'result')
                                    this.listBox = result.data;
                                })
           
        //     uni.request({
        //     url: BaseUrl + '/wrzs/tmtaskcoal/getDepts' + '/' + uni.getStorageSync('userId') ,
        //     method: 'GET',
        //     header: {
        //         'Authorization': 'Basic c29jaWFsOnNvY2lhbA==', //app:app
        //         'content-type': 'application/x-www-form-urlencoded',
        //         'CLIENT_TOC': 'Y',
        //         'isToken': 'false'
        //     },
        //     success: res => {
        //         uni.hideLoading();
        //         console.log(res,'ressed');
        //         this.listBox = res.data.data;
        //     },
        //     fail: err => {
        //         console.log('错误', err)
        //         uni.hideLoading()
        //         uni.showToast({
        //             icon: 'none',
        //             title: '服务器错误'
        //         })
        //     }
        // })
        },
        getLocation(){
            var _this = this
            let QQMapWX = require('../../../utils/qqmap-wx-jssdk');
            let qqmapsdk = new QQMapWX({
                    key: 'HTNBZ-LZGRQ-YDB5S-B4KAS-KLHJH-GHBUE' // 必填
                });
                //使用 uni.getLocation获取用户所在经纬度
                uni.getLocation({
                    type: 'gcj02',
                    geocode: true,
                    isHighAccuracy: true,
                    success: (res) => {
                        console.log("获取经纬度成功");
                        // const re = _this.$mapChange.wgs84Togcj02(res.longitude, res.latitude)
                        // console.log(re)
                        _this.longitude = res.longitude
                        _this.latitude =  res.latitude
                    },
                    fail: () => {
                        console.log("获取经纬度失败");
                    },
                    complete: () => {
                        // 使用腾讯sdk的reverseGeocoder方法 解析经纬度
                        qqmapsdk.reverseGeocoder({
                            location: {
                                latitude: _this.latitude,
                                longitude: _this.longitude
                            },
                            success: function(res) {
                                console.log("解析地址成功", res);
                                console.log("当前地址:", res.result.address);
                                //保存缓存
                                uni.setStorage({
                                    key: 'local',
                                    data: res.result.address,
                                    success() {
                                        console.log("用户地址信息已缓存")
                                    }
                                })
                                _this.$reqGet('getCoalFiled',
                                {userId:uni.getStorageSync('userId'),
                                latitude:_this.latitude ? String(_this.latitude) : '38.04606544104117',
                                longitude:_this.longitude?  String(_this.longitude)  :'114.48735479816793'
                                }
                                ).then((result) => {
                                    console.log(result,'result')
                                    _this.listBox = result.data;
                                })
                            },
                            fail: function(res) {
                                uni.showToast({
                                    title: '定位失败',
                                    duration: 2000,
                                    icon: "none"
                                })
                                console.log(res);
                            },
                            complete: function(res) { //无论成功失败都会执行
                                console.log('获取定位信息')
                                return
                                uni.openLocation({
                                    latitude: _this.latitude,
                                    longitude: _this.longitude,
                                    success: function() {
                                        console.log('success');
                                    }
                                });
                            }
                        })
                 
                    }
                })
        },
        todoBasMap(item){
            uni.navigateTo({
                    url: `/pages/driver-page/driver-index/bill-of-lading-details/BaseMapDetail/index?latitude=${item.latitude}&longitude=${item.longitude}&name=${item.position}&brief=${item.brief}`
                });
        }
        
    },
 
}
 
</script>
 
<style lang="scss">
.warp{
    width: 100%;
    height: calc(100vh - 45px);
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #F4F4F4;
    overflow-y: auto;
    .listBox{
        width: 92%;
        height: 179rpx;
        background-color: #fff;
        margin-top: 20rpx;
        border-radius: 6rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
 
    }
    .left{
        margin-left: 30rpx;
        h4{
            font-weight: bold;
 
        }
        p{
            font-size: 24rpx;
            color: #676767;
        }
    }
    .right{
        margin-right: 30rpx;
        display: flex;
        flex-direction: column;
        align-items: center;
        span{
            font-size: 24rpx;
            color: #494949;
        }
    }
}
 
 
</style>