blob: 315f56e5425d242aa098930e4a8ec8c6161dde16 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <div class="offlineHelp">
3 <map id="map" class="myMap" :longitude="longitude" :latitude="latitude" :markers="markList" :circles="circles"
4 @markertap="markertap" @labeltap="labeltap" :style="{width:windowWidth +'px',height:windowHeight+'px'}"
5 @tap="clickMap"
6 v-if="showMap"></map>
7 <div :class="className" ref="stations">
8 <div class="stations-title"><text class="stations-title-text">附件网点</text></div>
9 <scroll-view scroll-y="true" class="srcollView">
10 <div class="stations-items" v-for="(v,i) in stationList" :key="i" v-if="stationList.length != 0">
11 <div class="stations-items-left">
12 <text class="stations-items-left-title">{{v.name}}</text>
13 <text class="stations-items-left-desc">距离我{{v.distance}}m</text>
14 </div>
15 <div class="stations-items-btn">
16 <text class="stations-items-btn-text" @click="toDetails(i+1)">查看详情</text>
17 </div>
18 </div>
19 <div class="stations-noitems" v-if="stationList.length == 0">
20 <text class="stations-noitems-text">附近暂无网点</text>
21 </div>
22 </scroll-view>
23 </div>
24 <div class="detail" ref="details" v-if="stationList.length != 0">
25 <div class="detail-title">
26 <text class="detail-title-text">{{stationList[id].name}}</text>
27 <uni-rate :readonly="true" :value="value" size="18" activeColor="#30A8E1" margin="5" />
28 <text class="detail-title-rate">{{value}}.0分</text>
29 </div>
30 <div class="detail-subtitle">
31 <text class="detail-subtitle-text">地址:{{stationList[id].address}}</text>
32 </div>
33 <div class="detail-list">
34 <text class="detail-list-text">营业时间:{{stationList[id].starttime|changeVal}}-{{stationList[id].endtime|changeVal}}</text>
35 <text class="detail-list-text">服务范围:{{stationList[id].businescope}}等</text>
36 <text class="detail-list-text">服务热线:{{stationList[id].tel}}</text>
37 </div>
38 </div>
39 </div>
40</template>
41
42<script>
43 export default {
44 data() {
45 return {
46 longitude: 121.5383637152778,
47 latitude: 31.27619086371528,
48 value: 5,
49 circles: [{
50 longitude: 0,
51 latitude: 0,
guangchao.xu6cdd45e2021-04-16 17:44:30 +080052 fillColor: '#DBF4FF99',
guangchao.xu070005a2020-12-07 09:56:40 +080053 radius: 1500,
guangchao.xu6cdd45e2021-04-16 17:44:30 +080054 color: '#DBF4FF99'
guangchao.xu070005a2020-12-07 09:56:40 +080055 }],
56 markList: [{
57 id: 0,
58 longitude: 0,
59 latitude: 0,
60 title: '我所在位置',
guangchao.xu6cdd45e2021-04-16 17:44:30 +080061 iconPath: './images/map/my.png',
guangchao.xu070005a2020-12-07 09:56:40 +080062 width: 20,
63 height: 20,
64 index: 0
65 }],
66 windowWidth: "",
67 windowHeight: "",
68 stationList: [],
69 // polyline: [{
70 // points: [{
71 // latitude: 31.27619086371528,
72 // longitude: 121.5383637152778
73 // }],
74 // color: "#30A8E1",
75 // }],
76 className: 'stations',
77 showMap: true,
78 id: 0
79 }
80 },
81 methods: {
82 getPhoneMsg() {
83 let that = this
84 uni.getSystemInfo({
85 success: function(res) {
86 that.windowHeight = res.windowHeight
87 that.windowWidth = res.windowWidth
88 }
89 });
90 },
91 getLocation() {
92 let that = this
93 uni.getLocation({
94 type: "gcj02",
95 success(res) {
96 console.log(res)
97 that.longitude = res.longitude
98 that.latitude = res.latitude
99 that.circles[0].longitude = res.longitude
100 that.circles[0].latitude = res.latitude
101 that.markList[0].longitude = res.longitude
102 that.markList[0].latitude = res.latitude
103 that.getNearbyStations(res.longitude, res.latitude)
104 },
105 fail(res) {
106 uni.showToast({
107 icon: "none",
108 title: "获取位置信息失败",
109 duration: 1500
110 })
111 }
112 })
113 },
114 markertap(e) {
115 let that = this
116 if (e.detail.markerId != 0) {
117 that.id = e.detail.markerId - 1
118 that.nearbyAnimateOut()
119 that.detailAnimateIn()
120 } else {
121 that.nearbyAnimateIn()
122 that.detailAnimateOut()
123 }
124 },
125 toDetails(e) {
126 let that = this
127 that.id = e - 1
128 that.nearbyAnimateOut()
129 that.detailAnimateIn()
130 },
131 onregionchange(e) {
132 console.log(e)
133 },
134 getNearbyStations(longitude, latitude) {
135 let that = this
136 that.showMap = false
137 let params = {
138 location: longitude + ',' + latitude,
139 distance: 3000
140 }
141 uni.request({
142 url: "https://yy.dlsmk.cn/portal/mobileapi/i/outlets/nearby",
143 data: params,
144 method: "GET",
145 success(res) {
146 console.log(res)
147 let list = res.data.data
148 console.log(list.length)
149 if (list.length != 0) {
150 that.stationList = list
151 list.map((value, index, arr) => {
152 that.markList.push({
153 longitude: value.location.substr(0, value.location.indexOf(",")),
154 latitude: value.location.substr(value.location.indexOf(",") + 1),
guangchao.xu6cdd45e2021-04-16 17:44:30 +0800155 iconPath: './images/map/mark.png',
guangchao.xu070005a2020-12-07 09:56:40 +0800156 width: 20,
157 height: 35,
158 title: value.name,
159 id: index + 1,
160 })
161 })
162 }
163 that.showMap = true
164 that.nearbyAnimateIn()
165 },
166 fail(rej) {
167 that.showMap = true
168 uni.showModal({
169 title: "错误",
170 content: rej.code + ":" + rej.message,
171 showCancel: false,
172 })
173 }
174 })
175 },
176 //点击地图更换位置
177 clickMap(e) {
178 let that = this
179 that.nearbyAnimateIn()
180 that.detailAnimateOut()
181 //console.log(e.detail)
182 },
183
184 //动画效果
185 nearbyAnimateIn() {
186 // #ifdef APP-NVUE
187 const animation = weex.requireModule('animation')
188 animation.transition(this.$refs['stations'], {
189 styles: {
190 transform: 'translateY(-700px)',
191 transformOrigin: 'center center',
192 opacity: 1,
193 backgroundColor: "#ffffff"
194 },
195 duration: 500, //ms
196 needLayout: true, //ms
197 timingFunction: 'linear',
198 delay: 0 //ms
199 }, () => {})
200 // #endif
201
202 // #ifdef MP-WEIXIN
203 this.$scope.animate('.stations', [{
204 translateY: '-700px',
205 opacity: 1,
206 backgroundColor: "#ffffff",
207 transformOrigin: 'center center'
208 }], 500, function() {})
209 // #endif
210 },
211 nearbyAnimateOut() {
212 // #ifdef APP-NVUE
213 const animation = weex.requireModule('animation')
214 animation.transition(this.$refs['stations'], {
215 styles: {
216 transform: 'translateY(700px)',
217 transformOrigin: 'center center',
218 opacity: 0,
219 },
220 duration: 500, //ms
221 needLayout: true, //ms
222 timingFunction: 'linear',
223 delay: 0 //ms
224 }, () => {})
225 // #endif
226
227 // #ifdef MP-WEIXIN
228 this.$scope.animate('.stations', [{
229 translateY: '700px',
230 opacity: 0,
231 transformOrigin: 'center center'
232 }], 500, function() {})
233 // #endif
234
235 },
236 detailAnimateIn() {
237 // #ifdef APP-NVUE
238 const animation = weex.requireModule('animation')
239 animation.transition(this.$refs['details'], {
240 styles: {
241 transform: 'translateY(-850px)',
242 transformOrigin: 'center center',
243 backgroundColor: "#ffffff",
244 opacity: 1
245 },
246 duration: 500, //ms
247 needLayout: true, //ms
248 timingFunction: 'linear',
249 delay: 0 //ms
250 }, () => {})
251 // #endif
252
253 // #ifdef MP-WEIXIN
254 this.$scope.animate('.detail', [{
255 translateY: '-850px',
256 opacity: 1,
257 backgroundColor: "#ffffff",
258 transformOrigin: 'center center'
259 }], 500, function() {})
260 // #endif
261
262 },
263 detailAnimateOut() {
264 // #ifdef APP-NVUE
265 const animation = weex.requireModule('animation')
266 animation.transition(this.$refs['details'], {
267 styles: {
268 transform: 'translateY(850px)',
269 transformOrigin: 'center center',
270 opacity: 0
271 },
272 duration: 500, //ms
273 needLayout: true, //ms
274 timingFunction: 'linear',
275 delay: 0 //ms
276 }, () => {})
277 // #endif
278
279 // #ifdef MP-WEIXIN
280 this.$scope.animate('.detail', [{
281 translateY: '850px',
282 opacity: 0,
283 transformOrigin: 'center center'
284 }], 500, function() {})
285 // #endif
286
287 },
288
289 },
290 created() {
291 this.getLocation()
292 this.getPhoneMsg()
293 },
294 filters: {
295 changeVal(data) {
296 data = data.substr(0, 2) + ":" + data.substr(2, 2)
297 return data
298 }
299 }
300 }
301</script>
302
303<style lang="scss" scoped>
304 .offlineHelp {
305 position: relative;
306 justify-content: center;
307 }
308
309 .srcollView {
310 height: 450rpx;
311 }
312
313 .detail {
314 position: absolute;
315 bottom: -800px;
316 left: 50rpx;
317 background-color: #FFFFFF;
318 width: 650rpx;
319 padding: 30rpx;
320 border-radius: 10rpx;
321 overflow: hidden;
322 font-family: "PingFang-SC-Medium";
323 opacity: 0;
324
325 &-title {
326 flex-direction: row;
327 align-items: center;
328
329 &-text {
330 color: #333333;
331 font-size: 32rpx;
332 margin-right: 10rpx;
333 }
334
335 &-rate {
336 color: #30A8E1;
337 font-size: 28rpx;
338 font-family: "PingFang-SC-Medium";
339 margin-left: 10rpx;
340 }
341 }
342
343 &-subtitle {
344 margin: 13rpx 0;
345
346 &-text {
347 color: #9A9A9A;
348 font-size: 25rpx;
349 }
350 }
351
352 &-list {
353 &-text {
354 color: #666666;
355 font-size: 28rpx;
356 line-height: 50rpx;
357 }
358 }
359 }
360
361 .stations {
362 position: absolute;
363 bottom: -700px;
364 left: 50rpx;
365 width: 650rpx;
366 padding: 30rpx;
367 border-top-left-radius: 20rpx;
368 border-top-right-radius: 20rpx;
369 overflow: hidden;
370 font-family: "PingFang-SC-Medium";
371 opacity: 0;
372
373 &-title {
374 &-text {
375 color: #333333;
376 font-size: 32rpx;
377 }
378 }
379
380 &-noitems {
381 justify-content: center;
382 align-items: center;
383 margin-top: 30rpx;
384
385 &-text {
386 color: #333333;
387 font-size: 30rpx;
388 }
389 }
390
391 &-items {
392 // display: flex;
393 flex-direction: row;
394 justify-content: space-between;
395 padding: 20rpx 0;
396 align-items: center;
397 border-bottom-color: #CCCCCC;
398 border-bottom-width: 1px;
399
400 &-left {
401 // display: flex;
402 flex-direction: column;
403
404 &-title {
405 color: #666666;
406 font-size: 28rpx;
407 }
408
409 &-desc {
410 color: #999999;
411 font-size: 25rpx;
412 margin-top: 10rpx;
413 }
414 }
415
416 &-btn {
417 padding: 15rpx 30rpx;
418 background-color: #2FA8E1;
419 border-radius: 50rpx;
420
421 &-text {
422 color: #FFFFFF;
423 font-size: 25rpx;
424 }
425 }
426 }
427 }
428</style>