|
|
@@ -0,0 +1,203 @@
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
+import styles from './index.module.scss'
|
|
|
+import classNames from 'classnames'
|
|
|
+import http from '@/utils/http'
|
|
|
+import { useHistory } from 'react-router-dom'
|
|
|
+import taohuanyuan from './image/D_taohuayuan.png'
|
|
|
+import xingtong from './image/D_xingtong.png'
|
|
|
+import xuni from './image/D_xuni.png'
|
|
|
+import address from './image/D_address.png'
|
|
|
+import like from './image/icon_like.png'
|
|
|
+import share from './image/icon_share.png'
|
|
|
+import intro from './image/icon_intro.png'
|
|
|
+import floor from './image/bg_floor.png'
|
|
|
+import map from './image/bg_map.png'
|
|
|
+import arrow from './image/arrow.png'
|
|
|
+
|
|
|
+import { message } from 'antd'
|
|
|
+import { Intro, MapIntro } from './component/Intro'
|
|
|
+import { Preview } from './component/Preview'
|
|
|
+
|
|
|
+const imgArrTemp = [
|
|
|
+ { src: 'Bao-0.png', title: '基本情况' },
|
|
|
+ { src: 'Bao-1.jpg', title: '休息洽谈区' },
|
|
|
+ { src: 'Bao-2.jpg', title: '汇报展示厅' },
|
|
|
+ { src: 'Bao-3.jpg', title: '会议室' },
|
|
|
+ { src: 'Bao-4.jpg', title: '智慧教室' },
|
|
|
+ { src: 'Bao-5.jpg', title: '共享工作室' },
|
|
|
+ { src: 'Bao-6.jpg', title: '共享办公区' },
|
|
|
+ { src: 'Bao-7.jpg', title: '贵宾接待室' },
|
|
|
+ { src: 'Bao-8.jpg', title: '茶憩文印室' },
|
|
|
+ { src: 'Bao-9.jpg', title: '休闲展览区' },
|
|
|
+ { src: 'Bao-10.jpg', title: '走廊' }
|
|
|
+]
|
|
|
+
|
|
|
+const imgArrTemp2 = [
|
|
|
+ { src: 'nan-0.png', title: '基本情况' },
|
|
|
+ { src: 'nan-1.jpg', title: '校史走廊' },
|
|
|
+ { src: 'nan-2.jpg', title: '校友之家' },
|
|
|
+ { src: 'nan-3.jpg', title: '专家办公室' },
|
|
|
+ { src: 'nan-4.jpg', title: '智慧教室' },
|
|
|
+ { src: 'nan-5.jpg', title: '开放办公区' },
|
|
|
+ { src: 'nan-6.jpg', title: '会议室' }
|
|
|
+]
|
|
|
+
|
|
|
+function Diagram({
|
|
|
+ imgSrc,
|
|
|
+ left,
|
|
|
+ top,
|
|
|
+ addressLeft,
|
|
|
+ addressTop,
|
|
|
+ text,
|
|
|
+ handleClick
|
|
|
+}: {
|
|
|
+ imgSrc: any
|
|
|
+ left: number
|
|
|
+ top: number
|
|
|
+ addressLeft: number
|
|
|
+ addressTop: number
|
|
|
+ text: string
|
|
|
+ handleClick: () => void
|
|
|
+}) {
|
|
|
+ console.log(imgSrc)
|
|
|
+ console.log(taohuanyuan)
|
|
|
+ return (
|
|
|
+ <div className={styles.diagram} style={{ left: `${left}%`, top: `${top}%` }}>
|
|
|
+ <img className='diagram-img' src={imgSrc} onClick={handleClick} alt='' />
|
|
|
+ <div className='diagram-address' style={{ left: `${addressLeft}%`, top: `${addressTop}%` }}>
|
|
|
+ <img src={address} alt='' />
|
|
|
+ <div className='diagram-text'>{text}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+function Layout({ setIsFloor }: { setIsFloor: (isFloor: boolean) => void }) {
|
|
|
+ const history = useHistory()
|
|
|
+ return (
|
|
|
+ <div className={styles.layout}>
|
|
|
+ <div className='back' onClick={() => setIsFloor(false)}>
|
|
|
+ <img src={require('./image/back.png')} alt='' />
|
|
|
+ </div>
|
|
|
+ <div className='layout-container'>
|
|
|
+ <div className='floor-1' onClick={() => history.push('/home?m=SG-dwRgbFq7Fiz')}>
|
|
|
+ 楼层23
|
|
|
+ </div>
|
|
|
+ <div className='floor-2'>楼层22</div>
|
|
|
+ <img src={arrow} alt='' className='arrow' />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+function A0Base() {
|
|
|
+ const [showIntro, setShowIntro] = useState(false)
|
|
|
+ const [isFloor, setIsFloor] = useState(false)
|
|
|
+ const [isPreview, setIsPreview] = useState<[boolean, string]>([false, ''])
|
|
|
+ const [likeCount, setLikeCount] = useState(0)
|
|
|
+ const [isLike, setIsLike] = useState(false)
|
|
|
+ const floor22sceneCode = 'SG-dwRgbFq7Fiz'
|
|
|
+ // const floor23sceneCode = 'SG-NqtcxoVBj5C'
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ http.get(`https://count.4dage.com/api/count/detail/${floor22sceneCode}`).then(res => {
|
|
|
+ setLikeCount(res.data.starSum)
|
|
|
+ })
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ const handleIntroClick = (isShow: boolean) => {
|
|
|
+ setShowIntro(isShow)
|
|
|
+ }
|
|
|
+ const handleShareClick = () => {
|
|
|
+ navigator.clipboard.writeText(window.location.href)
|
|
|
+ message.success('链接已复制到剪贴板')
|
|
|
+ }
|
|
|
+ const handleLikeClick = () => {
|
|
|
+ if (isLike) return
|
|
|
+ setIsLike(true)
|
|
|
+ setTimeout(() => {
|
|
|
+ http.get(`https://count.4dage.com/api/count/saveStar/${floor22sceneCode}`).then(res => {
|
|
|
+ setLikeCount(likeCount + 1)
|
|
|
+ setIsLike(false)
|
|
|
+ })
|
|
|
+ }, 2000)
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ className={styles.A0base}
|
|
|
+ style={{ backgroundImage: isFloor ? `url(${floor})` : `url(${map})` }}
|
|
|
+ >
|
|
|
+ {showIntro &&
|
|
|
+ (isFloor ? (
|
|
|
+ <Intro handleIntroClick={handleIntroClick} />
|
|
|
+ ) : (
|
|
|
+ <MapIntro handleIntroClick={handleIntroClick} />
|
|
|
+ ))}
|
|
|
+ {isFloor && !showIntro && <Layout setIsFloor={setIsFloor} />}
|
|
|
+
|
|
|
+ {!isFloor && !showIntro && !isPreview[0] && (
|
|
|
+ <>
|
|
|
+ <Diagram
|
|
|
+ imgSrc={taohuanyuan}
|
|
|
+ left={13.6}
|
|
|
+ top={8.2}
|
|
|
+ addressLeft={30.4}
|
|
|
+ addressTop={6}
|
|
|
+ text='桃花园科技创新生态园'
|
|
|
+ handleClick={() => setIsPreview([true, 'baoan'])}
|
|
|
+ />
|
|
|
+ <Diagram
|
|
|
+ imgSrc={xingtong}
|
|
|
+ left={9.6}
|
|
|
+ top={5}
|
|
|
+ addressLeft={25.6}
|
|
|
+ addressTop={73}
|
|
|
+ text='星通大厦'
|
|
|
+ handleClick={() => setIsFloor(true)}
|
|
|
+ />
|
|
|
+ <Diagram
|
|
|
+ imgSrc={xuni}
|
|
|
+ left={47.5}
|
|
|
+ top={-22}
|
|
|
+ addressLeft={55.5}
|
|
|
+ addressTop={85}
|
|
|
+ text='深圳虚拟大学园'
|
|
|
+ handleClick={() => setIsPreview([true, 'nanshang'])}
|
|
|
+ />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+
|
|
|
+ {isPreview[0] && (
|
|
|
+ <Preview
|
|
|
+ imgArr={isPreview[1] === 'baoan' ? imgArrTemp : imgArrTemp2}
|
|
|
+ setIsPreview={setIsPreview}
|
|
|
+ type={isPreview[1]}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ <div className='A0_iconBar' style={{ display: isPreview[0] ? 'none' : 'flex' }}>
|
|
|
+ <div className='A0_icon' onClick={() => handleLikeClick()}>
|
|
|
+ <div
|
|
|
+ className={classNames(isLike ? 'addLikeAc' : '', 'addLike')}
|
|
|
+ style={{ opacity: !isLike ? 0 : 1 }}
|
|
|
+ >
|
|
|
+ +1
|
|
|
+ </div>
|
|
|
+ <img className='A0_icon_like' src={like} alt='' />
|
|
|
+ <div>{likeCount}次赞</div>
|
|
|
+ </div>
|
|
|
+ <div className='A0_icon'>
|
|
|
+ <img className='A0_icon_intro' onClick={() => setShowIntro(true)} src={intro} alt='' />
|
|
|
+ <div>简介1</div>
|
|
|
+ </div>
|
|
|
+ <div className='A0_icon' onClick={() => handleShareClick()}>
|
|
|
+ <img className='A0_icon_share' src={share} alt='' />
|
|
|
+ <div>分享</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const MemoA0Base = React.memo(A0Base)
|
|
|
+
|
|
|
+export default MemoA0Base
|