Blame view

src/views/mapsection.vue 11.3 KB
0e3a2706   liuqimichale   地图 title
1
2
3
4
5
6
  <template>
      <div>
        <ul class="title-wrap">
          <li>
            <img src="../assets/img/parkingtotal.svg">
            <div>
adf82b69   liuqimichale   调取接口
7
              <p> <countTo :startVal='startVal' :endVal='parkingtotal' :duration='durationTime'></countTo></p>
0e3a2706   liuqimichale   地图 title
8
9
10
11
12
13
              <p>停车场总数</p>
            </div>
          </li>
          <li>
            <img src="../assets/img/membertotal.svg">
            <div>
adf82b69   liuqimichale   调取接口
14
              <p><countTo :startVal='startVal' :endVal='membertotal' :duration='durationTime'></countTo></p>
0e3a2706   liuqimichale   地图 title
15
16
17
18
19
20
              <p>会员总数</p>
            </div>
          </li>
          <li>
            <img src="../assets/img/incometotal.svg">
            <div>
adf82b69   liuqimichale   调取接口
21
              <p><countTo :startVal='startVal' :endVal='incometotal' :duration='durationTime'></countTo></p>
0e3a2706   liuqimichale   地图 title
22
23
24
25
26
27
              <p>今日收入总数</p>
            </div>
          </li>
          <li>
            <img src="../assets/img/ordertotal.svg">
            <div>
d655a1f6   liuqimichale   正式地址
28
29
30
              <p>
                <countTo :startVal='startVal' :endVal='getOrderNum' :duration='durationTime'></countTo>
              </p>
0e3a2706   liuqimichale   地图 title
31
32
33
34
              <p>今日订单数</p>
            </div>
          </li>
        </ul>
f16dcfc1   liuqimichale   引入地图
35
        <div class="allmap" id="allmap"></div>
bfcfca75   liuqimichale   办事处
36
37
38
39
40
        <ul class="type-wrap">
          <li>紧张</li>
          <li>正常</li>
          <li>空闲</li>
        </ul>
32e359df   liuqimichale   betterScroll
41
42
        <div class="park-wrap" ref="parkwrap">
            <ul class="content" ref="">
adf82b69   liuqimichale   调取接口
43
              <li v-for="(item, index) in parkList" :key="index" :title="item.areaName" :class="{'current-active':index===currentIndex}" @click="currentPark(item.id, index)">{{ item.areaName }}</li>
32e359df   liuqimichale   betterScroll
44
45
            </ul>
        </div>
bfcfca75   liuqimichale   办事处
46
        <div class="flexfm" ></div>
0e3a2706   liuqimichale   地图 title
47
48
49
50
      </div>
  </template>
  
  <script>
32e359df   liuqimichale   betterScroll
51
  import BScroll from 'better-scroll'
fdddb2fe   liuqimichale   地图覆盖物
52
53
54
  import busyCar from '../assets/img/busy-status.png'; //以import的方式导入图片文件
  import normalCar from '../assets/img/normal-status.png'; //以import的方式导入图片文件
  import idleCar from '../assets/img/idle-status.png'; //以import的方式导入图片文件
adf82b69   liuqimichale   调取接口
55
56
57
  import countTo from 'vue-count-to'
  import { parkAddress, memberAddress, incomeAddress, serviceAddress, parkListAddress } from '../api/api'
  import { mapGetters } from 'vuex'
32e359df   liuqimichale   betterScroll
58
  
0e3a2706   liuqimichale   地图 title
59
60
  export default {
    name: 'mapsection',
adf82b69   liuqimichale   调取接口
61
    components: { countTo },
0e3a2706   liuqimichale   地图 title
62
63
    data() {
      return {
adf82b69   liuqimichale   调取接口
64
65
66
67
68
        durationTime:3000,
        startVal: 0,
        parkingtotal: 0,
        membertotal: 0,
        incometotal: 0,
bfcfca75   liuqimichale   办事处
69
        ordertotal: '6738',
adf82b69   liuqimichale   调取接口
70
71
72
        parkList: [],
        currentIndex:0,
        firstItem:''
bfcfca75   liuqimichale   办事处
73
74
      }
    },
adf82b69   liuqimichale   调取接口
75
76
77
    computed: {
      ...mapGetters(['getOrderNum'])
    },
b850acb7   liuqimichale   地图覆盖物
78
    created() {
adf82b69   liuqimichale   调取接口
79
80
81
82
      parkAddress({
        orgIds: this.GLOBAL.paramsvariables
      }).then((response)=>{
        const data = response.data.data
f58839aa   liuqimichale   dy
83
        this.parkingtotal = data.allNum
adf82b69   liuqimichale   调取接口
84
85
86
87
      })
      memberAddress({
        orgIds: this.GLOBAL.paramsvariables
      }).then((response)=>{
1adfb32d   Andy   add cf
88
        const data = response.data.data;
adf82b69   liuqimichale   调取接口
89
90
91
92
93
94
        this.membertotal = data.registerNum
      })
      incomeAddress({
        orgIds: this.GLOBAL.paramsvariables
      }).then((response)=>{
        const data = response.data.data
bd499a6f   liuqimichale   正式地址
95
        this.incometotal = Math.round(data.totalPay/100)
adf82b69   liuqimichale   调取接口
96
97
      })
      serviceAddress({
1adfb32d   Andy   add cf
98
        orgId: '10003'
adf82b69   liuqimichale   调取接口
99
100
101
      }).then((response)=>{
        const data = response.data.data
        console.log(data)
33e582e5   liuqimichale   刷新时间修改为3分钟
102
103
104
105
        const newData = data.filter(item => item.areaName.indexOf('测试') < 0)
        this.parkList = newData
        console.log(newData)
        this.firstItem = newData[0].id
adf82b69   liuqimichale   调取接口
106
107
        this.currentPark(this.firstItem,0)
      })
b850acb7   liuqimichale   地图覆盖物
108
    },
32e359df   liuqimichale   betterScroll
109
110
111
112
113
114
115
116
    mounted() {
      this.$nextTick(() => {
        this.scroll = new BScroll(this.$refs.parkwrap,{
          scrollbars:true,//显示滚动条(默认是false不显示)
          mouseWheel:true,//支持鼠标触发区域滚动
          bounce:true,//取消达到边界的缓冲效果
        })
      })
adf82b69   liuqimichale   调取接口
117
118
119
120
121
122
123
124
      // let data = {
      //   nurseryInfo: [
      //     {Name:'万达停车场1',MapPointX:'111.742579',MapPointY:'40.818675',status:0,free:30,total:1000},
      //     {Name:'万达停车场2',MapPointX:'111.622579',MapPointY:'40.878675',status:1,free:40,total:800},
      //     {Name:'万达停车场333333',MapPointX:'111.782579',MapPointY:'40.778675',status:2,free:300,total:500}
      //   ]
      // }
      // this.baiduMap(data)
bfcfca75   liuqimichale   办事处
125
126
127
    },
    methods: {
      currentPark(item, index) {
bfcfca75   liuqimichale   办事处
128
        this.currentIndex = index
adf82b69   liuqimichale   调取接口
129
130
131
132
133
134
135
136
137
138
139
140
141
        let nurseryInfo = []
  
        parkListAddress({
          blockIds: [item]
        }).then((response)=>{
          const data = response.data.data
          console.log(response)
          nurseryInfo = data
          this.baiduMap(nurseryInfo)
        })
  
  
  
f16dcfc1   liuqimichale   引入地图
142
      },
fdddb2fe   liuqimichale   地图覆盖物
143
      baiduMap (data) {
adf82b69   liuqimichale   调取接口
144
145
146
147
148
        if(data.length === 0){
          var map = new BMap.Map('allmap', {enableMapClick: false})
          var point = new BMap.Point(111.742579, 40.878675)
          map.centerAndZoom(point, 14)
          var mapStyle={  style : "midnight" }
b56985bf   liuqimichale   弹窗
149
          map.enableScrollWheelZoom(false);
adf82b69   liuqimichale   调取接口
150
151
152
153
154
155
156
157
          map.setMapStyle(mapStyle);
          // var marker = new BMap.Marker(point)  // 创建标注
          // map.addOverlay(marker)              // 将标注添加到地图中
          map.clearOverlays();
  
        }else{
          var map = new BMap.Map('allmap', {enableMapClick: false})
          var point = new BMap.Point(data[0].lonId, data[0].latId)
6858abb9   liuqimichale   订单中心 停车场
158
          map.centerAndZoom(point, 15)
adf82b69   liuqimichale   调取接口
159
          var mapStyle={  style : "midnight" }
b56985bf   liuqimichale   弹窗
160
          map.enableScrollWheelZoom(false);
adf82b69   liuqimichale   调取接口
161
162
163
          map.setMapStyle(mapStyle);
          // var marker = new BMap.Marker(point)  // 创建标注
          // map.addOverlay(marker)              // 将标注添加到地图中
fdddb2fe   liuqimichale   地图覆盖物
164
  
adf82b69   liuqimichale   调取接口
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
          map.clearOverlays();
          var i = 0;
          var points = [];
          for (var item in data) {
            (function (x) {
              var itemthat = item;
              //创建标注
              var pt = new BMap.Point(data[item].lonId, data[item].latId);
              points[i] = pt;
              if(data[item].freeBrethNum/data[item].plBerthNum == 0){
                var myIcon = new BMap.Icon(busyCar,
                  new BMap.Size(29, 40), {
                    offset: new BMap.Size(10, 40),
                    textColor: '#fff'
                  });
                var marker = new BMap.Marker(pt,{icon:myIcon});
              } else if(data[item].freeBrethNum/data[item].plBerthNum <= 0.3){
                var myIcon = new BMap.Icon(normalCar,
                  new BMap.Size(29, 40), {
                    offset: new BMap.Size(10, 40),
                    textColor: '#fff'
                  });
                var marker = new BMap.Marker(pt,{icon:myIcon});
              } else {
                var myIcon = new BMap.Icon(idleCar,
                  new BMap.Size(29, 40), {
                    offset: new BMap.Size(10, 40),
                    textColor: '#fff'
                  });
                var marker = new BMap.Marker(pt,{icon:myIcon});
              }
fdddb2fe   liuqimichale   地图覆盖物
196
197
198
199
200
              var myIcon = new BMap.Icon(busyCar,
                new BMap.Size(29, 40), {
                  offset: new BMap.Size(10, 40),
                  textColor: '#fff'
                });
48c2893f   liuqimichale   地图覆盖物
201
  
adf82b69   liuqimichale   调取接口
202
203
204
205
              marker.setTop(true,27000000);
              map.addOverlay(marker);
              var myLabel;
  
9f216986   liuqimichale   弹窗
206
              marker.addEventListener("mouseover", (e)=> {
b56985bf   liuqimichale   弹窗
207
                map.removeOverlay(myLabel);
adf82b69   liuqimichale   调取接口
208
                var that = this;
9f216986   liuqimichale   弹窗
209
                let tmpHtml = '';
9f216986   liuqimichale   弹窗
210
211
212
213
214
215
216
                for(let i=0;i<JSON.parse(data[itemthat].plRate).length;i++){
                  //console.log(data[itemthat].plRate)
                  tmpHtml += "<li>"+JSON.parse(data[itemthat].plRate)[i].standard+"</li>"
                }
  
                // label = null
                // map.removeOverlay(myLabel);
fdddb2fe   liuqimichale   地图覆盖物
217
                myLabel = new BMap.Label(
1179eb82   liuqimichale   地图覆盖物
218
                  `<div class="dislog-wrap">
9f216986   liuqimichale   弹窗
219
                    <div class="dialog-header" title="${data[itemthat].plAddress}">${data[itemthat].plName}</div>
b56985bf   liuqimichale   弹窗
220
221
222
223
224
225
226
227
                    <div class="dialog-address" title="${data[itemthat].plAddress}">${data[itemthat].plAddress}</div>
                    <ul class="dislog-body">
                      <li><div>${data[itemthat].freeBrethNum}</div><div>空闲</div></li>
                      <li></li>
                      <li><div>${data[itemthat].plBerthNum}</div><div>总数</div></li>
                    </ul>
                    <div class="dislog-footer">收费标准</div>
                    <ul class="dislog-footer-main">
9f216986   liuqimichale   弹窗
228
                      ${tmpHtml}
b56985bf   liuqimichale   弹窗
229
230
                    </ul>
                  </div>`,
adf82b69   liuqimichale   调取接口
231
                  {
b56985bf   liuqimichale   弹窗
232
                    offset: new BMap.Size(-225, -55),   //label的偏移量,为了让label的中心显示在点上
adf82b69   liuqimichale   调取接口
233
234
235
236
237
238
239
240
241
242
243
244
245
246
                    position: pt
                  });
                myLabel.setStyle({
                    // color: "#0f0",
                    // fontSize: "12px",
                    padding: "0",
                    // whiteSpace: "normal",
                    backgroundColor: "",
                    border: "0px",
                    zIndex: "1000"
                  }
                );
                marker.setLabel(myLabel)
                marker.setTop(true,27000000);
fdddb2fe   liuqimichale   地图覆盖物
247
  
adf82b69   liuqimichale   调取接口
248
              });
9f216986   liuqimichale   弹窗
249
250
251
              marker.addEventListener("mouseout", function (e) {
                map.removeOverlay(myLabel);
              });
adf82b69   liuqimichale   调取接口
252
253
254
              i++;
            })(i);
          }
4d91ea5c   liuqimichale   地图覆盖物
255
  
c421e638   liuqimichale   引入地图
256
257
        }
  
0e3a2706   liuqimichale   地图 title
258
259
260
261
262
263
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
f16dcfc1   liuqimichale   引入地图
264
265
266
267
268
269
    .allmap{
      position: absolute;
      top:80px;
      left: 0;
      right: 0;
      bottom: 0;
b850acb7   liuqimichale   地图覆盖物
270
271
272
      .parkpop-content{
        background-color: black;
      }
f16dcfc1   liuqimichale   引入地图
273
    }
b850acb7   liuqimichale   地图覆盖物
274
  
0e3a2706   liuqimichale   地图 title
275
276
277
278
    .title-wrap{
      display: flex;
      padding-top: 17px;
      padding-bottom: 18px;
adf82b69   liuqimichale   调取接口
279
      background:rgba(0,45,140,.9);
0e3a2706   liuqimichale   地图 title
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
        li{
        flex: 1;
        height: 45px;
        text-align: center;
        overflow: hidden;
        font-size: 0;
          img{
            display: inline-block;
            width: 45px;
            height: 45px;
            margin-right: 14px;
          }
          div{
            display: inline-block;
            vertical-align: top;
            text-align: left;
            max-width: 100px;
            overflow: hidden;
            p{
              &:nth-of-type(1){
                font-size:24px;
                font-weight:500;
                color:rgba(255,255,255,1);
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
              }
              &:nth-of-type(2){
                font-size:14px;
                font-weight:bold;
                color:rgba(0,207,254,.7);
                margin-top: 7px;
              }
            }
          }
      }
    }
bfcfca75   liuqimichale   办事处
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
    .type-wrap{
      padding-left: 10px;
      position: absolute;
      left: 11px;
      bottom: 11px;
      background-color: rgba(10,52,140,.8);
      li{
        float: left;
        height: 20px;
        line-height: 20px;
        margin-right: 10px;
        padding-left: 12px;
        font-size: 12px;
        color:rgba(255,255,255,.7);
        background-repeat: no-repeat;
        background-position: 0 center;
        &:nth-of-type(1){
          background-image: url("../assets/img/busy-type.png");
        }
        &:nth-of-type(2){
          background-image: url("../assets/img/nomal-type.png");
        }
        &:nth-of-type(3){
          background-image: url("../assets/img/idle-type.png");
        }
      }
    }
    .park-wrap{
2ca6d27d   liuqimichale   正式地址
345
346
      width: 200px;
      max-height: 164px;
bfcfca75   liuqimichale   办事处
347
348
349
350
351
      position: absolute;
      right: 11px;
      bottom: 11px;
      background-color: #0D3689;
      font-size: 12px;
32e359df   liuqimichale   betterScroll
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
      overflow: hidden;
  
      .content{
        height:100%;
        li{
          padding-left: 26px;
          height: 20px;
          line-height: 20px;
          color:rgba(255,255,255,.7);
          background-image:url("../assets/img/office-icon.png");
          background-repeat: no-repeat;
          background-position: 9px center;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          cursor: pointer;
        }
        .current-active{
          color:rgba(255,255,255,1);
          background-image:url("../assets/img/officeactive-icon.png");
        }
bfcfca75   liuqimichale   办事处
373
      }
32e359df   liuqimichale   betterScroll
374
  
bfcfca75   liuqimichale   办事处
375
    }
0e3a2706   liuqimichale   地图 title
376
  </style>