|
@@ -4,7 +4,10 @@
|
|
id="mars3dContainer"
|
|
id="mars3dContainer"
|
|
class="mars3d-container"
|
|
class="mars3d-container"
|
|
/>
|
|
/>
|
|
- <button class="switch-to-pano">
|
|
|
|
|
|
+ <button
|
|
|
|
+ class="switch-pano"
|
|
|
|
+ @click="onClickSwitchPano"
|
|
|
|
+ >
|
|
<img
|
|
<img
|
|
src="@/assets/images/swkk/changjingdaolan.png"
|
|
src="@/assets/images/swkk/changjingdaolan.png"
|
|
alt=""
|
|
alt=""
|
|
@@ -12,11 +15,14 @@
|
|
>
|
|
>
|
|
<div>全景切换</div>
|
|
<div>全景切换</div>
|
|
</button>
|
|
</button>
|
|
|
|
+
|
|
|
|
+ <router-view />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import "mars3d/dist/mars3d.css"
|
|
import "mars3d/dist/mars3d.css"
|
|
|
|
+import axios from "axios"
|
|
import * as mars3d from "mars3d"
|
|
import * as mars3d from "mars3d"
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -25,9 +31,17 @@ export default {
|
|
return {
|
|
return {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- computed: {},
|
|
|
|
|
|
+ computed: {
|
|
|
|
+ ...globalMapState([
|
|
|
|
+ 'panoData',
|
|
|
|
+ ])
|
|
|
|
+ },
|
|
watch: {},
|
|
watch: {},
|
|
- created() {},
|
|
|
|
|
|
+ async created() {
|
|
|
|
+ let panoData = await this.fetchPanoData()
|
|
|
|
+ this.fixPanoData(panoData)
|
|
|
|
+ this.setPanoData(panoData)
|
|
|
|
+ },
|
|
mounted() {
|
|
mounted() {
|
|
this.initMap().then(
|
|
this.initMap().then(
|
|
(map) => {
|
|
(map) => {
|
|
@@ -58,6 +72,91 @@ export default {
|
|
destroyed() {}, //生命周期 - 销毁完成
|
|
destroyed() {}, //生命周期 - 销毁完成
|
|
activated() {},
|
|
activated() {},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ ...globalMapMutations([
|
|
|
|
+ 'setPanoData',
|
|
|
|
+ ]),
|
|
|
|
+ async fetchPanoData() {
|
|
|
|
+ const res = await axios({
|
|
|
|
+ method: 'get',
|
|
|
|
+ url: `https://zzbbh.4dage.com/YHT/Qjkk/local/WK1578926366500417536/someData.json?_=${Math.random()}`,
|
|
|
|
+ })
|
|
|
|
+ console.log('fetch pano data: ', res.data)
|
|
|
|
+ return res.data
|
|
|
|
+ },
|
|
|
|
+ // todo: 干啥呢?有用吗?
|
|
|
|
+ fixPanoData(panoData) {
|
|
|
|
+ let tmp = []
|
|
|
|
+ panoData.scenes.forEach((item) => {
|
|
|
|
+ panoData.catalogs.forEach((sub) => {
|
|
|
|
+ if (item.category == sub.id) {
|
|
|
|
+ if (tmp.indexOf(sub) < 0) {
|
|
|
|
+ tmp.push(sub)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ tmp = globalUtils.unique(tmp)
|
|
|
|
+
|
|
|
|
+ panoData.catalogs = tmp
|
|
|
|
+ let rootmp = []
|
|
|
|
+ tmp.forEach((item) => {
|
|
|
|
+ panoData.catalogRoot.forEach((sub) => {
|
|
|
|
+ sub.children = globalUtils.unique(sub.children)
|
|
|
|
+
|
|
|
|
+ if (sub.children.indexOf(item.id) > -1) {
|
|
|
|
+ rootmp.push(sub)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ rootmp = globalUtils.unique(rootmp)
|
|
|
|
+
|
|
|
|
+ let sortArr = panoData.catalogRoot.map((item) => item.name)
|
|
|
|
+ rootmp.sort((a, b) => {
|
|
|
|
+ return sortArr.indexOf(a.name) - sortArr.indexOf(b.name)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ panoData.catalogRoot = rootmp.map((item) => {
|
|
|
|
+ let temp = []
|
|
|
|
+ item.children = globalUtils.unique(item.children)
|
|
|
|
+ item.children.forEach((sub) => {
|
|
|
|
+ tmp.forEach((jj) => {
|
|
|
|
+ if (jj.id == sub) {
|
|
|
|
+ temp.push(sub)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ return {
|
|
|
|
+ ...item,
|
|
|
|
+ children: temp,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ panoData.catalogs = tmp
|
|
|
|
+
|
|
|
|
+ let cid = "c_" + globalUtils.randomWord(true, 8, 8)
|
|
|
|
+
|
|
|
|
+ if (panoData.catalogRoot.length <= 0) {
|
|
|
|
+ panoData.catalogRoot.push({
|
|
|
|
+ id: "r_" + globalUtils.randomWord(true, 8, 8),
|
|
|
|
+ name: "全部场景",
|
|
|
|
+ children: [cid],
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (panoData.catalogs.length <= 0) {
|
|
|
|
+ panoData.catalogs.push({
|
|
|
|
+ id: cid,
|
|
|
|
+ name: "默认二级分组",
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (panoData.firstScene) {
|
|
|
|
+ panoData.firstScene = panoData.scenes.find(
|
|
|
|
+ (item) => item.sceneCode == panoData.firstScene.sceneCode
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ },
|
|
// 初始化地图
|
|
// 初始化地图
|
|
async initMap() {
|
|
async initMap() {
|
|
// 读取 config.json 配置文件
|
|
// 读取 config.json 配置文件
|
|
@@ -131,6 +230,9 @@ export default {
|
|
cutVr(code, index) {
|
|
cutVr(code, index) {
|
|
this.$emit("mapCutVr", code, index)
|
|
this.$emit("mapCutVr", code, index)
|
|
},
|
|
},
|
|
|
|
+ onClickSwitchPano() {
|
|
|
|
+ this.$router.push({ name: 'PanoList' })
|
|
|
|
+ }
|
|
}, //如果页面有keep-alive缓存功能,这个函数会触发
|
|
}, //如果页面有keep-alive缓存功能,这个函数会触发
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
@@ -140,19 +242,22 @@ export default {
|
|
position: relative;
|
|
position: relative;
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
height: 100%;
|
|
|
|
+ z-index: 0;
|
|
#mars3dContainer {
|
|
#mars3dContainer {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
height: 100%;
|
|
position: absolute;
|
|
position: absolute;
|
|
top: 0px;
|
|
top: 0px;
|
|
left: 0px;
|
|
left: 0px;
|
|
|
|
+ z-index: 1;
|
|
}
|
|
}
|
|
- > button.switch-to-pano {
|
|
|
|
|
|
+ > button.switch-pano {
|
|
position: absolute;
|
|
position: absolute;
|
|
top: 2.08rem;
|
|
top: 2.08rem;
|
|
right: 1.63rem;
|
|
right: 1.63rem;
|
|
width: 5rem;
|
|
width: 5rem;
|
|
height: 5rem;
|
|
height: 5rem;
|
|
|
|
+ z-index: 2;
|
|
> img {
|
|
> img {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
height: 100%;
|
|
@@ -162,6 +267,7 @@ export default {
|
|
text-shadow: 0 0 0.1rem rgba(0,0,0,0.3);
|
|
text-shadow: 0 0 0.1rem rgba(0,0,0,0.3);
|
|
color: #333333;
|
|
color: #333333;
|
|
font-size: 1.17rem;
|
|
font-size: 1.17rem;
|
|
|
|
+ font-weight: bold;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|