Prechádzať zdrojové kódy

倾斜摄影界面新需求

任一存 2 rokov pred
rodič
commit
8c4ec9ad81

+ 3 - 10
public/index.html

@@ -21,20 +21,13 @@
 
     <!-- cesium -->
     <!--引入cesium基础lib-->
-    <link
+    <!-- <link
       href="<%= BASE_URL %>oblique/Cesium/Widgets/widgets.css"
       rel="stylesheet"
       type="text/css"
-    />
-    <!-- <script>
-      // window.CESIUM_BASE_URL = "./oblique/Cesium/" //非必须,如jsp、asp.net等非html框架报错时建议取消注释
-    </script> -->
-    <script
-      src="<%= BASE_URL %>oblique/Cesium/Cesium.js"
-      type="text/javascript"
-    ></script>
+    /> -->
     <!-- <script
-      src="<%= BASE_URL %>static/oblique/turf/turf.min.js"
+      src="<%= BASE_URL %>oblique/Cesium/Cesium.js"
       type="text/javascript"
     ></script> -->
 

BIN
src/assets/images/oblique/bg.png


BIN
src/assets/images/oblique/image 77.png


BIN
src/assets/images/oblique/丁香园.png


BIN
src/assets/images/oblique/忠魂亭.png


BIN
src/assets/images/oblique/知名烈士墓.png


BIN
src/assets/images/oblique/红领巾广场.png


BIN
src/assets/images/oblique/雨花台烈士纪念碑.png


BIN
src/assets/images/oblique/雨花台烈士纪念馆.png


+ 1 - 1
src/router/index.js

@@ -76,7 +76,7 @@ const routes = [
     meta: {
       isShowBottomBar: true,
       canFullScreen: true,
-      isSpecialStyle: true,
+      isSpecialStyle: false,
     },
     children: [
       {

+ 275 - 0
src/views/ObliqueView-backup.vue

@@ -0,0 +1,275 @@
+<template>
+  <div class="oblique-view">
+    <div
+      id="mars3dContainer"
+      class="mars3d-container"
+    />
+    <button
+      class="switch-pano"
+      @click="onClickSwitchPano"
+    >
+      <img
+        src="@/assets/images/swkk/changjingdaolan.png"
+        alt=""
+        draggable="false"
+      >
+      <div>全景切换</div>
+    </button>
+
+    <router-view />
+  </div>
+</template>
+
+<script>
+import "mars3d/dist/mars3d.css"
+import * as mars3d from "mars3d"
+
+export default {
+  components: {},
+  data() {
+    return {
+    }
+  },
+  computed: {
+    ...globalMapState([
+      'panoData',
+    ]),
+    ...globalMapGetters([
+      'catalogTopology',
+    ])
+  },
+  watch: {},
+  async created() {
+    let panoData = await globalApi.fetchPanoData()
+    this.fixPanoData(panoData)
+    this.setPanoData(panoData)
+  },
+  mounted() {
+    this.$msgCenter.publish('show-loading')
+    this.initMap().then(
+      (map) => {
+        // 加载模型
+        this.loadModel(map)
+        // 加载标签
+        let graphicLayer = new mars3d.layer.GraphicLayer()
+        map.addLayer(graphicLayer)
+        this.drawLabel(graphicLayer)
+        map.setCameraView({
+          lat: 31.99314,
+          lng: 118.776577,
+          alt: 656,
+          heading: 350,
+          pitch: -43,
+        })
+        setTimeout(() => {
+          this.$msgCenter.publish('hide-loading')
+        }, 3000)
+      },
+      (error) => {
+        console.log("地图初始化失败", error)
+        this.$msgCenter.publish('hide-loading')
+      }
+    )
+  },
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {}, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {},
+  methods: {
+    ...globalMapMutations([
+      'setPanoData',
+    ]),
+
+    // 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() {
+      // 读取 config.json 配置文件
+      const json = await mars3d.Util.fetchJson({ url: `${process.env.BASE_URL}oblique/config.json` })
+      console.log("读取 config.json 配置文件完成", json) // 打印测试信息
+      // 创建三维地球场景
+      const mapOptions = json.map3d
+      let map = new mars3d.Map("mars3dContainer", mapOptions)
+      // 打印测试信息
+      // console.log("mars3d的Map主对象构造完成", this.map);
+      // console.log("其中Cesium原生的Cesium.Viewer为", this.map.viewer);
+      return map
+    },
+    // 倾斜模型加载
+    loadModel(_map) {
+      const modelLayer = new mars3d.layer.TilesetLayer({
+        name: "雨花台模型",
+        url: "https://testgis.4dage.com/yuhuatai1021-qp/tileset.json",
+        maximumMemoryUsage: 2048,
+        position: { alt: -290 },
+        preloadFlightDestinations: true,
+        flyTo: false,
+      })
+      _map.addLayer(modelLayer)
+    },
+    drawLabel(_layer) {
+      const graphic = new mars3d.graphic.DivGraphic({
+        position: [118.775298, 31.999126, 80.5],
+        style: {
+          html: `<div
+      style="
+        width: 316px;
+        height: 174px;
+        display: flex;
+        justify-content: center;
+        align-items: flex-start;
+        cursor:pointer;
+      "
+    >
+      <div
+        style="
+          position: absolute;
+          margin-left: 25px;
+          width: 190px;
+          height: 70px;
+          line-height: 70px;
+          text-align: center;
+          color: #fff;
+          font-size: 20px;
+          font-weight: bold;
+        "
+      >
+        雨花台烈士纪念馆
+      </div>
+      <div><img src="${require('@/assets/images/oblique/spot-tag.png')}"/></div>
+    </div>`,
+          horizontalOrigin: mars3d.Cesium.HorizontalOrigin.CENTER,
+          verticalOrigin: mars3d.Cesium.VerticalOrigin.BOTTOM,
+          // distanceDisplayCondition: new mars3d.Cesium.DistanceDisplayCondition(0, 30000), // 按视距距离显示
+          // scaleByDistance: new mars3d.Cesium.NearFarScalar(100, 1, 1000, 0.5),
+          scale: 0.1,
+          clampToGround: false,
+        },
+      })
+      graphic.on(mars3d.EventType.click, () => {
+        this.$router.push({ name: 'PanoView', params: { scene: this.catalogTopology[0].children[0].children[11] } })
+      })
+
+      _layer.addGraphic(graphic)
+    },
+    onClickSwitchPano() {
+      this.$router.push({ name: 'PanoListInOblique' })
+    }
+  }, //如果页面有keep-alive缓存功能,这个函数会触发
+}
+</script>
+
+<style lang='less' scoped>
+.oblique-view {
+  position: relative;
+  width: 100%;
+  height: 100%;
+  z-index: 0;
+  #mars3dContainer {
+    width: 100%;
+    height: 100%;
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    z-index: 1;
+  }
+  > button.switch-pano {
+    position: absolute;
+    top: 2.08rem;
+    right: 1.63rem;
+    width: 5rem;
+    z-index: 2;
+    > img {
+      width: 100%;
+    }
+    > div {
+      margin-top: 0.17rem;
+      text-shadow: 0 0 0.1rem rgba(0,0,0,0.3);
+      color: #333333;
+      font-size: 1.17rem;
+      font-weight: bold;
+    }
+  }
+}
+
+
+/deep/.mars3d-locationbar {
+  background-color: #000 !important;
+  z-index: 0 !important;
+}
+</style>

+ 76 - 114
src/views/ObliqueView.vue

@@ -1,9 +1,11 @@
 <template>
   <div class="oblique-view">
-    <div
-      id="mars3dContainer"
-      class="mars3d-container"
-    />
+    <img
+      src="@/assets/images/oblique/bg.png"
+      alt=""
+      class="background"
+    >
+
     <button
       class="switch-pano"
       @click="onClickSwitchPano"
@@ -16,18 +18,70 @@
       <div>全景切换</div>
     </button>
 
+    <button
+      v-for="(item, index) in flagList"
+      :key="index"
+      class="flag"
+      :style="{
+        left: item.posX,
+        top: item.posY,
+      }"
+      @click="$router.push({ name: 'PanoView', params: { scene: catalogTopology[0].children[0].children[item.idx] } })"
+    >
+      <img
+        :src="item.bgImg"
+        alt=""
+        draggable="false"
+      >
+    </button>
+
     <router-view />
   </div>
 </template>
 
 <script>
-import "mars3d/dist/mars3d.css"
-import * as mars3d from "mars3d"
-
 export default {
   components: {},
   data() {
     return {
+      flagList: [
+        {
+          posX: '17.96rem',
+          posY: 'calc(50% - 30rem)',
+          bgImg: require(`@/assets/images/oblique/雨花台烈士纪念碑.png`),
+          idx: 13,
+        },
+        {
+          posX: '1.63rem',
+          posY: 'calc(50% - 24rem)',
+          bgImg: require(`@/assets/images/oblique/红领巾广场.png`),
+          idx: 5,
+        },
+        {
+          posX: '37.21rem',
+          posY: 'calc(50% - 19rem)',
+          bgImg: require(`@/assets/images/oblique/知名烈士墓.png`),
+          idx: 3,
+        },
+        {
+          posX: '22.92rem',
+          posY: 'calc(50% - 11rem)',
+          bgImg: require(`@/assets/images/oblique/雨花台烈士纪念馆.png`),
+          idx: 11,
+        },
+        {
+          posX: '34.63rem',
+          posY: 'calc(50% - 5rem)',
+          bgImg: require(`@/assets/images/oblique/丁香园.png`),
+          idx: 6,
+        },
+        {
+          posX: '27.79rem',
+          posY: 'calc(50%)',
+          bgImg: require(`@/assets/images/oblique/忠魂亭.png`),
+          idx: 7,
+        },
+      ],
     }
   },
   computed: {
@@ -45,31 +99,7 @@ export default {
     this.setPanoData(panoData)
   },
   mounted() {
-    this.$msgCenter.publish('show-loading')
-    this.initMap().then(
-      (map) => {
-        // 加载模型
-        this.loadModel(map)
-        // 加载标签
-        let graphicLayer = new mars3d.layer.GraphicLayer()
-        map.addLayer(graphicLayer)
-        this.drawLabel(graphicLayer)
-        map.setCameraView({
-          lat: 31.99314,
-          lng: 118.776577,
-          alt: 656,
-          heading: 350,
-          pitch: -43,
-        })
-        setTimeout(() => {
-          this.$msgCenter.publish('hide-loading')
-        }, 3000)
-      },
-      (error) => {
-        console.log("地图初始化失败", error)
-        this.$msgCenter.publish('hide-loading')
-      }
-    )
+    // this.$msgCenter.publish('show-loading')
   },
   beforeCreate() {}, //生命周期 - 创建之前
   beforeMount() {}, //生命周期 - 挂载之前
@@ -157,76 +187,6 @@ export default {
         )
       }
     },
-    // 初始化地图
-    async initMap() {
-      // 读取 config.json 配置文件
-      const json = await mars3d.Util.fetchJson({ url: `${process.env.BASE_URL}oblique/config.json` })
-      console.log("读取 config.json 配置文件完成", json) // 打印测试信息
-      // 创建三维地球场景
-      const mapOptions = json.map3d
-      let map = new mars3d.Map("mars3dContainer", mapOptions)
-      // 打印测试信息
-      // console.log("mars3d的Map主对象构造完成", this.map);
-      // console.log("其中Cesium原生的Cesium.Viewer为", this.map.viewer);
-      return map
-    },
-    // 倾斜模型加载
-    loadModel(_map) {
-      const modelLayer = new mars3d.layer.TilesetLayer({
-        name: "雨花台模型",
-        url: "https://testgis.4dage.com/yuhuatai1021-qp/tileset.json",
-        maximumMemoryUsage: 2048,
-        position: { alt: -290 },
-        preloadFlightDestinations: true,
-        flyTo: false,
-      })
-      _map.addLayer(modelLayer)
-    },
-    drawLabel(_layer) {
-      const graphic = new mars3d.graphic.DivGraphic({
-        position: [118.775298, 31.999126, 80.5],
-        style: {
-          html: `<div
-      style="
-        width: 316px;
-        height: 174px;
-        display: flex;
-        justify-content: center;
-        align-items: flex-start;
-        cursor:pointer;
-      "
-    >
-      <div
-        style="
-          position: absolute;
-          margin-left: 25px;
-          width: 190px;
-          height: 70px;
-          line-height: 70px;
-          text-align: center;
-          color: #fff;
-          font-size: 20px;
-          font-weight: bold;
-        "
-      >
-        雨花台烈士纪念馆
-      </div>
-      <div><img src="${require('@/assets/images/oblique/spot-tag.png')}"/></div>
-    </div>`,
-          horizontalOrigin: mars3d.Cesium.HorizontalOrigin.CENTER,
-          verticalOrigin: mars3d.Cesium.VerticalOrigin.BOTTOM,
-          // distanceDisplayCondition: new mars3d.Cesium.DistanceDisplayCondition(0, 30000), // 按视距距离显示
-          // scaleByDistance: new mars3d.Cesium.NearFarScalar(100, 1, 1000, 0.5),
-          scale: 0.1,
-          clampToGround: false,
-        },
-      })
-      graphic.on(mars3d.EventType.click, () => {
-        this.$router.push({ name: 'PanoView', params: { scene: this.catalogTopology[0].children[0].children[11] } })
-      })
-
-      _layer.addGraphic(graphic)
-    },
     onClickSwitchPano() {
       this.$router.push({ name: 'PanoListInOblique' })
     }
@@ -240,13 +200,13 @@ export default {
   width: 100%;
   height: 100%;
   z-index: 0;
-  #mars3dContainer {
-    width: 100%;
-    height: 100%;
+  background-color: #c3ac87;
+  > img.background {
     position: absolute;
-    top: 0px;
-    left: 0px;
-    z-index: 1;
+    left: 0;
+    top: 50%;
+    width: 100%;
+    transform: translateY(-50%);
   }
   > button.switch-pano {
     position: absolute;
@@ -265,11 +225,13 @@ export default {
       font-weight: bold;
     }
   }
-}
-
-
-/deep/.mars3d-locationbar {
-  background-color: #000 !important;
-  z-index: 0 !important;
+  > button.flag {
+    position: absolute;
+    height: 5.83rem;
+    > img {
+      width: 100%;
+      height: 100%;
+    }
+  }
 }
 </style>