index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="csq-container" v-if="visible" :style="popupStyle">
  3. <div class="csq-popup-title">
  4. <span class="title-text">{{ title }}</span>
  5. <img src="@/assets/image/common/close.png" style="cursor: pointer" alt="" @click="closeModal" />
  6. </div>
  7. <div class="csq-popup-content">
  8. <PieChart style="height: 2.4rem"/>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import PieChart from './pie-chart/index.vue'
  14. export default {
  15. components: {
  16. PieChart
  17. },
  18. data() {
  19. return {
  20. title: '采砂区',
  21. visible: false,
  22. popupStyle: {
  23. position: 'absolute',
  24. top: '0',
  25. left: '0'
  26. }
  27. }
  28. },
  29. mounted() {
  30. this.$globalEventBus.$on('clickCsqModal', (data) => {
  31. // this.visible = true
  32. this.title = data.title
  33. this.showPopup(data)
  34. })
  35. },
  36. methods: {
  37. showPopup(data) {
  38. // 将笛卡尔坐标转换为屏幕坐标
  39. const cartesian = this.Cesium.Cartesian3.fromDegrees(data.position[0],data.position[1],data.position[2])
  40. const canvasPosition = this.Cesium.SceneTransforms.worldToWindowCoordinates (window.map.scene, cartesian);
  41. console.info(canvasPosition)
  42. if (canvasPosition) {
  43. this.popupStyle = {
  44. position: 'absolute',
  45. left: `${canvasPosition.x}px`,
  46. top: `${canvasPosition.y -400}px`, // 向上偏移,避免遮挡点位
  47. 'z-index': 1000
  48. }
  49. this.visible = true
  50. }
  51. },
  52. closeModal() {
  53. this.visible = false
  54. }
  55. },
  56. destroyed() {
  57. this.$globalEventBus.$off('clickCsqModal')
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. .csq-container {
  63. position: absolute;
  64. top: 8%;
  65. left: 50%;
  66. transform: translate(-50%, 0%);
  67. width: px-to-rem(430);
  68. z-index: 9999;
  69. .csq-popup-title {
  70. background: url('@/assets/image/common/popup_title_bg.png') no-repeat;
  71. background-size: 100% 100%;
  72. height: px-to-rem(39);
  73. display: flex;
  74. justify-content: space-between;
  75. align-items: center;
  76. padding: 0 px-to-rem(20);
  77. font-size: px-to-rem(16);
  78. color: #fff;
  79. .title-text {
  80. font-weight: bold;
  81. margin-left: px-to-rem(20);
  82. }
  83. }
  84. .csq-popup-content {
  85. height: px-to-rem(262);
  86. background: rgba(#233d6c, 0.8);
  87. padding: px-to-rem(10);
  88. }
  89. }
  90. </style>