ac775d76
liuqimichale
天水
|
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
|
<template>
<div>
<ul class="park-wrap">
<li class="park-main" v-for="(i, index) in list">
<div class="park-top" @click="parkInfo(i)">
<div>
<p style="margin-bottom: 6px">
<span class="park-status bgcz" v-if="i.idleberths>10">充足</span>
<span class="park-status bgjz" v-else-if="i.idleberths>0&&i.idleberths<=10">紧张</span>
<span class="park-status bgtm" v-else-if="i.idleberths==0&&i.totalberths&&i.totalberths!=0&&i.totalberths!='0'">停满</span>
<span class="park-status bgcz" v-else>充足</span>
{{ i.name}}</p>
<p style="margin-bottom: 6px">
当前车位数: <span class="park-num-color">{{ i.idleberths }}</span> / {{ i.totalberths }}
</p>
<p style="color: #ccc">{{ i.address }}</p>
</div>
</div>
<div class="park-bottom">
<div style="flex: 1">
距离您:{{ toDecimal2((parseFloat(i.distance)*0.001)) }}KM
</div>
<p @click="gaodec(i)">导航</p>
</div>
</li>
</ul>
<popComponents
:latitude="latitude"
:longitude="longitude"
:popupFlag="popupVisible" :parkName="name" :idleberths="idleberths" :juli="juli" :num="n">
</popComponents>
</div>
</template>
<script>
import { queryParkingLots } from '@/api/map/map.js'
import popComponents from './popComponents.vue'
export default {
name: 'parkList',
components:{
popComponents
},
data() {
return {
lat: '',
lng: '',
list: [],
popupVisible: false,
n:10,
setTimeoutTimer:'',
latitude:'',
longitude:'',
name:'',
idleberths:'',
juli:''
}
},
created() {
this.lat = this.$route.query.lat
this.lng = this.$route.query.lng
this.queryParkingLots()
},
methods: {
queryParkingLots() { // 获取列表
var salt = this.$utils.myCommonSalt(32);
var jsondata = {
app_id: this.$utils.myVarAppid,
deviceInfo: this.$utils.myDeviceInfo,
salt: salt,
sign_type: "md5",
latitude: this.lat,
longitude: this.lng,
type: '02',
limit: '50',
isShowOther: '0'
}
jsondata.sign = this.$utils.signObject(jsondata)
// jsondata.sign = md5sign
queryParkingLots(jsondata).then(response => {
this.list = response.data
console.log(this.list)
})
},
// 进入列表详情
parkInfo: function(i){
console.log(i)
this.$router.push({
name:'parkinfo',
query: {
idleberths:i.idleberths,
name:i.name,
address:i.address,
julis:this.toDecimal2((parseFloat(i.distance)*0.001)),
guiz:JSON.stringify(i.chargeDetail),
longitude:i.longitude,
latitude:i.latitude,
pklNo:i.pklNo
}
})
},
gaodec: function (i) {
let me = this
this.latitude = i.latitude
this.longitude = i.longitude
this.name = i.name
this.idleberths = i.idleberths
this.juli = this.toDecimal2((parseFloat(i.distance)*0.001))
this.popupVisible = true
this.n = 10
this.popupVisible = true
this.setTimeoutTimer = setInterval(function () {
if(me.n == 0){
window.location.href = "http://api.map.baidu.com/marker?location="+this.latitude+","+this.longitude+"&title=目标地址&content="+this.name+"&output=html&src=webapp.baidu.openAPIdemo"
return
}
me.n --
console.log(me.n)
},1000)
},
toDecimal2: function (x) {
var f = parseFloat(x);
if (isNaN(f)) {
return false;
}
var f = Math.round(x * 100) / 100;
var s = f.toString();
var rs = s.indexOf('.');
if (rs < 0) {
rs = s.length;
s += '.';
}
while (s.length <= rs + 2) {
s += '0';
}
return s;
}
}
}
</script>
<style scoped lang="scss">
.park-wrap > li {
height: 130px;
padding: 10px 0 0 10px;
margin-bottom: 20px;
background: #fff url("../../assets/images/map/pinfo.png") right 10px top 10px no-repeat;
background-size: 37% 80px;
}
.park-main {
}
.park-left {
/*flex: 1;*/
/*padding: 10px;*/
}
.park-status {
padding: 2px 8px;
color: #FFF;
border-radius: 4px;
}
.bgcz{
background: #07b530;
}
.bgjz{
background: #FC3817;
}
.bgtm{
background: #f00;
}
.park-num-color {
color: #4caf50;
}
.park-bottom {
margin-top: 20px;
display: flex;
color: #0d72e2;
p {
width: 37%;
text-align: center;
}
}
</style>
|