浏览代码

访问热点详情页会修改url,这样在页面刷新后就会直接打开详情页

(cherry picked from commit 8d9c0e097786fd3e6bf8a487a3c640f2d9edec08)
任一存 2 年之前
父节点
当前提交
1a48389871
共有 3 个文件被更改,包括 58 次插入3 次删除
  1. 12 1
      public/static/js/Hot.js
  2. 24 0
      src/App.vue
  3. 22 2
      src/views/gui/CustomHotspotList.vue

+ 12 - 1
public/static/js/Hot.js

@@ -1216,6 +1216,13 @@ window.initHot = function (model) {
 
 
           SoundManager.play('hot')
           SoundManager.play('hot')
 
 
+          const myEvent = new CustomEvent('openHotspot', {
+            detail: {
+              hotspotUrl: this.info.link
+            }
+          })
+          document.dispatchEvent(myEvent)
+
           var src = getCommonHotspotUrl(this.info.link)
           var src = getCommonHotspotUrl(this.info.link)
           n.src = src
           n.src = src
           n.id = "id1",
           n.id = "id1",
@@ -1663,6 +1670,10 @@ window.initHot = function (model) {
 
 
     SoundManager.pause('hot', true)//自动播放被中断的音频 (bgm
     SoundManager.pause('hot', true)//自动播放被中断的音频 (bgm
 
 
+    const myEvent = new CustomEvent('closeHotspot', {
+      detail: null,
+    })
+    document.dispatchEvent(myEvent)
 
 
     return false
     return false
   }
   }
@@ -1717,4 +1728,4 @@ window.initHot = function (model) {
     数据速率为1824kbps,720 *576px   时正常
     数据速率为1824kbps,720 *576px   时正常
     所以尽量降到2000以下 同时播放个数最好不超过2个 可能需要将src归零  并延迟加载、不自动播放
     所以尽量降到2000以下 同时播放个数最好不超过2个 可能需要将src归零  并延迟加载、不自动播放
 
 
-     */
+ */

+ 24 - 0
src/App.vue

@@ -24,6 +24,30 @@ export default {
     if (this.isMobile) {
     if (this.isMobile) {
       document.body.classList.add('mobile')
       document.body.classList.add('mobile')
     }
     }
+    document.addEventListener('openHotspot', (e) => {
+      console.log('shabiweixin', e)
+      this.$router.push({
+        name: this.$route.name,
+        query: {
+          ...this.$route.query,
+          ...{
+            hotspotUrl: encodeURIComponent(e.detail.hotspotUrl)
+          }
+        }
+      })
+    })
+    document.addEventListener('closeHotspot', (e) => {
+      console.log('shabiweixin close', e)
+      this.$router.push({
+        name: this.$route.name,
+        query: {
+          ...this.$route.query,
+          ...{
+            hotspotUrl: null,
+          }
+        }
+      })
+    })
   }
   }
 }
 }
 </script>
 </script>

+ 22 - 2
src/views/gui/CustomHotspotList.vue

@@ -30,12 +30,32 @@
 export default {
 export default {
   data() {
   data() {
     return {
     return {
-      hotspotList: window.myHotList,
+      hotspotList: null,
       intervalId: null,
       intervalId: null,
     }
     }
   },
   },
+  watch: {
+    hotspotList: {
+      handler(vNew) {
+        if (vNew) {
+          if (this.$route.query.hotspotUrl) {
+            const hotspotId = decodeURIComponent(this.$route.query.hotspotUrl).split('m=')[1]
+            const clickedHotspot = this.hotspotList.find((item) => {
+              return item.sid === hotspotId
+            })
+            if (clickedHotspot) {
+              this.openHot(clickedHotspot)
+            }
+          }
+        }
+      },
+      immediate: true,
+    }
+  },
   mounted() {
   mounted() {
-    if (!window.myHotList) {
+    if (window.myHotList) {
+      this.hotspotList = window.myHotList
+    } else {
       this.intervalId = setInterval(() => {
       this.intervalId = setInterval(() => {
         if (window.myHotList) {
         if (window.myHotList) {
           this.hotspotList = window.myHotList
           this.hotspotList = window.myHotList