任一存 2 年之前
父节点
当前提交
c17ec0694e
共有 1 个文件被更改,包括 185 次插入133 次删除
  1. 185 133
      public/static/js/Hot.js

+ 185 - 133
public/static/js/Hot.js

@@ -34,11 +34,11 @@ window.initHot = function (model) {
 
   var animateTexSrcs = {}
 
-  var getLink = function (link) {
+  var getCommonHotspotUrl = function (link) {
     var querySectionInLink = link.split('?')[1]
     var langParam = "en" == manage.number("lang") ? "&lang=" + manage.number("lang") : ""
-    return `http://192.168.20.16:8085/#/${browser.isMobile() ? 'mobile' : 'web'}/?${querySectionInLink}&time=${randomTime().getTime()}&id=${window.number}${langParam}`
-    // return `/AnhuiDaily/hotspot/index.html#/${browser.isMobile() ? 'mobile' : 'web'}/?${querySectionInLink}&time=${randomTime().getTime()}&id=${window.number}${langParam}`
+    // return `http://192.168.20.16:8082/#/${browser.isMobile() ? 'mobile' : 'web'}/?${querySectionInLink}&time=${randomTime().getTime()}&id=${window.number}${langParam}`
+    return `/XuzhouHanStoneReliefArtMuseum/hotspot/index.html#/${browser.isMobile() ? 'mobile' : 'web'}/?${querySectionInLink}&time=${randomTime().getTime()}&id=${window.number}${langParam}`
   }
   var removeSrcPostMark = function (url) {//去除texture.load时自动加上的'?'
     var index = url.indexOf('?')
@@ -1100,160 +1100,212 @@ window.initHot = function (model) {
         SoundManager.pause('bgm')
       }
 
+      /**
+       * 图片、视频之类的热点
+       *
+       * link: 提供默认效果的链接
+       * linkType: 'common'
+       * iframe: []
+       */
+
+      /**
+       * 热点编辑里添加网页链接——普通
+       *
+       * link: 提供默认效果的链接
+       * linkType: 'jumpLink'
+       * iframe: ['http://47.112.166.173:8105/editPage/edit.html?m=1308']
+       */
+
+
+      /**
+       * 热点编辑里添加网页链接——跳转
+       *
+       * link: 提供默认效果的链接
+       * linkType: 'jumpLink'
+       * iframe: ['http://47.112.166.173:8105/editPage/edit.html?m=1308']
+       */
+
+      /**
+       * 热点编辑里添加网页链接——iframe
+       * 提供默认效果的链接
+       * linkType: 'iframeDiv'
+       * iframe: ['...']
+       */
+
       var openHot = this.info.link && this.info.actionType.openHot && !options.dontOpen
       var needExamine = options.examine || (!settings.dontExamHot && this.info.actionType.examine)
-      if (!openHot && !needExamine) return
+      if (!openHot && !needExamine) {
+        return
+      }
 
       if (openHot && this.info.linkType != "common" && this.info.iframe && this.info.iframe[0]) {
-        // // 注意,因为网站用了vue router, url里看上去像是查询片段的那一段其实是放在hash片段中的。
-        // const hotspotWebQuerySection = new URLSearchParams(this.info.iframe[0].split('?')[1])
-        // // console.log('111', hotspotWebQuerySection.get('m'));
-
-        // const mainWebQuerySection = new URLSearchParams(location.href.split('?')[1])
-        // mainWebQuerySection.set('m', '1302')
-        // const newLocation = location.href.split('?')[0] + '?' + mainWebQuerySection.toString()
-        // location.assign(newLocation)
-        // location.reload(true)
-
-
-
-        var src = getLink(this.info.iframe[0])
-
-        if (this.info.linkType == "jumpLink") {
-          var newPage = window.open(src, "_blank")
-          newPage.focus()
-
-        } else if (this.info.linkType == "iframeDiv") {
-
-          var div = document.createElement("div")
-          div.style.position = 'fixed'
-          div.style.width = div.style.height = "100%"
-          div.style.left = div.style.top = '0'
-          div.style["z-index"] = "999"
-
-          var exit = document.createElement("div")
-          exit.style["background-image"] = "url(images/vrOffImg.png)"
-          exit.style.position = 'absolute'
-          exit.style.width = exit.style.height = "50px"
-          exit.style.left = '17px'; exit.style.top = "20px"
-          exit.style.cursor = "pointer"
-          exit.style["background-repeat"] = "no-repeat"
-          exit.style["background-size"] = "25%"
-          exit.style["background-position"] = "center center"
-          exit.style["background-color"] = "rgba(0, 0, 0, 0.2)"
-          exit.style["border-radius"] = "50%"
-          exit.style["z-index"] = "3"
-          exit.onclick = () => {
-            $(div).remove()
-
-            Hot.closePopup()
+        if (false) { // 场景跳转(热点编辑里添加网页链接——跳转)
+          // 注意,因为网站用了vue router, url里看上去像是查询片段的那一段其实是放在hash片段中的。
+          const hotspotWebQuerySection = new URLSearchParams(this.info.iframe[0].split('?')[1])
+          const targetSceneCode = hotspotWebQuerySection.get('m')
+
+          const currentLocationQuerySection = new URLSearchParams(location.href.split('?')[1])
+          const currentSceneCode = currentLocationQuerySection.get('m')
+
+          if (currentSceneCode === '1300' && targetSceneCode === '1302') {
+            const iframeElem = document.createElement('iframe')
+            iframeElem.style.position = 'absolute'
+            iframeElem.style.top = '50%'
+            iframeElem.style.left = '50%'
+            iframeElem.style.width = '600px'
+            iframeElem.style.height = '800px'
+            iframeElem.style.transform = 'translate(-50%, -50%)'
+            iframeElem.style.zIndex = '9999'
+            iframeElem.style.boxShadow = '0 0 0 1000px rgba(0, 0, 0, 0.85)'
+            // iframeElem.src = 'http://192.168.20.16:8081/#/topic'
+            iframeElem.src = '/AnhuiDaily/quiz/index.html#/topic'
+            document.documentElement.appendChild(iframeElem)
+
+            const onMsg = (msg) => {
+              console.log('message received!', msg)
+              window.removeEventListener('message', onMsg, false)
+              if (msg.data === 'quiz over') {
+                // 跳转到新场景
+                currentLocationQuerySection.set('m', targetSceneCode)
+                const newLocation = location.href.split('?')[0] + '?' + currentLocationQuerySection.toString()
+                location.assign(newLocation)
+                location.reload(true)
+              }
+            }
 
+            window.addEventListener('message', onMsg, false)
+          } else {
+            // 跳转到新场景
+            currentLocationQuerySection.set('m', targetSceneCode)
+            const newLocation = location.href.split('?')[0] + '?' + currentLocationQuerySection.toString()
+            location.assign(newLocation)
+            location.reload(true)
           }
+        } else {
+          // 不是场景跳转
+          var src = this.info.iframe[0]
+
+          if (this.info.linkType == "jumpLink") { // 新页面打开链接
+            var newPage = window.open(src, "_blank")
+            newPage.focus()
+
+          } else if (this.info.linkType == "iframeDiv") { // iframe里打开链接
+            var div = document.createElement("div")
+            div.style.position = 'fixed'
+            div.style.width = div.style.height = "100%"
+            div.style.left = div.style.top = '0'
+            div.style["z-index"] = "999"
+
+            var exit = document.createElement("div")
+            exit.style["background-image"] = "url(images/vrOffImg.png)"
+            exit.style.position = 'absolute'
+            exit.style.width = exit.style.height = "50px"
+            exit.style.left = '17px'; exit.style.top = "20px"
+            exit.style.cursor = "pointer"
+            exit.style["background-repeat"] = "no-repeat"
+            exit.style["background-size"] = "25%"
+            exit.style["background-position"] = "center center"
+            exit.style["background-color"] = "rgba(0, 0, 0, 0.2)"
+            exit.style["border-radius"] = "50%"
+            exit.style["z-index"] = "3"
+            exit.onclick = () => {
+              $(div).remove()
+
+              Hot.closePopup()
 
-          var myElement = document.createElement("iframe")
-          myElement.style.position = 'absolute'
-          myElement.style.width = myElement.style.height = "100%"
-          myElement.style.left = myElement.style.top = '0'
+            }
 
-          myElement.src = src
+            var myElement = document.createElement("iframe")
+            myElement.style.position = 'absolute'
+            myElement.style.width = myElement.style.height = "100%"
+            myElement.style.left = myElement.style.top = '0'
 
-          $("body").append(div)
-          div.appendChild(exit)
-          div.appendChild(myElement)
+            myElement.src = this.info.iframe[0]
 
-          SoundManager.play('hot')
+            $("body").append(div)
+            div.appendChild(exit)
+            div.appendChild(myElement)
 
+            SoundManager.play('hot')
+          }
         }
+      } else {
+        // 图片、视频之类的热点
+        if (!player.currentPano) return
 
-        return
-      }
-
-      if (!player.currentPano) return
-
-      var popup = document.getElementById("popup")
-
-      if (openHot) {
-        // // 注意,因为网站用了vue router, url里看上去像是查询片段的那一段其实是放在hash片段中的。
-        // const hotspotWebQuerySection = new URLSearchParams(this.info.link.split('?')[1])
-        // // console.log('222', hotspotWebQuerySection.get('m'));
-
-        // const mainWebQuerySection = new URLSearchParams(location.href.split('?')[1])
-        // mainWebQuerySection.set('m', '1302')
-        // const newLocation = location.href.split('?')[0] + '?' + mainWebQuerySection.toString()
-        // location.assign(newLocation)
-        // location.reload(true)
-
-
+        var popup = document.getElementById("popup")
 
-        g_currentHot = this,
-        popup.style.display = "block",
-        popup.classList.add("wait")
-        var n = document.createElement("iframe")
+        if (openHot) {
+          g_currentHot = this,
+          popup.style.display = "block",
+          popup.classList.add("wait")
+          var n = document.createElement("iframe")
 
-        SoundManager.play('hot')
+          SoundManager.play('hot')
 
-        var src = getLink(this.info.link)
-        n.src = src
-        n.id = "id1",
-        n.allowTransparency = "true"
-        var a = document.getElementById("id1")
-        if (void 0 === a || null == a) {
-          document.querySelector(".popup-content").appendChild(n)
-          var s = !1
-          window.loaddingSuccess = function () {
-            s = !0
+          var src = getCommonHotspotUrl(this.info.link)
+          n.src = src
+          n.id = "id1",
+          n.allowTransparency = "true"
+          var a = document.getElementById("id1")
+          if (void 0 === a || null == a) {
+            document.querySelector(".popup-content").appendChild(n)
+            var s = !1
+            window.loaddingSuccess = function () {
+              s = !0
+            }
+            ,
+            setTimeout(function e() {
+              if (s) {
+                var t = document.querySelector("#id1").contentWindow.document
+                t.querySelector("video") && (t.querySelector("video").play(),
+                !t.querySelector("video").paused && t.querySelector(".playPause") && t.querySelector(".playPause").classList.add("fa-pause")),
+                t.querySelector("audio") && t.querySelector("audio").play()
+              } else
+                setTimeout(e, 300)
+            }, 800)
           }
-          ,
-          setTimeout(function e() {
-            if (s) {
-              var t = document.querySelector("#id1").contentWindow.document
-              t.querySelector("video") && (t.querySelector("video").play(),
-              !t.querySelector("video").paused && t.querySelector(".playPause") && t.querySelector(".playPause").classList.add("fa-pause")),
-              t.querySelector("audio") && t.querySelector("audio").play()
-            } else
-              setTimeout(e, 300)
-          }, 800)
         }
-      }
 
-      var done = function () {
-        player.flyingToTag = !1
-        openHot && popup.classList.remove("wait")
-      }.bind(this)
+        var done = function () {
+          player.flyingToTag = !1
+          openHot && popup.classList.remove("wait")
+        }.bind(this)
 
-      if (!needExamine) {
-        done()
-        return
-      }
+        if (!needExamine) {
+          done()
+          return
+        }
 
-      var c = this.closestPanoTowardTag(player.mode, player.currentPano) || player.currentPano
-        , h = this.mesh.getWorldPosition()
-      player.flyingToTag = !0
+        var c = this.closestPanoTowardTag(player.mode, player.currentPano) || player.currentPano
+          , h = this.mesh.getWorldPosition()
+        player.flyingToTag = !0
 
-      if (player.mode === 'panorama') {
-        var d = {
-          pano: c,
-          lookAtPoint: h,
-          duration: options.duration,
-          maxDistanceOverride: null,
-          skipWarpingCheck: !1,
-          aimDuration: options.aimDuration,
+        if (player.mode === 'panorama') {
+          var d = {
+            pano: c,
+            lookAtPoint: h,
+            duration: options.duration,
+            maxDistanceOverride: null,
+            skipWarpingCheck: !1,
+            aimDuration: options.aimDuration,
 
+          }
+          player.flyToPano(d, done)
+        } else {
+          var p = {
+            pano: c
+          }
+          if (h) {
+            var f = (new THREE.Matrix4).lookAt(c.position, h, new THREE.Vector3(0, 1, 0))
+            p.quaternion = (new THREE.Quaternion).setFromRotationMatrix(f)
+          }
+          p.callback = done,
+          p.duration = options.duration || 1500,
+          p.mode = 'panorama',
+          p.aimDuration = options.aimDuration
+          player.flyToNewMode(p)
         }
-        player.flyToPano(d, done)
-      } else {
-        var p = {
-          pano: c
-        }
-        if (h) {
-          var f = (new THREE.Matrix4).lookAt(c.position, h, new THREE.Vector3(0, 1, 0))
-          p.quaternion = (new THREE.Quaternion).setFromRotationMatrix(f)
-        }
-        p.callback = done,
-        p.duration = options.duration || 1500,
-        p.mode = 'panorama',
-        p.aimDuration = options.aimDuration
-        player.flyToNewMode(p)
       }
     }