shaogen1995 9 months ago
parent
commit
c675844f2b

+ 1 - 0
README.md

@@ -1,4 +1,5 @@
 暂时使用官网数据,后续一起部署到甲方服务器
+修改 isMyEnv 变量即可
 
 1.甲方服务器 使用 VPN:Hillstone Secure Connect 这个软件
 

+ 18 - 15
public/info/index.js

@@ -1,3 +1,6 @@
+// 环境:true为全部从甲方服务器拿数据(最后阶段把数据全部放到甲方服务器之后在修改为true)
+const isMyEnv = false
+
 const WKID = 'WK1856238346562650112'
 
 // 看看的数据(室外)
@@ -9,12 +12,12 @@ const KKlist1Temp = [
   },
   {
     name: '海军静展区',
-    id: 'kj2',
+    id: 'hj',
     children: ['海军静展区']
   },
   {
     name: 'SU57',
-    id: 'kj3',
+    id: 'SU57',
     children: ['SU57']
   }
 ]
@@ -74,67 +77,67 @@ const KKobjTemp = {
 const KKlist1Temp2 = [
   {
     name: '1号馆',
-    id: 'kj4',
+    id: 'n1',
     children: ['1号馆']
   },
   {
     name: '2号馆',
-    id: 'kj5',
+    id: 'n2',
     children: ['2号馆']
   },
   {
     name: '3号馆',
-    id: 'kj6',
+    id: 'n3',
     children: ['3号馆']
   },
   {
     name: '4号馆',
-    id: 'kj7',
+    id: 'n4',
     children: ['4号馆']
   },
   {
     name: '5号馆',
-    id: 'kj8',
+    id: 'n5',
     children: ['5号馆']
   },
   {
     name: '6号馆',
-    id: 'kj9',
+    id: 'n6',
     children: ['6号馆']
   },
   {
     name: '7号馆',
-    id: 'kj10',
+    id: 'n7',
     children: ['7号馆']
   },
   {
     name: '8号馆',
-    id: 'kj11',
+    id: 'n8',
     children: ['8号馆']
   },
   {
     name: '9号馆',
-    id: 'kj12',
+    id: 'n9',
     children: ['9号馆']
   },
   {
     name: '10号馆',
-    id: 'kj13',
+    id: 'n10',
     children: ['10号馆']
   },
   {
     name: '11号馆',
-    id: 'kj14',
+    id: 'n11',
     children: ['11号馆']
   },
   {
     name: '12号馆',
-    id: 'kj15',
+    id: 'n12',
     children: ['12号馆']
   },
   {
     name: '13号馆',
-    id: 'kj16',
+    id: 'n13',
     children: ['13号馆']
   }
 ]

+ 16 - 14
src/pages/A1home/Bottom/index.tsx

@@ -4,6 +4,8 @@ import styles from './index.module.scss'
 import xiaImg from '@/assets/img/jiantou_w.png'
 import classNames from 'classnames'
 import { MyList1Type, MyObjRowType } from './data'
+import { urlParameter } from '@/utils/history'
+import { kankanImgUrl, panoSomeData } from '@/utils/urlRes'
 
 type Props = {
   setTopObj: (val: MyObjRowType) => void
@@ -29,10 +31,19 @@ function Bottom({ setTopObj, pageKey }: Props) {
   const [myList1, setMyList1] = useState([] as MyList1Type[])
 
   useEffect(() => {
-    if (myList1[0] && myList1[0].children && myList1[0].children[0]) setAc1(myList1[0].children[0])
+    if (myList1[0] && myList1[0].children && myList1[0].children[0]) {
+      const urlObj = urlParameter(window.location.href)
+      if (urlObj.type) {
+        // 有参数
+        const acObj = myList1.find(v => v.id + '' === urlObj.type)
+        acObj && setAc1(acObj.children[0])
+      } else setAc1(myList1[0].children[0])
+    }
   }, [myList1])
 
   const getInfoFu = useCallback((data: any) => {
+    // 待完善,里面的所有数据待本地化之后 替换字符串
+
     const myList1Temp = data.catalogRoot
 
     const myObjTemp: any = {}
@@ -57,8 +68,7 @@ function Bottom({ setTopObj, pageKey }: Props) {
 
   useEffect(() => {
     if (pageKey === '室外') {
-      // 待完善路径
-      fetch(`https://4dkk.4dage.com/720yun_fd_manage/${WKID}/someData.json`)
+      fetch(panoSomeData)
         .then(res => {
           return res.json()
         })
@@ -125,22 +135,14 @@ function Bottom({ setTopObj, pageKey }: Props) {
               key={item.id}
               className={classNames(code === item.sceneCode ? 'activeTxt' : '')}
             >
-              {/* 图片路径待完善 */}
-
-              <img
-                src={
-                  item.type === 'kk'
-                    ? `https://4dkk.4dage.com/scene_view_data/${item.sceneCode}/user/thumb-2k.jpg`
-                    : item.icon
-                }
-                alt=''
-              />
+              {/* 图片路径 */}
+              <img src={item.type === 'kk' ? kankanImgUrl(item.sceneCode) : item.icon} alt='' />
 
               {/* 用图片懒加载,点击向下按钮之后 会有图片直接不加载的问题 */}
               {/* <LazyImg
                 src={
                   item.type === 'kk'
-                    ? `https://4dkk.4dage.com/scene_view_data/${item.sceneCode}/user/thumb-2k.jpg`
+                    ? kankanImgUrl(item.sceneCode)
                     : item.icon
                 }
               /> */}

+ 10 - 7
src/pages/A1home/index.tsx

@@ -12,9 +12,10 @@ import bgmMp3 from '@/assets/img/bgm.mp3'
 import Share from './Share'
 import Bottom from './Bottom'
 import { MyObjRowType } from './Bottom/data'
-import { isMobileFu } from '@/utils/history'
+import { isMobileFu, urlParameter } from '@/utils/history'
 
 import xiaImg from '@/assets/img/jiantou_w.png'
+import { kankanUrl, panoBaseUrl } from '@/utils/urlRes'
 
 function A1home() {
   const audioRef = useRef<HTMLAudioElement>(null)
@@ -28,8 +29,11 @@ function A1home() {
   const [pageKey, setPageKey] = useState<'首页' | '室内' | '室外'>('首页')
 
   useEffect(() => {
-    if (window.location.href.includes('?type=kj')) {
-      setPageKey('室外')
+    const urlObj = urlParameter(window.location.href)
+    if (urlObj.type) {
+      if (KKlist1Temp2.find((v: any) => v.id === urlObj.type)) setPageKey('室内')
+      else setPageKey('室外')
+      // if (KKlist1Temp.find((v: any) => v.id === urlObj.type)) setPageKey('室外')
     }
   }, [])
 
@@ -53,9 +57,8 @@ function A1home() {
     if (acObj.type && acObj.type !== 'kk') {
       // 加载全景
       embedpano({
-        // 地址待完善
         swf: `//www.4dkankan.com/panorama/showviewer/lib/krpano/tour.swf`,
-        xml: `//4dkk.4dage.com/720yun_fd_manage/${WKID}/tour.xml`,
+        xml: panoBaseUrl,
         target: 'panoBox',
         html5: 'auto',
         mobilescale: 1.0,
@@ -139,11 +142,11 @@ function A1home() {
           <div className='A1title'>{acObj.sceneTitle}</div>
 
           <div className='iframeBox'>
-            {/* 四维看看 地址待完善*/}
+            {/* 四维看看*/}
             {acObj.type === 'kk' ? (
               <iframe
                 key={acObj.sceneCode}
-                src={`https://www.4dkankan.com/spg.html?m=${acObj.sceneCode}&hideNav`}
+                src={kankanUrl(acObj.sceneCode)}
                 frameBorder='0'
                 title='qj'
               ></iframe>

+ 4 - 1
src/types/declaration.d.ts

@@ -24,5 +24,8 @@ declare const KKobjTemp2
 // 介绍
 declare const myText: string
 
-// 全图加载数据
+// 全图加载数据
 declare const embedpano: any
+
+// 环境
+declare const isMyEnv: boolean

+ 15 - 0
src/utils/history.ts

@@ -12,3 +12,18 @@ export const isMobileFu = () => {
     return true
   } else return false
 }
+
+// 获取地址栏参数
+export const urlParameter = (data: string) => {
+  if (data) {
+    const query = data.substring(data.indexOf('?') + 1)
+    const arr = query.split('&')
+    const params = {} as any
+    arr.forEach(v => {
+      const key = v.substring(0, v.indexOf('='))
+      const val = v.substring(v.indexOf('=') + 1)
+      params[key] = val
+    })
+    return params
+  } else return {}
+}

+ 21 - 0
src/utils/urlRes.ts

@@ -0,0 +1,21 @@
+// 全景xml加载地址
+export const panoBaseUrl = isMyEnv
+  ? 'xxxxxxxxxx'
+  : `https://4dkk.4dage.com/720yun_fd_manage/${WKID}/tour.xml`
+
+// 全景someData数据加载地址
+export const panoSomeData = isMyEnv
+  ? 'xxxxxxxxxxxxxxxxx'
+  : `https://4dkk.4dage.com/720yun_fd_manage/${WKID}/someData.json`
+
+// 四维看看加载地址
+export const kankanUrl = (code: string) => {
+  return isMyEnv ? 'xxxxxxxxxxxxx' : `https://www.4dkankan.com/spg.html?m=${code}&hideNav`
+}
+
+// 四维看看封面图路径
+export const kankanImgUrl = (code: string) => {
+  return isMyEnv
+    ? 'xxxxxxxxxxxxx'
+    : `https://4dkk.4dage.com/scene_view_data/${code}/user/thumb-2k.jpg`
+}