Pārlūkot izejas kodu

修复全景热点传索引打开错乱的问题

shaogen1995 9 mēneši atpakaļ
vecāks
revīzija
d6ce1d5b8d

+ 1 - 1
Code/public/myData/myData.js

@@ -3,7 +3,7 @@ window.isHH = document.documentElement.clientWidth >= document.documentElement.c
 const isPcTemp = document.documentElement.clientWidth >= 1200
 const isPcTemp = document.documentElement.clientWidth >= 1200
 
 
 // 本地开发静态资源目录
 // 本地开发静态资源目录
-const baseUrlLoc = ' http://192.168.0.18:8081/staticData/'
+const baseUrlLoc = ' http://192.168.20.55:8080/staticData/'
 
 
 const myBaseUrl = 'https://houseoss.4dkankan.com/project/henan/'
 const myBaseUrl = 'https://houseoss.4dkankan.com/project/henan/'
 
 

+ 10 - 9
Code/src/pages/A3banPano/index.tsx

@@ -19,7 +19,7 @@ function A3banPano() {
   // 路由:/banPano/id
   // 路由:/banPano/id
   const urlObj: any = useParams()
   const urlObj: any = useParams()
   // 0为 第一种模式的热点 其他为第二种
   // 0为 第一种模式的热点 其他为第二种
-  const [ind, setInd] = useState(-1)
+  const [acName, setAcName] = useState('')
   const [activeIdx, setActiveIdx] = useState(-1)
   const [activeIdx, setActiveIdx] = useState(-1)
   const [curScene, setCurScene] = useState('')
   const [curScene, setCurScene] = useState('')
 
 
@@ -31,10 +31,11 @@ function A3banPano() {
     // myData.banquet.hot.filter(v=>v.louType===id)
     // myData.banquet.hot.filter(v=>v.louType===id)
   }, [urlObj.id])
   }, [urlObj.id])
 
 
-  const data = useMemo(() => {
-    if (ind !== -1) return myData.banquet.hot[ind].data
-    else return []
-  }, [ind])
+  const info = useMemo(() => {
+    let infoRes: any = {}
+    if (acName) infoRes = myData.banquet.hot.find(v => v.name === acName)
+    return infoRes
+  }, [acName])
 
 
   return (
   return (
     <div className={styles.A3banPano}>
     <div className={styles.A3banPano}>
@@ -83,7 +84,7 @@ function A3banPano() {
                 bg={false}
                 bg={false}
                 onOver={() => setActiveIdx(index)}
                 onOver={() => setActiveIdx(index)}
                 onOut={() => setActiveIdx(-1)}
                 onOut={() => setActiveIdx(-1)}
-                onClick={() => setInd(index)}
+                onClick={() => setAcName(item.name)}
                 // @ts-ignore
                 // @ts-ignore
                 // onDown='draggable_hotspot()'
                 // onDown='draggable_hotspot()'
               >
               >
@@ -190,9 +191,9 @@ function A3banPano() {
       {/* 右下角按钮 */}
       {/* 右下角按钮 */}
       <FloorBtn />
       <FloorBtn />
 
 
-      {ind === -1 ? null : (
-        <Hot2 data={data} closeFu={() => setInd(-1)} name={myData.banquet.hot[ind].name} />
-      )}
+      {acName && info && info.data ? (
+        <Hot2 data={info.data} closeFu={() => setAcName('')} name={info.name} />
+      ) : null}
     </div>
     </div>
   )
   )
 }
 }

+ 10 - 9
Code/src/pages/A3banquet/PanoImg/index.tsx

@@ -14,14 +14,15 @@ import FloorHotspotIcon from '@/assets/img/icon-flo-min.png'
 
 
 function PanoImg() {
 function PanoImg() {
   // 0为 第一种模式的热点 其他为第二种
   // 0为 第一种模式的热点 其他为第二种
-  const [ind, setInd] = useState(-1)
+  const [acName, setAcName] = useState('')
   const [activeIdx, setActiveIdx] = useState(-1)
   const [activeIdx, setActiveIdx] = useState(-1)
   const middlewareIns = useRef<KrpanoMiddlewareMethods>(null)
   const middlewareIns = useRef<KrpanoMiddlewareMethods>(null)
 
 
-  const data = useMemo(() => {
-    if (ind !== -1) return myData.banquet.hot[ind].data
-    else return []
-  }, [ind])
+  const info = useMemo(() => {
+    let infoRes: any = {}
+    if (acName) infoRes = myData.banquet.hot.find(v => v.name === acName)
+    return infoRes
+  }, [acName])
 
 
   return (
   return (
     <>
     <>
@@ -87,7 +88,7 @@ function PanoImg() {
                   bg={false}
                   bg={false}
                   onOver={() => setActiveIdx(index)}
                   onOver={() => setActiveIdx(index)}
                   onOut={() => setActiveIdx(-1)}
                   onOut={() => setActiveIdx(-1)}
-                  onClick={() => setInd(index)}
+                  onClick={() => setAcName(item.name)}
                   // @ts-ignore
                   // @ts-ignore
                   // onDown='draggable_hotspot()'
                   // onDown='draggable_hotspot()'
                 >
                 >
@@ -124,9 +125,9 @@ function PanoImg() {
         </Krpano>
         </Krpano>
       </KrpanoMiddleware>
       </KrpanoMiddleware>
 
 
-      {ind === -1 ? null : (
-        <Hot2 data={data} closeFu={() => setInd(-1)} name={myData.banquet.hot[ind].name} />
-      )}
+      {acName && info && info.data ? (
+        <Hot2 data={info.data} closeFu={() => setAcName('')} name={info.name} />
+      ) : null}
     </>
     </>
   )
   )
 }
 }