2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
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
274
275
276
277
278
279
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
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<!--
 * @Author: LuLu
 * @Date: 2023-05-11 19:30:21
 * @LastEditors: Andy
 * @LastEditTime: 2023-06-08 11:54:25
 * @FilePath: \cim-xian\src\views\xianCim\bottomViewer\wheelMenu.vue
 * @Description: 底部轮盘菜单组件
 思路:
 1.摆位置。把静态的位置排列放好
 2.公转。需要旋转的时候整体去旋转,此时各个item位置自然会发生偏移
 3.自转。不作处理的话item的朝向永远是向着容器圆心的,所以需要item自转
 4.在需要旋转时公转和自转同时进行
 5.加个transition过渡
-->
<template>
  <div class="wheelMenu">
    <div class="menuBox">
      <div
        class="round"
        :style="{ transform: 'rotate(' + orbitalRotation + 'deg)' }"
      >
        <div class="div1">
          <div
            :style="{ transform: 'rotate(' + selfRotation + 'deg)' }"
            class="content rotationSelf1"
          >
            <div class="menu" :style="currentMenu == 1 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(1)">资源中心</div>
            </div>
          </div>
        </div>
        <div class="div2">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 36) + 'deg)' }"
            class="content rotationSelf2"
          >
            <div class="menu" :style="currentMenu == 2 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(2)">运维中心</div>
            </div>
          </div>
        </div>
        <div class="div3">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 72) + 'deg)' }"
            class="content rotationSelf3"
          >
            <div class="menu" :style="currentMenu == 3 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(3)">应用中心</div>
            </div>
          </div>
        </div>
        <div class="div4">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 108) + 'deg)' }"
            class="content rotationSelf4"
          >
            <div class="menu" :style="currentMenu == 4 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(4)">生命线</div>
            </div>
          </div>
        </div>
        <div class="div5">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 144) + 'deg)' }"
            class="content rotationSelf5"
          >
            <div class="menu" :style="currentMenu == 5 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(5)">智慧景区</div>
            </div>
          </div>
        </div>
        <div class="div6">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 180) + 'deg)' }"
            class="content rotationSelf6"
          >
            <div class="menu" :style="currentMenu == 6 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(6)">智慧园区</div>
            </div>
          </div>
        </div>
        <div class="div7">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 216) + 'deg)' }"
            class="content rotationSelf7"
          >
            <div class="menu" :style="currentMenu == 7 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(7)">城市建造</div>
            </div>
          </div>
        </div>
        <div class="div8">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 252) + 'deg)' }"
            class="content rotationSelf8"
          >
            <div class="menu" :style="currentMenu == 8 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(8)">应急管理</div>
            </div>
          </div>
        </div>
        <div class="div9">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 288) + 'deg)' }"
            class="content rotationSelf9"
          >
            <div class="menu" :style="currentMenu == 9 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(9)">服务中心</div>
            </div>
          </div>
        </div>
        <div class="div10">
          <div
            :style="{ transform: 'rotate(' + (selfRotation - 324) + 'deg)' }"
            class="content rotationSelf10"
          >
            <div class="menu" :style="currentMenu == 10 ? activeBg : ''">
              <div class="menu_name" @click="clickMenu(10)">开发中心</div>
            </div>
          </div>
        </div>
      </div>
      <div class="turnLeftBtn" @click="turnLeft"></div>
      <div class="turnRightBtn" @click="turnRight"></div>
    </div>
  </div>
</template>
 
<script>
import { Cesium } from "../../../../public/CimSDK";
export default {
  name: "App",
  data() {
    return {
      preisWeb: true,
      orbitalRotation: 0, //公转
      selfRotation: 0, //自传
      currentMenu: 1, //当前菜单
      activeBg: {
        backgroundImage: "url(" + "./menu_btn_active.png" + ")",
        transform: "scale(2.075,6.25)",
      },
    };
  },
  methods: {
    turnRight() {
      this.orbitalRotation += 36;
      this.selfRotation -= 36;
 
      if (this.currentMenu > 1) {
        this.currentMenu--;
      } else {
        this.currentMenu = 10;
      }
      // this.getCameraParams()
      this.$nextTick(() => {
        window.dispatchEvent(new Event("resize")); //初始化echarts
      });
    },
    turnLeft() {
      this.selfRotation += 36;
      this.orbitalRotation -= 36;
 
      if (this.currentMenu < 10) {
        this.currentMenu++;
      } else {
        this.currentMenu = 1;
      }
      // this.getCameraParams()
      this.$nextTick(() => {
        window.dispatchEvent(new Event("resize")); //初始化echarts
      });
    },
    //点击菜单
    clickMenu(index) {
      // return //取消按钮点击切换
      if (index == this.currentMenu) {
        return;
      }
      //向右点击一个
      if (index - this.currentMenu == 1) {
        this.turnLeft();
      }
      //向左点击一个
      else if (index - this.currentMenu == -1) {
        this.turnRight();
      }
      //向右点击两个
      else if (index - this.currentMenu == 2) {
        this.turnLeft();
        this.turnLeft();
      }
      //向左点击两个
      else if (index - this.currentMenu == -2) {
        this.turnRight();
        this.turnRight();
      }
      //向右点击一个(边界条件)
      else if (index - this.currentMenu == -9) {
        this.turnLeft();
      }
      //向左点击一个(边界条件)
      else if (index - this.currentMenu == 9) {
        this.turnRight();
      }
      //向右点击两个(边界条件)
      else if (index - this.currentMenu == -8) {
        this.turnLeft();
        this.turnLeft();
      }
      //向右点击两个(边界条件)
      else if (index - this.currentMenu == 8) {
        this.turnRight();
        this.turnRight();
      }
      //改变当前菜单index
      this.currentMenu = index;
    },
    //刷新后根据路由切换菜单
    setMenuIndex() {
      switch (this.$route.path) {
        //2
        case "/xianCim/systemCenter":
          this.turnLeft();
          break;
        //3
        case "/xianCim/useCenter":
          this.turnLeft();
          this.turnLeft();
 
          break;
        //4
        case "/xianCim/UEView/lifeline":
          this.turnLeft();
          this.turnLeft();
          this.turnLeft();
          break;
 
        //5
        case "/xianCim/UEView/societyGovern":
          this.turnLeft();
          this.turnLeft();
          this.turnLeft();
          this.turnLeft();
          break;
 
        //6
        case "/xianCim/UEView/smartPark":
          this.turnRight();
          this.turnRight();
          this.turnRight();
          this.turnRight();
          this.turnRight();
          break;
        //7
        case "/xianCim/cityCenter":
          this.turnRight();
          this.turnRight();
          this.turnRight();
          this.turnRight();
          break;
        //8
        case "/xianCim/UEView/emergency":
          this.turnRight();
          this.turnRight();
          this.turnRight();
          break;
        //9
        case "/xianCim/servicesmanager":
          this.turnRight();
          this.turnRight();
          break;
        //10
        case "/xianCim/developmentCenter":
          this.turnRight();
          break;
        default:
          break;
      }
    },
    //获取镜头位置
    getCameraParams() {
      let viewer = sgworld._Viewer;
 
      var lon = Cesium.Math.toDegrees(
        viewer.camera.positionCartographic.longitude
      );
      var lat = Cesium.Math.toDegrees(
        viewer.camera.positionCartographic.latitude
      );
      var height = viewer.camera.positionCartographic.height; //Cesium.Math.toDegrees作用是把弧度转换成度数
      var heading = viewer.camera.heading;
      var pitch = viewer.camera.pitch;
      var roll = viewer.camera.roll;
      let position = {
        lon,
        lat,
        height,
        heading,
        pitch,
        roll,
      };
      return position;
    },
    //项UE发送获取位置请求
    askUEPosition(){
      let params = {
        func_name: "askUEPosition",
      };
      document
        .getElementById("djtIframe")
        .contentWindow.postMessage(params, "*");
    },
    flyTo() {
      let position = this.getCameraParams();
 
      if(isNaN(position.lat)){
        return;
      }
 
      console.log(" @@ position", position);
      console.log(" @@ heading", Cesium.Math.toDegrees(position.heading));
      console.log(" @@ pitch", Cesium.Math.toDegrees(position.pitch));
      let params = {
        func_name: "flyTo",
        data: {
          posX: position.lon,
          posY: position.lat,
          posZ: position.height,
          yaw: (180 / Math.PI) * position.heading - 90, //面向的方向
          pitch: Cesium.Math.toDegrees(position.pitch), //position.pitch ((180 / Math.PI) * position.pitch) % 360
          distance: 20000,
        },
      };
      //
      console.log(" @@ flyto all params:", params.data);
      document
        .getElementById("djtIframe")
        .contentWindow.postMessage(params, "*");
    },
 
    changeModule(val) {
      console.log(" @@ name", val);
      document.getElementById("djtIframe").contentWindow.postMessage(
        {
          func_name: "module",
          data: {
            name: val,
          },
        },
        "*"
      );
    },
  },
  mounted() {
    this.setMenuIndex();
  },
  watch: {
    currentMenu(val) {
      switch (val) {
        case 1:
          this.askUEPosition();
          //地球主页
          this.$router.push("/xianCim");
          this.preisWeb = true;
          break;
        case 2:
          //运维中心
          this.$router.push("/xianCim/systemCenter");
          this.preisWeb = false;
          break;
        case 3:
          //应用中心
          this.$router.push("/xianCim/useCenter");
          this.preisWeb = false;
          break;
        case 4:
          //生命线
          this.changeModule("生命线");
          if (this.preisWeb) {
            this.flyTo();
          }
          this.$router.push("/xianCim/UEView/lifeline");
          this.preisWeb = false;
          break;
        case 5:
          //智慧景区
          this.changeModule("智慧景区");
          if (this.preisWeb) {
            this.flyTo();
          }
          this.$router.push("/xianCim/UEView/societyGovern");
          this.preisWeb = false;
          break;
        case 6:
          //智慧园区
          this.changeModule("智慧园区");
          if (this.preisWeb) {
            this.flyTo();
          }
          this.$router.push("/xianCim/UEView/smartPark");
          this.preisWeb = false;
          break;
        case 7:
          //城市管理
          this.askUEPosition();
          this.$router.push("/xianCim/cityCenter");
          this.preisWeb = true;
          break;
        case 8:
          //应急管理
          this.changeModule("应急管理");
          if (this.preisWeb) {
            this.flyTo();
          }
          this.$router.push("/xianCim/UEView/emergency");
          this.preisWeb = false;
          break;
        case 9:
          //服务中心
          this.$router.push("/xianCim/servicesmanager");
          this.preisWeb = false;
          break;
        case 10:
          //开发中心
          this.$router.push("/xianCim/developmentCenter");
          this.preisWeb = false;
          break;
      }
    },
  },
};
</script>
 
<style>
.wheelMenu {
  width: auto;
  height: auto;
  pointer-events: all;
}
 
.round {
  position: relative;
  height: 800px;
  width: 800px;
  border-radius: 50%;
  transition: transform 1s;
}
 
.menuBox {
  transform-origin: 400px 23px;
  transform: scale(0.6, 0.2);
}
 
.div1 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(0deg);
  transform-origin: 60px 400px;
}
 
.div2 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(36deg);
  transform-origin: 60px 400px;
}
 
.div3 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(72deg);
  transform-origin: 60px 400px;
}
 
.div4 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(108deg);
  transform-origin: 60px 400px;
}
 
.div5 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(144deg);
  transform-origin: 60px 400px;
}
 
.div6 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(180deg);
  transform-origin: 60px 400px;
}
 
.div7 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(216deg);
  transform-origin: 60px 400px;
}
 
.div8 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(252deg);
  transform-origin: 60px 400px;
}
 
.div9 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(288deg);
  transform-origin: 60px 400px;
}
 
.div10 {
  position: absolute;
  left: calc(50% - 60px);
  transform: rotate(324deg);
  transform-origin: 60px 400px;
}
 
.content {
  transition: transform 1s;
}
 
.menu {
  width: 130px;
  height: 54px;
  background: url("../../../assets/img/menu_btn.png") no-repeat;
  background-size: 100% 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  transform: scale(1.66, 5);
  cursor: pointer;
}
 
.activeMenu {
  background: url("../../../assets/img/menu_btn_active.png") no-repeat !important;
}
 
.menu_name {
  font-size: 18px;
  font-family: PangMenZhengDao;
  font-weight: 400;
  color: #ffffff;
  /* text-shadow: 0px 3px 0px rgba(0, 9, 12, 0.34); */
  padding-bottom: 10px;
}
 
.rotationSelf1 {
  transform: rotate(0deg);
}
 
.rotationSelf2 {
  transform: rotate(-36deg);
}
 
.rotationSelf3 {
  transform: rotate(-72deg);
}
 
.rotationSelf4 {
  transform: rotate(-108deg);
}
 
.rotationSelf5 {
  transform: rotate(-144deg);
}
 
.rotationSelf6 {
  transform: rotate(-180deg);
}
 
.rotationSelf7 {
  transform: rotate(-216deg);
}
 
.rotationSelf8 {
  transform: rotate(-252deg);
}
 
.rotationSelf9 {
  transform: rotate(-288deg);
}
 
.rotationSelf10 {
  transform: rotate(-324deg);
}
 
.turnLeftBtn {
  position: absolute;
  left: -410px;
  top: 325px;
  transform: scale(1.66, 5);
  cursor: pointer;
  width: 150px;
  height: 26px;
  background: url("../../../assets/img/形状1拷贝.png") no-repeat;
  background-size: 100% 100%;
}
 
.turnRightBtn {
  position: absolute;
  right: -410px;
  top: 325px;
  transform: scale(1.66, 5);
  cursor: pointer;
  width: 150px;
  height: 26px;
  background: url("../../../assets/img/形状1.png") no-repeat;
  background-size: 100% 100%;
}
</style>