<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>
|