北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
ZhAkps
2024-02-06 e8ec0a53b3fddeaf0f70ef38abad9a2ad1207c93
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
<template>
    <div class="addCollectionPanel">
        <div class="menutop">
            <div class="menuback" @click="back">
                <i class="el-icon-arrow-left"></i><span>返回</span>
            </div>
            <div class="menutitle">添加收藏</div>
        </div>
        <div style="width: 80%; margin: 0.2rem auto" id="sc">
            <el-input placeholder="请输入收藏点名称" v-model="scVal" size="small"></el-input>
            <div style="text-align: center; margin-top: 5%">
                <el-button size="mini" @click="cancelSc">取消</el-button>
                <el-button type="primary" size="mini" @click="addSc">确定</el-button>
            </div>
        </div>
    </div>
</template>
 
<script>
import store from "@/utils/store2.js";
export default {
    name: 'AddCollectionPanel',
    data() {
        return {
            scVal: ''
        }
    },
    methods: {
        addSc() {
            if (this.scVal == "") {
                this.$message("请输入收藏点名称");
            } else {
                this.scNewJm = false;
                // 此处执行收藏操作
                // 获取当前位置信息
                let posi = sgworld.Viewer.camera.position;
                let pointsInterest = {
                    destination: posi,
                    orientation: {
                        heading: Viewer.camera.heading,
                        pitch: Viewer.camera.pitch,
                        roll: Viewer.camera.roll,
                    },
                };
                // 添加收藏点名称和位置信息到临时对象,到位置收藏列表中
                let temObj = {};
                temObj.name = this.scVal;
                // 对象克隆
                temObj.position = JSON.parse(JSON.stringify(pointsInterest));
                // this.dataSc.push(temObj);
                if (window.locations == "" || window.locations == undefined) {
                    window.locations = [];
                }
                // 把位置信息添加到缓存中
                window.setLocations([...window.locations, temObj])
                //window.setLocations(this.dataSc);
 
                // 从缓存中取出当前所有位置信息
                //this.dataSc = window.locations;
 
                // 添加过之后把位置点名称置为空
                this.scVal = "";
                this.$message({
                    message: "已收藏,请到菜单>位置>收藏中查看",
                    duration: 1500,
                    type: "success",
                });
                this.back();
            }
        },
        cancelSc() {
            this.back();
        },
        back() {
            store.setAddFavoriteShow(false);
        }
    },
}
</script>
 
<style scoped>
.addCollectionPanel {
    position: absolute;
    width: 100%;
    height: 100%;
    color: black;
    background: white;
    z-index: 3001;
}
</style>