Browse Source

我自己的热点详情页

任一存 2 năm trước cách đây
mục cha
commit
a6b3162103

+ 45 - 5
.eslintrc.js

@@ -1,17 +1,57 @@
+// ESLint 检查 .vue 文件需要单独配置编辑器:
+// https://eslint.vuejs.org/user-guide/#editor-integrations
 module.exports = {
   root: true,
   env: {
-    node: true
+    browser: true,
+    commonjs: true,
+    es6: true,
+    jest: true,
+    jquery: true,
+    node: true,
   },
   'extends': [
-    'plugin:vue/essential',
-    'eslint:recommended'
+    'eslint:recommended',
+    // "plugin:vue/base",
+    'plugin:vue/recommended',
   ],
   parserOptions: {
     parser: 'babel-eslint'
+    // "parser": "@babel/eslint-parser"
   },
   rules: {
     'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
-    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
+    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
+    'semi': ['error', 'never'],
+    "no-unused-vars": ["warn", {
+      "vars": "all",
+      "args": "after-used",
+      "ignoreRestSiblings": false
+    }],
+    "keyword-spacing": ["error", { "before": true, "after": true }],
+    "object-curly-spacing": ["error", "always"],
+    "space-infix-ops": ["error"],
+    'key-spacing': ["error", {
+      "mode": "strict"
+    }],
+    "comma-spacing": ["error", { "before": false, "after": true }],
+    "func-call-spacing": ["error", "never"],
+    "semi-spacing": ["error", { "before": false, "after": true }],
+    "space-before-blocks": ["error", "always"],
+    'no-trailing-spaces': 'error',
+    'no-multi-spaces': 'error',
+    "indent": ["error", 2],
+    'no-empty': 'off',
+    // 默认不启用:为了避免细微的 bug,最好直接从 Object.prototype 调用挂载于prototype上的方法方法。例如,foo.hasOwnProperty("bar") 应该替换为 Object.prototype.hasOwnProperty.call(foo, "bar")。
+    'no-prototype-builtins': "off",
+  },
+  globals: {
+    api: true,
+    config: true,
+    mapState: true,
+    mapGetters: true,
+    mapMutations: true,
+    store: true,
+    utils: true,
   }
-}
+}

+ 15 - 34
package-lock.json

@@ -10,7 +10,7 @@
       "dependencies": {
         "axios": "^0.20.0",
         "core-js": "^3.6.5",
-        "swiper": "^5.4.5",
+        "swiper": "^9.0.3",
         "v-viewer": "^1.5.1",
         "vue": "^2.6.11",
         "vue-awesome-swiper": "^4.1.1",
@@ -5342,14 +5342,6 @@
       "integrity": "sha1-87blSSAeRvWItZRj3XcYcTH+aXE=",
       "dev": true
     },
-    "node_modules/dom7": {
-      "version": "2.1.5",
-      "resolved": "https://registry.npm.taobao.org/dom7/download/dom7-2.1.5.tgz",
-      "integrity": "sha1-p5QRAXgAsx2EAAcM2uu/ySwfY3c=",
-      "dependencies": {
-        "ssr-window": "^2.0.0"
-      }
-    },
     "node_modules/domain-browser": {
       "version": "1.2.0",
       "resolved": "https://registry.npm.taobao.org/domain-browser/download/domain-browser-1.2.0.tgz?cache=0&sync_timestamp=1599393068432&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdomain-browser%2Fdownload%2Fdomain-browser-1.2.0.tgz",
@@ -12072,9 +12064,9 @@
       }
     },
     "node_modules/ssr-window": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-2.0.0.tgz",
-      "integrity": "sha512-NXzN+/HPObKAx191H3zKlYomE5WrVIkoCB5IaSdvKokxTpjBdWfr0RaP+1Z5KOfDT0ZVz+2tdtiBkhsEQ9p+0A=="
+      "version": "4.0.2",
+      "resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-4.0.2.tgz",
+      "integrity": "sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ=="
     },
     "node_modules/ssri": {
       "version": "6.0.1",
@@ -12398,13 +12390,11 @@
       }
     },
     "node_modules/swiper": {
-      "version": "5.4.5",
-      "resolved": "https://registry.npmmirror.com/swiper/-/swiper-5.4.5.tgz",
-      "integrity": "sha512-7QjA0XpdOmiMoClfaZ2lYN6ICHcMm72LXiY+NF4fQLFidigameaofvpjEEiTQuw3xm5eksG5hzkaRsjQX57vtA==",
-      "hasInstallScript": true,
+      "version": "9.0.4",
+      "resolved": "https://registry.npmmirror.com/swiper/-/swiper-9.0.4.tgz",
+      "integrity": "sha512-YH4sUh68DYw7vcoBZQ+DeBV6/wLZIRf8dZ4CzkvRTcvDPkIF6oweBdOjKnsXtoPCSUQbtqbZcLRghkfOtd5UYA==",
       "dependencies": {
-        "dom7": "^2.1.5",
-        "ssr-window": "^2.0.0"
+        "ssr-window": "^4.0.2"
       },
       "engines": {
         "node": ">= 4.7.0"
@@ -18919,14 +18909,6 @@
         }
       }
     },
-    "dom7": {
-      "version": "2.1.5",
-      "resolved": "https://registry.npm.taobao.org/dom7/download/dom7-2.1.5.tgz",
-      "integrity": "sha1-p5QRAXgAsx2EAAcM2uu/ySwfY3c=",
-      "requires": {
-        "ssr-window": "^2.0.0"
-      }
-    },
     "domain-browser": {
       "version": "1.2.0",
       "resolved": "https://registry.npm.taobao.org/domain-browser/download/domain-browser-1.2.0.tgz?cache=0&sync_timestamp=1599393068432&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fdomain-browser%2Fdownload%2Fdomain-browser-1.2.0.tgz",
@@ -24536,9 +24518,9 @@
       }
     },
     "ssr-window": {
-      "version": "2.0.0",
-      "resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-2.0.0.tgz",
-      "integrity": "sha512-NXzN+/HPObKAx191H3zKlYomE5WrVIkoCB5IaSdvKokxTpjBdWfr0RaP+1Z5KOfDT0ZVz+2tdtiBkhsEQ9p+0A=="
+      "version": "4.0.2",
+      "resolved": "https://registry.npmmirror.com/ssr-window/-/ssr-window-4.0.2.tgz",
+      "integrity": "sha512-ISv/Ch+ig7SOtw7G2+qkwfVASzazUnvlDTwypdLoPoySv+6MqlOV10VwPSE6EWkGjhW50lUmghPmpYZXMu/+AQ=="
     },
     "ssri": {
       "version": "6.0.1",
@@ -24817,12 +24799,11 @@
       }
     },
     "swiper": {
-      "version": "5.4.5",
-      "resolved": "https://registry.npmmirror.com/swiper/-/swiper-5.4.5.tgz",
-      "integrity": "sha512-7QjA0XpdOmiMoClfaZ2lYN6ICHcMm72LXiY+NF4fQLFidigameaofvpjEEiTQuw3xm5eksG5hzkaRsjQX57vtA==",
+      "version": "9.0.4",
+      "resolved": "https://registry.npmmirror.com/swiper/-/swiper-9.0.4.tgz",
+      "integrity": "sha512-YH4sUh68DYw7vcoBZQ+DeBV6/wLZIRf8dZ4CzkvRTcvDPkIF6oweBdOjKnsXtoPCSUQbtqbZcLRghkfOtd5UYA==",
       "requires": {
-        "dom7": "^2.1.5",
-        "ssr-window": "^2.0.0"
+        "ssr-window": "^4.0.2"
       }
     },
     "table": {

+ 1 - 1
package.json

@@ -10,9 +10,9 @@
   "dependencies": {
     "axios": "^0.20.0",
     "core-js": "^3.6.5",
-    "swiper": "^5.4.5",
     "v-viewer": "^1.5.1",
     "vue": "^2.6.11",
+    "swiper": "^9.0.3",
     "vue-awesome-swiper": "^4.1.1",
     "vue-lazyload": "^1.3.3",
     "vue-router": "^3.2.0"

BIN
src/assets/images/arrow-left.png


BIN
src/assets/images/arrow-right.png


BIN
src/assets/images/close.png


+ 60 - 0
src/assets/style/my-reset.css

@@ -0,0 +1,60 @@
+*,
+*::before,
+*::after {
+  /* 阻止safari在用户交互设置一些元素的背景色 */
+  -webkit-tap-highlight-color: transparent;
+  box-sizing: border-box;
+}
+
+html {
+  overflow: hidden;
+  touch-action: none;
+  scroll-behavior: smooth; /* MDN: When this property is specified on the root element, it applies to the viewport instead. This property specified on the body element will not propagate to the viewport.(???) */
+  height: 100%;
+}
+
+body {
+  text-align: justify;
+  height: 100%;
+  overflow: hidden;
+}
+
+a {
+  color: initial;
+  text-decoration: initial;
+  outline: none;
+}
+
+button {
+  padding: 0;
+  cursor: pointer;
+  background-color: initial;
+  border: initial;
+  outline: none;
+  white-space: pre;
+}
+
+img {
+  user-select: none;
+}
+
+menu {
+  list-style-type: initial;
+}
+
+li {
+  display: initial;
+}
+
+input {
+  outline: initial;
+  background: initial;
+  border: initial;
+  border-radius: initial;
+  width: initial;
+  height: initial;
+}
+
+td {
+  vertical-align: inherit;
+}

+ 48 - 0
src/assets/style/reset.css

@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/ 
+   v2.0 | 20110126
+   License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed, 
+figure, figcaption, footer, header, hgroup, 
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	font-size: 100%;
+	font: inherit;
+	vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure, 
+footer, header, hgroup, menu, nav, section {
+	display: block;
+}
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}

+ 8 - 0
src/main.js

@@ -1,3 +1,5 @@
+import "@/assets/style/reset.css"
+import "@/assets/style/my-reset.css"
 import Vue from 'vue'
 import App from './App.vue'
 import router from './router'
@@ -6,6 +8,12 @@ import 'viewerjs/dist/viewer.css'
 import Viewer from 'v-viewer'
 // 图片懒加载
 import VueLazyLoad from 'vue-lazyload'
+
+// 禁用上下文菜单
+document.oncontextmenu = function(e) {
+  e.preventDefault()
+}
+
 Vue.use(VueLazyLoad, {
   error: require('@/assets/images/IMGerror.png'),
   loading: require('@/assets/images/loading.gif')

+ 10 - 4
src/router/index.js

@@ -1,14 +1,20 @@
 import Vue from 'vue'
 import VueRouter from 'vue-router'
-import Home from '../views/Home.vue'
+// import Home from '../views/Home.vue'
+import HomeNew from '../views/HomeNew.vue'
 
 Vue.use(VueRouter)
 
 const routes = [
+  // {
+  //   path: '/',
+  //   name: 'Home',
+  //   component: Home
+  // },
   {
-    path: '/',
-    name: 'Home',
-    component: Home
+    path: '/new',
+    name: 'HomeNew',
+    component: HomeNew
   },
 ]
 

+ 27 - 27
src/utils/browser.js

@@ -1,29 +1,29 @@
 function versions () {
-    var u = window.navigator.userAgent
-    return {
-      // IE内核
-      trident: u.indexOf('Trident') > -1,
-      // opera内核
-      presto: u.indexOf('Presto') > -1,
-      // 苹果、谷歌内核
-      webKit: u.indexOf('AppleWebKit') > -1,
-      // 火狐内核
-      gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1,
-      // 是否为移动终端 / Tablets use desktop version
-      mobile: (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) && !(/Tablet|iPad/i.test(navigator.userAgent)),
-      // ios终端
-      ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
-      // android终端或者uc浏览器
-      android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
-      // 是否为iPhone或者安卓QQ浏览器
-      iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1,
-      // 是否为iPad
-      iPad: u.indexOf('iPad') > -1,
-      // 是否为web应用程序,没有头部与底部
-      webApp: u.indexOf('Safari') === -1,
-      // 是否为微信浏览器
-      weixin: ~u.indexOf('MicroMessenger')
-    }
+  var u = window.navigator.userAgent
+  return {
+    // IE内核
+    trident: u.indexOf('Trident') > -1,
+    // opera内核
+    presto: u.indexOf('Presto') > -1,
+    // 苹果、谷歌内核
+    webKit: u.indexOf('AppleWebKit') > -1,
+    // 火狐内核
+    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') === -1,
+    // 是否为移动终端 / Tablets use desktop version
+    mobile: (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) && !(/Tablet|iPad/i.test(navigator.userAgent)),
+    // ios终端
+    ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
+    // android终端或者uc浏览器
+    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
+    // 是否为iPhone或者安卓QQ浏览器
+    iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1,
+    // 是否为iPad
+    iPad: u.indexOf('iPad') > -1,
+    // 是否为web应用程序,没有头部与底部
+    webApp: u.indexOf('Safari') === -1,
+    // 是否为微信浏览器
+    weixin: ~u.indexOf('MicroMessenger')
   }
-  
-  export default versions()
+}
+
+export default versions()

+ 171 - 145
src/views/Home.vue

@@ -3,127 +3,144 @@
   <div class="home">
     <audio
       v-if="audio"
-      class="audio"
       id="audio1"
+      ref="musicBg"
+      class="audio"
       :src="audio"
       preload
-      ref="musicBg"
       @ended="overAudio"
-    ></audio>
+    />
     <div
-      class="content"
       v-if="(!audio && fixIcon.length > 0) || (audio && fixIcon.length > 1)"
+      class="content"
       :class="{ isMobileCon: isMobile }"
     >
       <div
         v-if="!isMobile && lengthShow"
-        @click="slideto('slidePrev')"
         class="swiper-button-prev"
-      ></div>
-      <div class="mb-intro" v-show="active === 'title' && isMobile">
-        <p v-html="data.title"></p>
-        <p v-html="data.content"></p>
+        @click="slideto('slidePrev')"
+      />
+      <div
+        v-show="active === 'title' && isMobile"
+        class="mb-intro"
+      >
+        <p v-html="data.title" />
+        <p v-html="data.content" />
         <p
-          v-html="data.imagesDesc[myInd]"
           v-if="
             data.imagesDesc && data.imagesDesc[myInd] && active === 'images'
           "
-        ></p>
+          v-html="data.imagesDesc[myInd]"
+        />
         <p
-          v-html="data.videosDesc[myInd]"
           v-if="data.videosDesc && data.videosDesc[myInd] && active === 'video'"
-        ></p>
+          v-html="data.videosDesc[myInd]"
+        />
       </div>
       <!-- 查看图片 -->
-      <viewer class="viewerCla" ref="viewer" :images="lookPics">
-        <img :src="lookPics[0]" alt="" />
+      <viewer
+        ref="viewer"
+        class="viewerCla"
+        :images="lookPics"
+      >
+        <img
+          :src="lookPics[0]"
+          alt=""
+        >
       </viewer>
 
       <swiper
         v-show="active !== 'title'"
-        class="warpper"
         ref="mySwiper"
+        class="warpper"
         :options="swiperOptions"
       >
-        <swiper-slide v-for="(item, i) in data[active]" :key="i">
+        <swiper-slide
+          v-for="(item, i) in data[active]"
+          :key="i"
+        >
           <div class="slide">
             <img
-              style="cursor: pointer"
               v-if="active === 'images'"
               v-lazy="fixUrl(item)"
-              @click="lookImg(fixUrl(item))"
+              style="cursor: pointer"
               alt=""
-            />
+              @click="lookImg(fixUrl(item))"
+            >
             <video
-              class="videoDom"
               v-else-if="active === 'video'"
+              class="videoDom"
               :src="fixUrl(item.url)"
               controls
-            ></video>
+            />
             <iframe
-              @click="colseParent(item)"
               v-else-if="active === 'model' || active === 'iframe'"
               :src="fixUrl(item)"
               frameborder="0"
-            ></iframe>
+              @click="colseParent(item)"
+            />
           </div>
         </swiper-slide>
         <div
-          class="swiper-pagination"
-          slot="pagination"
           v-show="lengthShow"
-        ></div>
+          slot="pagination"
+          class="swiper-pagination"
+        />
       </swiper>
       <div
         v-if="!isMobile && lengthShow"
-        @click="slideto('slideNext')"
         class="swiper-button-next"
-      ></div>
+        @click="slideto('slideNext')"
+      />
     </div>
     <ul
-      class="iconarr"
       v-if="fixIcon.length > 0"
+      class="iconarr"
       :class="{ oneChuMusic: fixIcon.length === 1 && !audio }"
     >
       <li
+        v-for="(item, i) in fixIcon"
+        :key="i"
         :class="{
           active: item.id === active || item.audioAc,
           onlyTxt: audio && fixIcon.length === 2 && i !== 0,
         }"
         @click="changeActive(item.id, item.audioAc)"
-        v-for="(item, i) in fixIcon"
-        :key="i"
       >
-        <img :src="require(`@/assets/images/${item.img}.png`)" alt="" />
+        <img
+          :src="require(`@/assets/images/${item.img}.png`)"
+          alt=""
+        >
         <span>{{ item.name }}</span>
       </li>
     </ul>
+    <!-- 文字解说 -->
     <div
+      v-if="!isMobile || (isMobile && fixIcon.length <= 0)"
       class="intro"
       :class="{
         ismtop:
           (!audio && fixIcon.length === 0) || (audio && fixIcon.length === 1),
       }"
-      v-if="!isMobile || (isMobile && fixIcon.length <= 0)"
     >
-      <h3 v-html="data.title"></h3>
-      <p v-html="data.content"></p>
+      <h3 v-html="data.title" />
+      <p v-html="data.content" />
       <p
-        v-html="data.imagesDesc[myInd]"
         v-if="data.imagesDesc && data.imagesDesc[myInd] && active === 'images'"
-      ></p>
+        v-html="data.imagesDesc[myInd]"
+      />
       <p
-        v-html="data.videosDesc[myInd]"
         v-if="data.videosDesc && data.videosDesc[myInd] && active === 'video'"
-      ></p>
+        v-html="data.videosDesc[myInd]"
+      />
     </div>
   </div>
 </template>
 
 <script>
-import { Swiper, SwiperSlide } from "vue-awesome-swiper";
-import "swiper/css/swiper.css";
-import browser from "@/utils/browser";
+import { Swiper, SwiperSlide } from "vue-awesome-swiper"
+import "swiper/css/swiper.css"
+import browser from "@/utils/browser"
 
 let iconArr = [
   {
@@ -137,13 +154,17 @@ let iconArr = [
   { name: "视频", id: "video", img: "video-icon", display: false },
   { name: "网页", id: "iframe", img: "iframe-icon", display: false },
   { name: "模型", id: "model", img: "model-icon", display: false },
-];
+]
 
 browser.mobile &&
-  iconArr.push({ name: "介绍", id: "title", img: "txt-icon", display: false });
+  iconArr.push({ name: "介绍", id: "title", img: "txt-icon", display: false })
 
 export default {
   name: "Home",
+  components: {
+    Swiper,
+    SwiperSlide,
+  },
   data() {
     return {
       lookPics: [],
@@ -159,38 +180,47 @@ export default {
       isAndriod: browser.android,
       swiperOptions: browser.mobile
         ? {
-            pagination: {
-              el: ".swiper-pagination",
-              clickable: true,
-            },
-            on: {
-              slideChangeTransitionEnd: () => {
-                let swiper = this.$refs.mySwiper.$swiper;
-                let activeIndex = swiper.activeIndex;
-                this.myInd = activeIndex;
-              },
+          pagination: {
+            el: ".swiper-pagination",
+            clickable: true,
+          },
+          on: {
+            slideChangeTransitionEnd: () => {
+              let swiper = this.$refs.mySwiper.$swiper
+              let activeIndex = swiper.activeIndex
+              this.myInd = activeIndex
             },
-          }
+          },
+        }
         : {
-            slidesPerView: 3,
-            spaceBetween: 0,
-            centeredSlides: true,
-            pagination: {
-              el: ".swiper-pagination",
-              clickable: true,
-            },
-            on: {
-              slideChangeTransitionEnd: () => {
-                let swiper = this.$refs.mySwiper.$swiper;
-                let activeIndex = swiper.activeIndex;
-                this.myInd = activeIndex;
-              },
+          slidesPerView: 3,
+          spaceBetween: 0,
+          centeredSlides: true,
+          pagination: {
+            el: ".swiper-pagination",
+            clickable: true,
+          },
+          on: {
+            slideChangeTransitionEnd: () => {
+              let swiper = this.$refs.mySwiper.$swiper
+              let activeIndex = swiper.activeIndex
+              this.myInd = activeIndex
             },
           },
+        },
       data: {},
       iconArr,
       active: "",
-    };
+    }
+  },
+  computed: {
+    swiper() {
+      return this.$refs.mySwiper.$swiper
+    },
+    fixIcon() {
+      let arr = this.iconArr.filter((item) => !!item.display)
+      return arr
+    },
   },
   watch: {
     myInd: {
@@ -199,116 +229,113 @@ export default {
           setTimeout(() => {
             if (this.active == "video") {
               // 控制当前选中的视频播放
-              let videoDoms = document.querySelectorAll(".videoDom");
+              let videoDoms = document.querySelectorAll(".videoDom")
               videoDoms.forEach((v, i) => {
-                if (i === newv) v.play();
-                else v.pause();
-              });
+                if (i === newv) v.play()
+                else v.pause()
+              })
             }
-          }, 500);
-        });
+          }, 500)
+        })
       },
       immediate: true,
     },
 
     active(newVal) {
-      let AcDataLength = this.data[newVal].length - 1;
-      if (this.myInd > AcDataLength) this.myInd = AcDataLength;
+      let AcDataLength = this.data[newVal].length - 1
+      if (this.myInd > AcDataLength) this.myInd = AcDataLength
 
       // 判断是否只有一张图片或者视频,ifrm   lengthShow
-      let tempType = this.data[newVal];
+      let tempType = this.data[newVal]
       if (tempType && tempType.length && tempType.length > 1)
-        this.lengthShow = true;
-      else this.lengthShow = false;
+        this.lengthShow = true
+      else this.lengthShow = false
       if (!newVal) {
-        return;
+        return
       }
       if (!this.$refs.musicBg) {
-        return;
+        return
       }
       // 如果点击的是音频
       setTimeout(() => {
         if (newVal == "video") {
-          this.audioAc(false);
+          this.audioAc(false)
           if (!this.$refs.musicBg.paused) {
-            this.$refs.musicBg.pause();
+            this.$refs.musicBg.pause()
           }
         }
         // 控制当前选中的视频播放
-        let videoDoms = document.querySelectorAll(".videoDom");
+        let videoDoms = document.querySelectorAll(".videoDom")
         videoDoms.forEach((v, i) => {
-          if (i === this.myInd) v.play();
-          else v.pause();
-        });
-      }, 500);
-    },
-  },
-  computed: {
-    swiper() {
-      return this.$refs.mySwiper.$swiper;
-    },
-    fixIcon() {
-      let arr = this.iconArr.filter((item) => !!item.display);
-      return arr;
+          if (i === this.myInd) v.play()
+          else v.pause()
+        })
+      }, 500)
     },
   },
-  components: {
-    Swiper,
-    SwiperSlide,
+  mounted() {
+    this.getData()
+    document.addEventListener(
+      "WeixinJSBridgeReady",
+      () => {
+        this.autoplay()
+      },
+      false
+    )
   },
   methods: {
     // 点击查看大图
     lookImg(url) {
-      let dom = this.$refs.viewer.$viewer;
-      this.lookPics = [url];
-      dom.show();
+      let dom = this.$refs.viewer.$viewer
+      this.lookPics = [url]
+      dom.show()
     },
     // 音频播放完毕
     overAudio() {
-      console.log("播放声音完毕");
-      this.audioAc(false);
+      console.log("播放声音完毕")
+      this.audioAc(false)
     },
     // 音频的状态
     audioAc(flag) {
       this.iconArr.forEach((v) => {
-        if (v.id === "audio") v.audioAc = flag;
-      });
+        if (v.id === "audio") v.audioAc = flag
+      })
     },
     // 点击切换图片--视频
     changeActive(id, flag) {
       if (id === "audio" && flag === false) {
-        this.audioAc(true);
-        this.$refs.musicBg.play();
-        return;
+        this.audioAc(true)
+        this.$refs.musicBg.play()
+        return
       } else if (id === "audio" && flag === true) {
-        this.audioAc(false);
-        this.$refs.musicBg.pause();
-        return;
+        this.audioAc(false)
+        this.$refs.musicBg.pause()
+        return
       }
-      this.active = id;
+      this.active = id
     },
     async getData() {
       // https://www.4dmodel.com/
       let url = `https://super.4dage.com/data/${
         this.id
-      }/hot/js/data.js?time=${Math.random()}`;
-      let result = (await this.$http.get(url)).data;
-      this.data = result[this.m];
+      }/hot/js/data.js?time=${Math.random()}`
+      let result = (await this.$http.get(url)).data
+      this.data = result[this.m]
       if (!this.data) {
-        return alert("热点解析错误");
+        return alert("热点解析错误")
       }
-      this.audio = this.data["backgroundMusic"];
+      this.audio = this.data["backgroundMusic"]
       if (!this.data.content && this.isMobile) {
-        this.iconArr.pop();
+        this.iconArr.pop()
       }
       this.iconArr.forEach((item) => {
         if (this.data[item.id]) {
-          this.active = !this.active ? item.id : this.active;
-          item.display = true;
+          this.active = !this.active ? item.id : this.active
+          item.display = true
         }
         // 如果有音频
-        if (item.id === "audio" && this.audio) item.display = true;
-      });
+        if (item.id === "audio" && this.audio) item.display = true
+      })
     },
 
     colseParent(item) {
@@ -317,13 +344,13 @@ export default {
           item.indexOf("mp.weixin.qq.com/mp/") > -1 &&
           this.active === "iframe"
         ) {
-          window.parent.document.getElementById("closepop").click();
+          window.parent.document.getElementById("closepop").click()
         }
       }
     },
     fixUrl(item) {
       let condition =
-        item.indexOf("http://") > -1 || item.indexOf("https://") > -1;
+        item.indexOf("http://") > -1 || item.indexOf("https://") > -1
       if (this.isMobile) {
         if (
           item.indexOf("mp.weixin.qq.com/mp/") > -1 &&
@@ -331,29 +358,19 @@ export default {
         ) {
           return `https://www.4dmodel.com/SuperTwo/hot_online1/linktoWC.html?url=${encodeURIComponent(
             item
-          )}`;
+          )}`
         }
       }
       if (!condition) {
-        return "https://" + item;
+        return "https://" + item
       }
-      return item;
+      return item
     },
     slideto(action) {
-      this.swiper[action]();
+      this.swiper[action]()
     },
   },
-  mounted() {
-    this.getData();
-    document.addEventListener(
-      "WeixinJSBridgeReady",
-      () => {
-        this.autoplay();
-      },
-      false
-    );
-  },
-};
+}
 </script>
 
 <style lang="less" scoped>
@@ -381,10 +398,19 @@ export default {
   }
 }
 .home {
-  background-color: rgba(0, 0, 0, 0.6);
+  position: absolute;
+  left: 50%;
+  top: 50%;
+  transform: translate(-50%, -50%);
   width: 100%;
   height: 100%;
-  position: relative;
+  max-width: 1329px;
+  max-height: 848px;
+  background: #E5DFCD;
+  border-top: solid 8px #A10E0C;
+  border-bottom: solid 8px #A10E0C;
+  padding: 28px 100px;
+  box-sizing: border-box;
   .content {
     width: 100%;
     height: 80%;

+ 354 - 0
src/views/HomeNew.vue

@@ -0,0 +1,354 @@
+<template>
+  <div class="hotspot-home">
+    <h1
+      :title="hotspotData.title"
+      v-html="hotspotData.title"
+    />
+
+    <button
+      class="close"
+      @click="onClickClose"
+    >
+      <img
+        src="@/assets/images/close.png"
+        alt="关闭"
+        draggable="false"
+      >
+    </button>
+
+    <div
+      v-if="isShowVideos"
+      class="swiper-wrapper-mine video-wrap"
+    >
+      <div
+        class="swiper-root swiper-root"
+      >
+        <div
+          class="swiper-wrapper"
+        >
+          <div
+            v-for="(item, index) in hotspotData.video"
+            :key="index"
+            class="swiper-slide"
+          >
+            <video
+              ref="video"
+              :src="item.url"
+              controls
+              controlslist="nodownload"
+              disablePictureInPicture
+            />
+          </div>
+        </div>
+        <div class="swiper-pagination">
+          <!-- <span class="cur">{{ currentSlideIdx + 1 }}</span> / <span>{{ typesForShow[currentTabIdx].list.length }}</span> -->
+        </div>
+        <div class="swiper-button-prev" />
+        <div class="swiper-button-next" />
+      </div>
+    </div>
+
+    <div
+      v-show="isShowImages"
+      class="swiper-wrapper-mine image-wrap"
+    >
+      <div
+        class="swiper-root"
+      >
+        <div
+          v-viewer="{
+            button: true,
+            navbar: false,
+            title: false,
+            toolbar: false,
+            tooltip: false,
+            movable: true,
+            zoomable: true,
+            rotatable: true,
+            scalable: true,
+            transition: false,
+            fullscreen: false,
+            keyboard: true,
+            loop: false,
+          }"
+          class="swiper-wrapper"
+        >
+          <img
+            v-for="(item, index) in hotspotData.images"
+            :key="index"
+            v-lazy="item"
+            class="swiper-slide"
+            alt=""
+            draggable="false"
+          >
+        </div>
+        <div class="swiper-pagination">
+          <!-- <span
+            class="cur"
+          >
+            {{ currentSlideIdx + 1 }}
+          </span>
+          /
+          <span>
+            {{ hotspotData.Images ? hotspotData.images.length : '' }}
+          </span> -->
+        </div>
+        <div class="swiper-button-prev" />
+        <div class="swiper-button-next" />
+      </div>
+    </div>
+
+    <p
+      class="desc"
+      v-html="descForShow"
+    />
+  </div>
+</template>
+
+<script>
+import Swiper from 'swiper/swiper-bundle.esm.js'
+import 'swiper/swiper-bundle.css'
+
+// import browser from "@/utils/browser";
+
+export default {
+  data() {
+    return {
+      hotspotData: {}, // 热点数据
+      audioUrl: "", //背景音频url
+      isShowImages: false,
+      isShowVideos: false,
+      currentSlideIdx: 0,
+    }
+  },
+  computed: {
+    descForShow() {
+      if (this.isShowImages) {
+        return this.hotspotData.imagesDesc[this.currentSlideIdx] || this.hotspotData.content
+      } else if (this.isShowVideos) {
+        return this.hotspotData.videosDesc[this.currentSlideIdx] || this.hotspotData.content
+      } else {
+        return ''
+      }
+    },
+  },
+  async mounted() {
+    await this.getData()
+    this.$nextTick(() => {
+      const that = this
+      new Swiper('.swiper-root', {
+        pagination: {
+          el: '.swiper-pagination',
+        },
+        navigation: {
+          nextEl: '.swiper-button-next',
+          prevEl: '.swiper-button-prev',
+        },
+
+        on: {
+          // 自动播放
+          afterInit: function (e) {
+            if (that.isShowVideos) {
+              that.$nextTick(() => {
+                that.$refs.video[0].play()
+              })
+            }
+            // if (that.typesForShow[vNew].key === 'audio') {
+            //   that.$nextTick(() => {
+            //     that.$refs['audio-comp'][0].play()
+            //   })
+            // }
+          },
+          slideChange: function(e) {
+            that.currentSlideIdx = e.activeIndex
+
+            // 自动播放
+            if (that.isShowVideos) {
+              for (let index = 0; index < that.$refs.video.length; index++) {
+                if (index !== that.currentSlideIdx) {
+                  that.$refs.video[index].pause()
+                } else {
+                  that.$refs.video[index].play()
+                }
+              }
+            }
+            // if (that.typesForShow[vNew].key === 'audio') {
+            //   for (let index = 0; index < that.$refs['audio-comp'].length; index++) {
+            //     if (index !== that.currentSlideIdx) {
+            //       that.$refs['audio-comp'][index].pause()
+            //     } else {
+            //       that.$refs['audio-comp'][index].play()
+            //     }
+            //   }
+            // }
+          }
+        }
+      })
+    })
+  },
+  methods: {
+    async getData() {
+      let url = `https://super.4dage.com/data/${this.$route.query.id}/hot/js/data.js?time=${Math.random()}`
+      let result = (await this.$http.get(url)).data
+      this.hotspotData = result[this.$route.query.m]
+      if (!this.hotspotData) {
+        return alert("热点解析错误")
+      }
+      console.log('热点数据:', this.hotspotData)
+
+      this.audioUrl = this.hotspotData["backgroundMusic"]
+
+      if (this.hotspotData.images && this.hotspotData.images.length) {
+        this.isShowImages = true
+      } else if (this.hotspotData.video && this.hotspotData.video.length) {
+        this.isShowVideos = true
+      }
+    },
+    onClickClose() {
+      window.parent.document.getElementById('closepop').click()
+    },
+  }
+}
+</script>
+
+<style lang="less" scoped>
+.hotspot-home {
+  position: absolute;
+  left: 50%;
+  top: 50%;
+  transform: translate(-50%, -50%);
+  width: 100%;
+  height: 100%;
+  max-width: 1329px;
+  max-height: 848px;
+  background: #E5DFCD;
+  border-top: solid 8px #A10E0C;
+  border-bottom: solid 8px #A10E0C;
+  padding: 28px 100px;
+  > button.close {
+    position: absolute;
+    top: 29px;
+    right: 37px;
+    width: 28px;
+    height: 28px;
+    > img {
+      width: 100%;
+      height: 100%;
+    }
+  }
+  > h1 {
+    text-align: center;
+    font-size: 32px;
+    font-family: Source Han Sans CN-Regular, Source Han Sans CN;
+    font-weight: 400;
+    color: #A10E0C;
+    overflow: hidden;
+    white-space: pre;
+    text-overflow: ellipsis;
+    margin-bottom: 28px;
+  }
+  .swiper-wrapper-mine {
+    height: calc(100% - 32px - 28px - 22px - 72px);
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    position: relative;
+    margin-bottom: 22px;
+    .swiper-root {
+      overflow: hidden;
+      height: 100%;
+      width: 100%;
+      .swiper-wrapper {
+      }
+      .swiper-pagination {
+        position: absolute;
+        top: 100%;
+        left: 50%;
+        transform: translateX(-50%);
+        font-size: 1.33rem;
+        font-family: Inter-Regular, Inter;
+        color: #666;
+        .cur {
+          color: #930909;
+        }
+      }
+      .swiper-button-prev {
+        left: calc(-1.67rem - 1.83rem);
+        width: 1.83rem;
+        height: 3.58rem;
+        background-image: url(../assets/images/arrow-left.png);
+        background-size: contain;
+        &::after {
+          content: '';
+        }
+      }
+      .swiper-button-next {
+        right: calc(-1.67rem - 1.83rem);
+        width: 1.83rem;
+        height: 3.58rem;
+        background-image: url(../assets/images/arrow-right.png);
+        background-size: contain;
+        &::after {
+          content: '';
+        }
+      }
+    }
+  }
+  .swiper-wrapper-mine.video-wrap {
+    .swiper-root {
+      .swiper-wrapper {
+        .swiper-slide {
+          > video {
+            width: 100%;
+            height: 100%;
+            background: #000;
+          }
+        }
+      }
+    }
+  }
+  // .swiper-wrapper-mine.model-wrap {
+  //   .swiper-root {
+  //     .swiper-wrapper {
+  //     }
+  //   }
+  // }
+  // .swiper-wrapper-mine.audio-wrap {
+  //   width: calc(100% - 1.67rem * 2 - 1.83rem * 2 - 1.67rem * 2);
+  //   height: 30rem;
+  //   position: absolute;
+  //   left: 50%;
+  //   top: 50%;
+  //   transform: translate(-50%, -70%);
+  //   .swiper-root {
+  //     width: 100%;
+  //     .swiper-wrapper {
+  //     }
+  //   }
+  // }
+  .swiper-wrapper-mine.image-wrap {
+    .swiper-root {
+      .swiper-wrapper {
+        > img {
+          width: 100%;
+          height: 100%;
+          object-fit: contain;
+        }
+      }
+    }
+  }
+
+  > p.desc {
+    font-size: 16px;
+    color: #494140;
+    line-height: 19px;
+    height: 72px;
+    overflow: auto;
+    padding-right: 6px;
+  }
+}
+
+/deep/.swiper-pagination-bullet-active {
+  background: #a10e0c;
+}
+</style>