1
guanqb
2024-01-20 f13afcb61276061871b30bce17a7877287df0b67
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
<!--
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-09 10:36:05
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-04-27 19:54:44
 * @FilePath: \srs-police-affairs\src\components\map\components\yToolTip.vue
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
-->
<template>
    <div ref="toolTopBox" v-show="tooltipShow">
        <div class="tool-text">
            {{ handlerText }}
        </div>
    </div>
</template>
 
<script>
export default {
    data () {
        return {
            handlerText: '',
            tooltipShow: false
        }
    },
 
    mounted () {
        const that = this
 
        this.$EventBus.$on('showTooltip', params => {
            that.showTooltip(params)
        })
 
        this.$EventBus.$on('closeTooltip', () => {
            that.closeTooltip()
        })
    },
 
    methods: {
        showTooltip (params) {
            const that = this
 
            this.handlerText = params.text
 
            this.tooltipShow = true
 
            that.updateWindowCoord(params.position)
        },
 
        closeTooltip () {
            this.tooltipShow = false
        },
 
        updateWindowCoord (windowCoord) {
            let x = windowCoord.x + 12
            let y = windowCoord.y - this.$refs.toolTopBox.offsetHeight / 2
 
            this.$refs.toolTopBox.style.cssText = `
                position: fixed;
                z-index:99;
                transform:translate3d(${Math.round(x)}px,${Math.round(y)}px, 0);
            `
        }
    },
 
    destroyed () {
        this.$EventBus.$off('showTooltip')
        this.$EventBus.$off('closeTooltip')
    },
}
</script>
 
<style lang="scss" scoped>
.tool-text {
    position: relative;
    padding: 0.6vh;
    color: #fff;
    background: rgba(0, 0, 0, .7);
    border-radius: 0.6vh;
}
 
.tool-text::after {
    content: '';
    position: absolute;
    left: -0.8vh;
    border-top: 0.8vh solid transparent;
    border-right: 0.8vh solid rgba(0, 0, 0, .7);
    border-bottom: 0.8vh solid transparent;
}
</style>