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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
| <template>
| <view class="base_body">
| <map :markers="markers" @tap="regionchange" :circles="circles" :show-compass="true" :scale="scale" id="map1"
| style="width: 100%; height: 100%;" :latitude="latitude" :longitude="longitude">
| <cover-view slot="callout">
| <block v-for="(item,index) in markers" :key="index">
| <cover-view class="customCallout" :marker-id="item.id" v-if="item.title">
| <cover-view class="content">
| <!-- <view>随意指定</view> -->
| {{item.title}}
| </cover-view>
| </cover-view>
| </block>
| </cover-view>
|
| <view class="home-icon" @click="backMyLocation">
| <u-icon name="home" color="#000" size="28px"></u-icon>
| <text style="font-size: 12px;">我的位置</text>
| </view>
| </map>
| <tabBar :current="1" :list="tabbarList" />
| </view>
| </template>
|
| <script>
| import tabBar from "@/components/tabBar/tabBar.vue"
| import {
| getTabbarList
| } from "@/common/common.js"
| import {
| getNearbyPlaceList
| } from '@/api/place/place.js'
| export default {
| components: {
| tabBar
| },
| data() {
| return {
| roleType: 1,
| addressType: 1,
| user_info: {},
| color: "#017BFC",
| tabbarList: [],
| map: '',
| scale: 18,
| latitude: '', // 地图默认显示的维度
| longitude: '', // 地图默认显示的纬度
| markers: [],
| //在地图上显示圈
| circles: [{
| longitude: 116.2529,
| latitude: 39.542,
| color: '#DEDEF8',
| fillColor: '#DEDEF8', // 填充颜色
| radius: 150, // 圆半径
| strokeWidth: 1 // 边
| }],
| }
| },
| onLoad() {
|
| },
|
| onReady() {},
|
| onShow() {
| let role = uni.getStorageSync('activeRole')
| if (role.roleName == "居民" || role.roleName == '无诈') {
| this.tabbarList = getTabbarList(1)
| this.roleType = 1
| this.color = "#017BFC"
| // this.tabbarIndex = 1;
| this.tabbarIndex = 2
| } else if (role.roleName == "民警") {
| this.tabbarList = getTabbarList(2)
| this.roleType = 2;
| this.color = "#003399"
| // this.tabbarIndex = 2;
| this.tabbarIndex = 3;
| } else if (role.roleName == "系统管理员") {
| this.tabbarList = getTabbarList(4)
| this.roleType = 1
| this.color = "#017BFC";
| // this.tabbarIndex = 2;
| this.tabbarIndex = 3;
| } else if (role.roleName == "网格员") {
| this.tabbarList = getTabbarList(3)
| this.roleType = 1
| this.color = "#017BFC";
| // this.tabbarIndex = 2;
| this.tabbarIndex = 3;
| } else if (role.roleName == '校园主体' || role.roleName == '校园通用') {
| this.tabbarList = getTabbarList(5);
| this.roleType = 5
| } else {
| this.tabbarList = getTabbarList(1)
| this.roleType = 1
| this.color = "#017BFC"
| // this.tabbarIndex = 1;
| this.tabbarIndex = 2
| }
| if (uni.getStorageSync("siteInfo")) {
| this.addressType = uni.getStorageSync("siteInfo").addressType;
| }
| this.getLocations()
| },
|
| methods: {
|
| backMyLocation() {
| this.getLocations()
| },
|
| async getLocations() {
| let param
| let that = this
| await uni.getLocation({
| type: 'gcj02',
| isHighAccuracy: true,
| success: function(res) {
| console.log('当前位置的经度:' + res.longitude);
| console.log('当前位置的纬度:' + res.latitude);
| that.latitude = res.latitude
| that.longitude = res.longitude
| that.getList()
| }
| });
| },
|
| regionchange(e) {
| console.log("****************", e)
| this.latitude = e.detail.latitude
| this.longitude = e.detail.longitude
| this.markers = []
| // if (this.latitude || this.longitude) {
| // return
| // }
| this.getList()
| },
|
| getList() {
| this.markers.push({
| id: 999,
| latitude: this.latitude,
| longitude: this.longitude,
| title: '',
| joinCluster: false,
| width: '36px', //设置宽高
| height: '46px',
| customCallout: {
| anchorY: 0, // Y轴偏移量
| anchorX: 50, // X轴偏移量
| display: "ALWAYS" // 一直展示
| },
| label: {
| content: '当前位置',
| color: '#fff',
| fontSize: 12,
| borderRadius: 5,
| padding: 5,
| textAlign: 'center',
| bgColor: '#2979ff',
| }
| })
| getNearbyPlaceList({
| lat: this.latitude,
| lng: this.longitude
| }).then(res => {
| let data = res.data;
| for (var i = 0; i < data.length; i++) {
| this.markers.push({
| id: i,
| latitude: data[i].lat,
| longitude: data[i].lng,
| title: data[i].placeName,
| joinCluster: true,
| width: '26px', //设置宽高
| height: '36px',
| customCallout: {
| anchorY: 0, // Y轴偏移量
| anchorX: 50, // X轴偏移量
| display: "ALWAYS" // 一直展示
| },
|
| })
| }
| console.log("*********", data)
| })
| }
| }
| }
| </script>
|
| <style>
| .base_body {
| width: 100%;
| height: 100%;
| position: absolute;
| }
|
| /* 水平,垂直居中 */
| .base_all_center {
| justify-content: center;
| align-items: center;
| }
|
| /* 垂直居中 */
| .base_center_vertical {
| display: flex;
| align-items: center;
| }
|
| /* 水平居中 */
| .base_center_horizontal {
| display: flex;
| justify-content: center;
| }
|
| /* 垂直布局 */
| .base_column {
| display: flex;
| flex-direction: column;
| }
|
| /* 横向布局 */
| .base_row {
| display: flex;
| flex-direction: row;
| }
|
| /* 基础dialog */
| .base_dialog {
| width: 100%;
| height: 80%;
| position: absolute;
| top: 0px;
| background: rgba(0, 0, 0, 0.5);
| }
|
| /* *************************************** */
| .customCallout {
| box-sizing: border-box;
| background-color: #fff;
| border: 1px solid #ccc;
| border-radius: 30px;
| /* width: 150px; */
| /* height: 40px; */
| display: inline-flex;
| padding: 5px 10px;
| justify-content: center;
| align-items: center;
| }
|
| .content {
| flex: 0 1 auto;
| margin: 0 10px;
| font-size: 14px;
| }
|
| .home-icon {
| border-radius: 10px;
| position: absolute;
| bottom: 120px;
| left: 83%;
| color: black;
| background-color: #fff;
| display: flex;
| flex-direction: column;
| align-items: center;
| width: 55px;
| height: 55px;
| }
| </style>
|
|