shaogen1995 2 年之前
父節點
當前提交
4fbaac008e

+ 2 - 2
webNew/public/model.html

@@ -20,8 +20,8 @@
   <script>
     let number = getQueryVariable("m");
     window.autoRotate = true; // 是否自动旋转
-    // fdage.embed('/goods/model/' + number, {
-      fdage.embed('https://hnbwg.4dage.com/goods/model/' + number, {
+    fdage.embed('/goods/model/' + number, {
+      // fdage.embed('https://hnbwg.4dage.com/goods/model/' + number, {
       transparentBackground: true,
       width: 800,
       height: 600,

+ 2 - 2
webNew/src/AppM.tsx

@@ -9,7 +9,7 @@ import React, { useEffect } from "react"
 import { Router, Route, Switch, Redirect } from "react-router-dom"
 import history from "./utils/history"
 const HomeM = React.lazy(() => import('./pages/HomeM'))
-// const Model = React.lazy(() => import('./pages/Model'))
+const ModelM = React.lazy(() => import('./pages/ModelM'))
 
 export default function AppM() {
 
@@ -26,7 +26,7 @@ export default function AppM() {
         <React.Suspense fallback={<div className='lodingApp'>加载中...</div>}>
           <Switch>
             <Redirect exact path="/" to="Home" />
-            {/* <Route path="/Model" component={Model} /> */}
+            <Route path="/Model" component={ModelM} />
             <Route path="/Home" component={HomeM} />
           </Switch>
         </React.Suspense>

+ 0 - 1
webNew/src/components/ModelM/index.tsx

@@ -7,7 +7,6 @@ import musicImg from '@/assets/img/music.png'
 import musicImgAc from '@/assets/img/musicAc.png'
 import styles from './index.module.scss'
 import { baseURL } from '@/utils/http';
-import { CaretDownOutlined, CaretUpOutlined } from '@ant-design/icons';
 
 type props = {
   modelId: number,

+ 129 - 0
webNew/src/pages/ModelM/index.module.scss

@@ -0,0 +1,129 @@
+.ModelM {
+  width: 100%;
+  height: 100%;
+  background-color: #cdbc8c;
+  background-image: url('../../assets/img/modelBacM.png');
+  background-size: 100% 100%;
+  position: relative;
+
+  :global {
+    .ifrBox {
+      position: absolute;
+      top: 2.5%;
+      left: 50%;
+      transform: translateX(-50%);
+      width: 92%;
+      height: calc(100% - 175px);
+
+      iframe {
+        width: 100%;
+        height: 100%;
+      }
+    }
+
+    .model_title {
+      background-image: url('../../assets/img/name.png');
+      background-size: 100% 100%;
+      position: absolute;
+      z-index: 10;
+      top: 20px;
+      left: 50%;
+      transform: translateX(-50%);
+      width: 210px;
+      height: 40px;
+      line-height: 40px;
+      font-weight: 700;
+      font-size: 18px;
+      text-align: center;
+    }
+
+    .rightTxt {
+      background-image: url('../../assets/img/txtM.png');
+      background-size: 100% 100%;
+      font-size: 12px;
+      position: absolute;
+      z-index: 10;
+      bottom: 10px;
+      left: 50%;
+      transform: translateX(-50%);
+      width: 90%;
+      height: 145px;
+      padding: 15px 10px;
+
+
+      .model_txt {
+        padding: 6px 6px 2px 6px;
+        height: 75px;
+        overflow-y: auto;
+      }
+
+
+
+      .model_floo {
+        margin-top: 12px;
+        display: flex;
+        justify-content: center;
+
+        p {
+          margin: 0;
+        }
+
+        &>div {
+          display: flex;
+        }
+
+        .model_sortRow {
+          margin-right: 20px;
+        }
+      }
+
+      .model_size {
+        padding: 0 3px;
+        margin-top: 2px;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        white-space: nowrap;
+        text-align: center;
+      }
+    }
+
+    .flootBtnBox {
+      position: absolute;
+      z-index: 10;
+      right: 20px;
+      bottom: 170px;
+
+      .flootRow {
+        width: 30px;
+        height: 30px;
+        cursor: pointer;
+        margin-right: 6px;
+        background-size: 100% 100%;
+        margin-top: 8px;
+      }
+
+      .flootRow1 {
+        background-image: url('../../assets/img/inco1.png');
+      }
+
+      .flootRow2 {
+        background-image: url('../../assets/img/inco2.png');
+      }
+
+      .flootRow3 {
+        background-image: url('../../assets/img/inco3.png');
+      }
+
+      .flootRow4 {
+        background-image: url('../../assets/img/inco4.png');
+      }
+
+      .flootRowM {
+        &>img {
+          width: 100%;
+          height: 100%;
+        }
+      }
+    }
+  }
+}

+ 118 - 0
webNew/src/pages/ModelM/index.tsx

@@ -0,0 +1,118 @@
+/* eslint-disable jsx-a11y/iframe-has-title */
+import { RootState } from '@/store';
+import { useEffect, useRef, useState } from 'react';
+import { useDispatch, useSelector } from 'react-redux';
+import musicImg from '@/assets/img/music.png'
+import musicImgAc from '@/assets/img/musicAc.png'
+import styles from './index.module.scss'
+import { baseURL } from '@/utils/http';
+import { useLocation } from 'react-router-dom';
+import { getModelInfo } from '@/store/action/home';
+
+export default function ModelM() {
+  const location = useLocation()
+
+  const dispatch = useDispatch()
+
+
+  // 发送请求获取信息,存到仓库
+  useEffect(() => {
+    const arr = location.search.split('=')
+    const id = arr[1]
+    dispatch(getModelInfo(id))
+  }, [dispatch, location.search])
+
+  // 从仓库获取信息
+  const info = useSelector((state: RootState) => state.homeStore.qrModel)
+
+
+  // 控制模型放大缩小和复位
+  const ifrBoxRef = useRef<any>(null)
+  const modelChangeFu = (val: number) => {
+    const dom = ifrBoxRef.current
+
+    if (dom && dom.contentWindow && dom.contentWindow.webview) {
+      if (val === 1) dom.contentWindow.webview.zoomIn()  // 放大
+      else if (val === 2) dom.contentWindow.webview.zoomOut() // 缩小
+      else dom.contentWindow.webview.resetView() // 复位
+    }
+  }
+
+
+  // 控制音乐播放暂停
+  const musicRef = useRef<HTMLAudioElement>(null)
+
+  const [music, setMusic] = useState(false)
+  const musicPlayFu = (flag: boolean) => {
+    const dom = musicRef.current
+    if (dom) {
+      if (flag) {
+
+        // 打开音乐
+        setMusic(true)
+        dom.play()
+        dom.addEventListener('ended', function () {
+          setMusic(false)
+        }, false);
+      } else {
+        // 关闭音乐
+        setMusic(false)
+        dom.pause()
+      }
+    }
+  }
+
+
+  return (
+    <div className={styles.ModelM}>
+      {/* 音频 */}
+      {info.audioPath ? (<audio src={baseURL + info.audioPath} ref={musicRef}></audio>) : null}
+      {/* 模型盒子 */}
+      <div className='ifrBox'>
+        {info.fileName ? (<iframe ref={ifrBoxRef} src={`model.html?m=${info.fileName}`} frameBorder='no'></iframe>) : null}
+
+      </div>
+      {/* 名字 */}
+        <div className='model_title'>{info.name}</div>
+
+      {/* 下边介绍 */}
+      <div className='rightTxt'>
+
+
+        {
+          info.description ? (<div className='model_txt' dangerouslySetInnerHTML={{ __html: info.description }}></div>) : <div className='model_txt'>暂无信息</div>
+        }
+
+        <div className='model_floo'>
+          <div className='model_sortRow'>类别:
+            <p>{info.dictTextureName ? info.dictTextureName : '(空)'}</p>
+          </div>
+          <div className='model_ageRow'>年代:
+            <p>{info.dictAgeName ? info.dictAgeName : '(空)'}</p>
+          </div>
+
+        </div>
+
+
+        {
+          <div className='model_size'>尺寸:{info.sizeLength ? info.sizeLength : '(空)'}
+          </div>
+        }
+
+      </div>
+
+      {/* 底部按钮 */}
+      <div className='flootBtnBox'>
+        <div className='flootRow flootRow1' onClick={() => modelChangeFu(1)}></div>
+        <div className='flootRow flootRow2' onClick={() => modelChangeFu(2)}></div>
+        {info.audioPath ? (<div className='flootRow flootRowM'>
+          {music ? (<img src={musicImgAc} alt="" onClick={() => musicPlayFu(false)} />) :
+            (<img src={musicImg} alt="" onClick={() => musicPlayFu(true)} />)}
+        </div>) : null}
+
+        <div className='flootRow flootRow4' onClick={() => modelChangeFu(3)}></div>
+      </div>
+
+    </div>
+  )
+}