Bladeren bron

场景跳转逻辑修改

任一存 2 jaren geleden
bovenliggende
commit
cbd2a5b35c
1 gewijzigde bestanden met toevoegingen van 14 en 15 verwijderingen
  1. 14 15
      public/static/js/Hot.js

+ 14 - 15
public/static/js/Hot.js

@@ -1109,14 +1109,19 @@ window.initHot = function (model) {
             const hotspotWebQuerySection = new URLSearchParams(this.info.iframe[0].split('?')[1])
             const targetSceneCode = hotspotWebQuerySection.get('m')
 
-            if (targetSceneCode === '1300') {
+            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 = '0'
-              iframeElem.style.left = '0'
-              iframeElem.style.width = '100%'
-              iframeElem.style.height = '100%'
+              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)
@@ -1125,14 +1130,9 @@ window.initHot = function (model) {
                 console.log('message received!', msg);
                 window.removeEventListener('message', onMsg, false)
                 if (msg.data === 'quiz over') {
-                  
-                  // 注意,因为网站用了vue router, url里看上去像是查询片段的那一段其实是放在hash片段中的。
-                  const hotspotWebQuerySection = new URLSearchParams(this.info.iframe[0].split('?')[1])
-  
                   // 跳转到新场景
-                  const mainWebQuerySection = new URLSearchParams(location.href.split('?')[1])
-                  mainWebQuerySection.set('m', hotspotWebQuerySection.get('m'))
-                  const newLocation = location.href.split('?')[0] + '?' + mainWebQuerySection.toString()
+                  currentLocationQuerySection.set('m', targetSceneCode)
+                  const newLocation = location.href.split('?')[0] + '?' + currentLocationQuerySection.toString()
                   location.assign(newLocation)
                   location.reload(true)
                 }
@@ -1141,9 +1141,8 @@ window.initHot = function (model) {
               window.addEventListener('message', onMsg, false)
             } else {
               // 跳转到新场景
-              const mainWebQuerySection = new URLSearchParams(location.href.split('?')[1])
-              mainWebQuerySection.set('m', targetSceneCode)
-              const newLocation = location.href.split('?')[0] + '?' + mainWebQuerySection.toString()
+              currentLocationQuerySection.set('m', targetSceneCode)
+              const newLocation = location.href.split('?')[0] + '?' + currentLocationQuerySection.toString()
               location.assign(newLocation)
               location.reload(true)
             }