Pārlūkot izejas kodu

热点点击功能完善

任一存 2 gadi atpakaļ
vecāks
revīzija
2f749035ee
2 mainītis faili ar 195 papildinājumiem un 163 dzēšanām
  1. 195 162
      public/static/js/Hot.js
  2. 0 1
      src/assets/style/public.less

+ 195 - 162
public/static/js/Hot.js

@@ -34,7 +34,7 @@ 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}`
@@ -1100,181 +1100,214 @@ 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])
-            const targetSceneCode = hotspotWebQuerySection.get('m')
+            if (this.info.linkType === 'jumpLink' && !this.info.iframe[0].startsWith('external-')) { // 场景跳转(热点编辑里添加网页链接——跳转)
+              // 注意,因为网站用了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)
+              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)
               }
-              
-              window.addEventListener('message', onMsg, false)
             } else {
-              // 跳转到新场景
-              currentLocationQuerySection.set('m', targetSceneCode)
-              const newLocation = location.href.split('?')[0] + '?' + currentLocationQuerySection.toString()
-              location.assign(newLocation)
-              location.reload(true)
-            }
-
-            return
-            
-            
-            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()
+              // 不是场景跳转
+              var src = this.info.iframe[0]
         
+              if (this.info.linkType == "jumpLink") { // 新页面打开链接
+                src = src.substring(9) // 把前缀external-去掉
+                var newPage = window.open(src, "_blank")
+                newPage.focus()
+          
+              } else if (this.info.linkType == "iframeDiv") { // iframe里打开链接
+                console.log('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 = this.info.iframe[0]
+          
+                $("body").append(div)
+                div.appendChild(exit)
+                div.appendChild(myElement)
+          
+                SoundManager.play('hot')
               }
-        
-              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
-        
-              $("body").append(div)
-              div.appendChild(exit)
-              div.appendChild(myElement)
-        
-              SoundManager.play('hot')
-        
             }
-        
-            return
-          }
-        
-          if (!player.currentPano) return
-        
-          var popup = document.getElementById("popup")
-        
-          if (openHot) {
-            g_currentHot = this,
-            popup.style.display = "block",
-            popup.classList.add("wait")
-            var n = document.createElement("iframe")
-        
-            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
+          } else {
+            // 图片、视频之类的热点
+            if (!player.currentPano) return
+          
+            var popup = document.getElementById("popup")
+          
+            if (openHot) {
+              g_currentHot = this,
+              popup.style.display = "block",
+              popup.classList.add("wait")
+              var n = document.createElement("iframe")
+          
+              SoundManager.play('hot')
+          
+              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)
-        
-          if (!needExamine) {
-            done()
-            return
-          }
-        
-          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,
-        
             }
-            player.flyToPano(d, done)
-          } else {
-            var p = {
-              pano: c
+          
+            var done = function () {
+              player.flyingToTag = !1
+              openHot && popup.classList.remove("wait")
+            }.bind(this)
+          
+            if (!needExamine) {
+              done()
+              return
             }
-            if (h) {
-              var f = (new THREE.Matrix4).lookAt(c.position, h, new THREE.Vector3(0, 1, 0))
-              p.quaternion = (new THREE.Quaternion).setFromRotationMatrix(f)
+          
+            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,
+          
+              }
+              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)
             }
-            p.callback = done,
-            p.duration = options.duration || 1500,
-            p.mode = 'panorama',
-            p.aimDuration = options.aimDuration
-            player.flyToNewMode(p)
           }
         }
 

+ 0 - 1
src/assets/style/public.less

@@ -85,7 +85,6 @@ input:-ms-input-placeholder{  /* Internet Explorer 10-11 */
     path {
       stroke-width: 0.5;
     }
-    
   }
 }