center.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="center" id="model">
  3. <CusTabs :tabs="areaTabs" :active.sync="areaType" @tab-click="areaTabClick" />
  4. </div>
  5. </template>
  6. <script>
  7. import CusTabs from './components/CusTabs.vue';
  8. import {mapMutations} from 'vuex';
  9. import renderModel from './three/renderModel'
  10. export default {
  11. name: 'Center',
  12. data () {
  13. return {
  14. areaType: '',
  15. areaTabs: [{name: '全部', value: ''}, {name: '北区', value: '1'}, {name: '南区', value: '2'}],
  16. modelApi: null,
  17. };
  18. },
  19. components: {
  20. CusTabs
  21. },
  22. mounted () {
  23. this.initThree();
  24. },
  25. methods: {
  26. ...mapMutations('userState', ['setAreaType']),
  27. areaTabClick () {
  28. this.setAreaType(this.areaType)
  29. if (this.areaType === '2') {
  30. const target = {
  31. position: {x: -68.07200022928386, y: -573.3788080485533, z: 358.4490004266269}, // 相机目标位置
  32. targetContent: {x: -68.07200022928386, y: -58.61085804855406, z: -48.804124573372285}, // 控制器目标焦点
  33. time: 1000 // 动画时间
  34. };
  35. this.modelApi.flyTo(target,1.2)
  36. } else if (this.areaType === '1') {
  37. const target = {
  38. position: {x: 2.9287885309866817, y: -403.9781890137868, z: 376.33849737114133}, // 相机目标位置
  39. targetContent: {x: -2.929806062765964, y: 15.311141772539063, z: 44.637911374941055}, // 控制器目标焦点
  40. time: 1000 // 动画时间
  41. };
  42. this.modelApi.flyTo(target)
  43. } else {
  44. const target = {
  45. position: {x: -20, y: -652, z: 500}, // 相机目标位置
  46. targetContent: {x: -20, y: -20, z: 0}, // 控制器目标焦点
  47. time: 1000 // 动画时间
  48. };
  49. this.modelApi.flyTo(target)
  50. }
  51. },
  52. initThree () {
  53. setTimeout(() => {
  54. this.modelApi = new renderModel('#model')
  55. this.modelApi.init()
  56. }, 100)
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang='scss' scoped>
  62. .center {
  63. // background: url("~@/assets/images/center.jpg") no-repeat;
  64. // background-size:cover ;
  65. // width: calc(100% - 806px);
  66. width: 100%;
  67. // margin: auto auto 0;
  68. height: 100%;
  69. position: relative;
  70. .tabs {
  71. position: absolute;
  72. top: 90px;
  73. left: 403px;
  74. z-index: 45;
  75. }
  76. ::v-deep .tag3d {
  77. // color: #fff;
  78. font-weight: 500;
  79. font-size: 20px;
  80. }
  81. ::v-deep .load-container {
  82. background-color: rgba(12, 74, 110, 0.5);
  83. border: 2px solid rgba(165, 243, 252, 0.8);
  84. padding: 10px;
  85. .title {
  86. font-weight: bold;
  87. margin-left: 4px;
  88. border-left: 4px solid #2dd4bf;
  89. padding-left: 2px;
  90. margin-top: 3px;
  91. margin-bottom: 3px;
  92. font-size: 20px;
  93. }
  94. .data-grid {
  95. display: grid;
  96. grid-template-columns: repeat(2, 1fr);
  97. gap: 2px;
  98. padding: 0 3px;
  99. >div {
  100. background-color: #0F4565;
  101. white-space: nowrap;
  102. margin-right: 4px;
  103. padding: 5px;
  104. margin-top: 4px;
  105. .value {
  106. color: #06E3F9; // 根据需要调整颜色
  107. }
  108. }
  109. }
  110. }
  111. }
  112. </style>