Blame view

src/views/mapsection.vue 9.17 KB
0e3a2706   liuqimichale   地图 title
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
  <template>
      <div>
        <ul class="title-wrap">
          <li>
            <img src="../assets/img/parkingtotal.svg">
            <div>
              <p>{{parkingtotal|formatNum}}</p>
              <p>停车场总数</p>
            </div>
          </li>
          <li>
            <img src="../assets/img/membertotal.svg">
            <div>
              <p>{{membertotal|formatNum}}</p>
              <p>会员总数</p>
            </div>
          </li>
          <li>
            <img src="../assets/img/incometotal.svg">
            <div>
              <p>{{incometotal|formatNum}}</p>
              <p>今日收入总数</p>
            </div>
          </li>
          <li>
            <img src="../assets/img/ordertotal.svg">
            <div>
              <p>{{ordertotal|formatNum}}</p>
              <p>今日订单数</p>
            </div>
          </li>
        </ul>
f16dcfc1   liuqimichale   引入地图
33
        <div class="allmap" id="allmap"></div>
bfcfca75   liuqimichale   办事处
34
35
36
37
38
        <ul class="type-wrap">
          <li>紧张</li>
          <li>正常</li>
          <li>空闲</li>
        </ul>
32e359df   liuqimichale   betterScroll
39
40
41
42
43
        <div class="park-wrap" ref="parkwrap">
            <ul class="content" ref="">
              <li v-for="(item, index) in parkList" :key="index" :title="item.name" :class="{'current-active':index===currentIndex}" @click="currentPark(item, index)">{{ item.name }}</li>
            </ul>
        </div>
bfcfca75   liuqimichale   办事处
44
        <div class="flexfm" ></div>
0e3a2706   liuqimichale   地图 title
45
46
47
48
      </div>
  </template>
  
  <script>
32e359df   liuqimichale   betterScroll
49
  import BScroll from 'better-scroll'
fdddb2fe   liuqimichale   地图覆盖物
50
51
52
  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的方式导入图片文件
32e359df   liuqimichale   betterScroll
53
  
0e3a2706   liuqimichale   地图 title
54
55
56
57
58
59
60
  export default {
    name: 'mapsection',
    data() {
      return {
        parkingtotal: '7338',
        membertotal: '738',
        incometotal: '1156738',
bfcfca75   liuqimichale   办事处
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
        ordertotal: '6738',
        parkList: [
          {name:'西局街道办事处12321312312312',id:'1'},
          {name:'西局街道办事处',id:'2'},
          {name:'西局街道办事处',id:'3'},
          {name:'西局街道办事处',id:'4'},
          {name:'西局街道办事处',id:'5'},
          {name:'西局街道办事处',id:'6'},
          {name:'西局街道办事处',id:'7'},
          {name:'西局街道办事处',id:'8'},
          {name:'西局街道办事处',id:'9'},
          {name:'西局街道办事处',id:'10'},
          {name:'西局街道办事处',id:'11'},
          {name:'西局街道办事处',id:'12'},
  
        ],
        currentIndex:0
      }
    },
b850acb7   liuqimichale   地图覆盖物
80
81
82
    created() {
  
    },
32e359df   liuqimichale   betterScroll
83
84
85
86
87
88
89
90
    mounted() {
      this.$nextTick(() => {
        this.scroll = new BScroll(this.$refs.parkwrap,{
          scrollbars:true,//显示滚动条(默认是false不显示)
          mouseWheel:true,//支持鼠标触发区域滚动
          bounce:true,//取消达到边界的缓冲效果
        })
      })
fdddb2fe   liuqimichale   地图覆盖物
91
92
      let data = {
        nurseryInfo: [
48c2893f   liuqimichale   地图覆盖物
93
94
95
          {Name:'万达停车场1',MapPointX:'111.742579',MapPointY:'40.818675',status:0,free:30,total:1000},
          {Name:'万达停车场2',MapPointX:'111.722579',MapPointY:'40.878675',status:1,free:40,total:800},
          {Name:'万达停车场333333',MapPointX:'111.782579',MapPointY:'40.818675',status:2,free:300,total:500}
fdddb2fe   liuqimichale   地图覆盖物
96
97
98
        ]
      }
      this.baiduMap(data)
bfcfca75   liuqimichale   办事处
99
100
101
102
103
    },
    methods: {
      currentPark(item, index) {
        console.log(item)
        this.currentIndex = index
fdddb2fe   liuqimichale   地图覆盖物
104
105
        let data = {
          nurseryInfo: [
48c2893f   liuqimichale   地图覆盖物
106
107
108
            {Name:'万达停车场11111',MapPointX:'111.742579',MapPointY:'40.818675',status:2,free:300,total:500},
            {Name:'万达停车场22222',MapPointX:'111.722579',MapPointY:'40.878675',status:0,free:30,total:1000},
            {Name:'万达停车场333333',MapPointX:'111.782579',MapPointY:'40.818675',status:1,free:40,total:800}
fdddb2fe   liuqimichale   地图覆盖物
109
110
111
          ]
        }
        this.baiduMap(data)
f16dcfc1   liuqimichale   引入地图
112
      },
fdddb2fe   liuqimichale   地图覆盖物
113
      baiduMap (data) {
4d91ea5c   liuqimichale   地图覆盖物
114
        var map = new BMap.Map('allmap', {enableMapClick: false})
f16dcfc1   liuqimichale   引入地图
115
116
        var point = new BMap.Point(111.742579, 40.818675)
        map.centerAndZoom(point, 12)
4d91ea5c   liuqimichale   地图覆盖物
117
118
        var mapStyle={  style : "midnight" }
        map.setMapStyle(mapStyle);
c421e638   liuqimichale   引入地图
119
120
        // var marker = new BMap.Marker(point)  // 创建标注
        // map.addOverlay(marker)              // 将标注添加到地图中
fdddb2fe   liuqimichale   地图覆盖物
121
  
c421e638   liuqimichale   引入地图
122
123
124
125
126
        map.clearOverlays();
        var i = 0;
        var points = [];
        for (var item in data.nurseryInfo) {
          (function (x) {
48c2893f   liuqimichale   地图覆盖物
127
            var itemthat = item;
c421e638   liuqimichale   引入地图
128
129
130
            //创建标注
            var pt = new BMap.Point(data.nurseryInfo[item].MapPointX, data.nurseryInfo[item].MapPointY);
            points[i] = pt;
fdddb2fe   liuqimichale   地图覆盖物
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
            if(data.nurseryInfo[item].status === 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.nurseryInfo[item].status === 1){
              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});
            }
1179eb82   liuqimichale   地图覆盖物
153
            console.log(data)
c421e638   liuqimichale   引入地图
154
            map.addOverlay(marker);
fdddb2fe   liuqimichale   地图覆盖物
155
            var myLabel;
48c2893f   liuqimichale   地图覆盖物
156
  
fdddb2fe   liuqimichale   地图覆盖物
157
            marker.addEventListener("mouseover", function (e) {
1179eb82   liuqimichale   地图覆盖物
158
              console.log(e)
fdddb2fe   liuqimichale   地图覆盖物
159
                myLabel = new BMap.Label(
1179eb82   liuqimichale   地图覆盖物
160
                  `<div class="dislog-wrap">
48c2893f   liuqimichale   地图覆盖物
161
                    <div class="dialog-header" title="${data.nurseryInfo[itemthat].Name}">${data.nurseryInfo[itemthat].Name}</div>
1179eb82   liuqimichale   地图覆盖物
162
                    <ul class="dislog-body">
48c2893f   liuqimichale   地图覆盖物
163
164
165
                      <li><div>${data.nurseryInfo[itemthat].free}</div><div>空闲</div></li>
                      <li><div>/</div><div></div></li>
                      <li><div>${data.nurseryInfo[itemthat].total}</div><div>总数</div></li>
1179eb82   liuqimichale   地图覆盖物
166
167
                    </ul>
                  </div>`,
fdddb2fe   liuqimichale   地图覆盖物
168
                {
48c2893f   liuqimichale   地图覆盖物
169
                  offset: new BMap.Size(25, -35),   //label的偏移量,为了让label的中心显示在点上
1179eb82   liuqimichale   地图覆盖物
170
                  position: pt
fdddb2fe   liuqimichale   地图覆盖物
171
172
173
                });
  
              myLabel.setStyle({
b850acb7   liuqimichale   地图覆盖物
174
                  // color: "#0f0",
1179eb82   liuqimichale   地图覆盖物
175
                  // fontSize: "12px",
48c2893f   liuqimichale   地图覆盖物
176
                  padding: "0",
b850acb7   liuqimichale   地图覆盖物
177
                  // whiteSpace: "normal",
48c2893f   liuqimichale   地图覆盖物
178
                  backgroundColor: "",
1179eb82   liuqimichale   地图覆盖物
179
                  border: "0px",
b850acb7   liuqimichale   地图覆盖物
180
                  // zIndex: "1000"
fdddb2fe   liuqimichale   地图覆盖物
181
182
                }
              );
fdddb2fe   liuqimichale   地图覆盖物
183
184
              map.addOverlay(myLabel);
            });
4d91ea5c   liuqimichale   地图覆盖物
185
186
187
188
  
            marker.addEventListener("mouseout", function (e) {
              map.removeOverlay(myLabel);
            });
fdddb2fe   liuqimichale   地图覆盖物
189
            i++;
c421e638   liuqimichale   引入地图
190
191
192
          })(i);
        }
  
0e3a2706   liuqimichale   地图 title
193
194
195
196
197
198
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
f16dcfc1   liuqimichale   引入地图
199
200
201
202
203
204
    .allmap{
      position: absolute;
      top:80px;
      left: 0;
      right: 0;
      bottom: 0;
b850acb7   liuqimichale   地图覆盖物
205
206
207
      .parkpop-content{
        background-color: black;
      }
f16dcfc1   liuqimichale   引入地图
208
    }
b850acb7   liuqimichale   地图覆盖物
209
  
0e3a2706   liuqimichale   地图 title
210
211
212
213
    .title-wrap{
      display: flex;
      padding-top: 17px;
      padding-bottom: 18px;
bfcfca75   liuqimichale   办事处
214
      background:rgba(0,45,140,.6);
0e3a2706   liuqimichale   地图 title
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
        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   办事处
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
    .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{
      width: 120px;
120cce1d   liuqimichale   办事处
281
      max-height: 124px;
bfcfca75   liuqimichale   办事处
282
283
284
285
286
      position: absolute;
      right: 11px;
      bottom: 11px;
      background-color: #0D3689;
      font-size: 12px;
32e359df   liuqimichale   betterScroll
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
      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   办事处
308
      }
32e359df   liuqimichale   betterScroll
309
  
bfcfca75   liuqimichale   办事处
310
    }
0e3a2706   liuqimichale   地图 title
311
  </style>