tremble 4 år sedan
förälder
incheckning
aa646d0e5e

+ 48 - 4
package-lock.json

@@ -2466,6 +2466,14 @@
       "integrity": "sha1-4eguTz6Zniz9YbFhKA0WoRH4ZCg=",
       "dev": true
     },
+    "axios": {
+      "version": "0.20.0",
+      "resolved": "https://registry.npm.taobao.org/axios/download/axios-0.20.0.tgz?cache=0&sync_timestamp=1597979633356&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Faxios%2Fdownload%2Faxios-0.20.0.tgz",
+      "integrity": "sha1-BXujDwSIRpSZOozQf6OUz/EcUL0=",
+      "requires": {
+        "follow-redirects": "^1.10.0"
+      }
+    },
     "babel-eslint": {
       "version": "10.1.0",
       "resolved": "https://registry.npm.taobao.org/babel-eslint/download/babel-eslint-10.1.0.tgz?cache=0&sync_timestamp=1582679727935&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbabel-eslint%2Fdownload%2Fbabel-eslint-10.1.0.tgz",
@@ -4457,6 +4465,21 @@
         }
       }
     },
+    "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"
+      },
+      "dependencies": {
+        "ssr-window": {
+          "version": "2.0.0",
+          "resolved": "https://registry.npm.taobao.org/ssr-window/download/ssr-window-2.0.0.tgz",
+          "integrity": "sha1-mMMBrvmVIzF/jWlhjwAQeRCW78Q="
+        }
+      }
+    },
     "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",
@@ -5444,8 +5467,7 @@
     "follow-redirects": {
       "version": "1.13.0",
       "resolved": "https://registry.npm.taobao.org/follow-redirects/download/follow-redirects-1.13.0.tgz?cache=0&sync_timestamp=1597057976909&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffollow-redirects%2Fdownload%2Ffollow-redirects-1.13.0.tgz",
-      "integrity": "sha1-tC6Nk6Kn7qXtiGM2dtZZe8jjhNs=",
-      "dev": true
+      "integrity": "sha1-tC6Nk6Kn7qXtiGM2dtZZe8jjhNs="
     },
     "for-in": {
       "version": "1.0.2",
@@ -7659,8 +7681,7 @@
     "object-assign": {
       "version": "4.1.1",
       "resolved": "http://registry.npm.taobao.org/object-assign/download/object-assign-4.1.1.tgz",
-      "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
-      "dev": true
+      "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
     },
     "object-copy": {
       "version": "0.1.0",
@@ -10065,6 +10086,11 @@
         "tweetnacl": "~0.14.0"
       }
     },
+    "ssr-window": {
+      "version": "1.0.1",
+      "resolved": "https://registry.npm.taobao.org/ssr-window/download/ssr-window-1.0.1.tgz",
+      "integrity": "sha1-MHUqakZm53Z/C35qpvwv29DZs2k="
+    },
     "ssri": {
       "version": "6.0.1",
       "resolved": "https://registry.npm.taobao.org/ssri/download/ssri-6.0.1.tgz",
@@ -10341,6 +10367,15 @@
         "util.promisify": "~1.0.0"
       }
     },
+    "swiper": {
+      "version": "4.5.1",
+      "resolved": "https://registry.npm.taobao.org/swiper/download/swiper-4.5.1.tgz",
+      "integrity": "sha1-7UOZjngM60eGEAecjSP9Ql7KY28=",
+      "requires": {
+        "dom7": "^2.1.3",
+        "ssr-window": "^1.0.1"
+      }
+    },
     "table": {
       "version": "5.4.6",
       "resolved": "https://registry.npm.taobao.org/table/download/table-5.4.6.tgz",
@@ -11023,6 +11058,15 @@
       "resolved": "https://registry.npm.taobao.org/vue/download/vue-2.6.12.tgz?cache=0&sync_timestamp=1600443052956&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-2.6.12.tgz",
       "integrity": "sha1-9evU+mvShpQD4pqJau1JBEVskSM="
     },
+    "vue-awesome-swiper": {
+      "version": "3.1.3",
+      "resolved": "https://registry.npm.taobao.org/vue-awesome-swiper/download/vue-awesome-swiper-3.1.3.tgz",
+      "integrity": "sha1-BVALUB/7P+yb9+uZhbz0roNg7Z4=",
+      "requires": {
+        "object-assign": "^4.1.1",
+        "swiper": "^4.0.7"
+      }
+    },
     "vue-eslint-parser": {
       "version": "7.1.1",
       "resolved": "https://registry.npm.taobao.org/vue-eslint-parser/download/vue-eslint-parser-7.1.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-eslint-parser%2Fdownload%2Fvue-eslint-parser-7.1.1.tgz",

+ 4 - 0
package.json

@@ -8,8 +8,12 @@
     "lint": "vue-cli-service lint"
   },
   "dependencies": {
+    "axios": "^0.20.0",
     "core-js": "^3.6.5",
+    "swiper": "^5.4.5",
+    "v-viewer": "^1.5.1",
     "vue": "^2.6.11",
+    "vue-awesome-swiper": "^4.1.1",
     "vue-router": "^3.2.0"
   },
   "devDependencies": {

BIN
public/favicon.ico


+ 0 - 1
public/index.html

@@ -4,7 +4,6 @@
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <title><%= htmlWebpackPlugin.options.title %></title>
   </head>
   <body>

+ 11 - 21
src/App.vue

@@ -1,32 +1,22 @@
 <template>
   <div id="app">
-    <div id="nav">
-      <router-link to="/">Home</router-link> |
-      <router-link to="/about">About</router-link>
-    </div>
     <router-view/>
   </div>
 </template>
 
 <style lang="less">
+html,body{
+  width: 100%;
+  height: 100%;
+  overflow: hidden;
+}
+*{
+  margin: 0;
+  padding: 0;
+}
 #app {
-  font-family: Avenir, Helvetica, Arial, sans-serif;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  text-align: center;
-  color: #2c3e50;
+  width: 100%;
+  height: 100%;
 }
 
-#nav {
-  padding: 30px;
-
-  a {
-    font-weight: bold;
-    color: #2c3e50;
-
-    &.router-link-exact-active {
-      color: #42b983;
-    }
-  }
-}
 </style>

BIN
src/assets/images/iframe-icon.png


BIN
src/assets/images/img-icon.png


BIN
src/assets/images/model-icon.png


BIN
src/assets/images/txt-icon.png


BIN
src/assets/images/video-icon.png


+ 7 - 0
src/main.js

@@ -1,8 +1,15 @@
 import Vue from 'vue'
 import App from './App.vue'
 import router from './router'
+import axios from 'axios'
+import 'viewerjs/dist/viewer.css'
+import Viewer from 'v-viewer'
+ 
 
 Vue.config.productionTip = false
+Vue.prototype.$http = axios
+
+Vue.use(Viewer)
 
 new Vue({
   router,

+ 29 - 0
src/utils/browser.js

@@ -0,0 +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')
+    }
+  }
+  
+  export default versions()

+ 0 - 0
src/utils/http.js


+ 462 - 8
src/views/Home.vue

@@ -1,18 +1,472 @@
 <template>
-  <div class="home">
-    <img alt="Vue logo" src="../assets/logo.png">
-    <HelloWorld msg="Welcome to Your Vue.js App"/>
+  <div class="home" @click="autoplay" @touchstart="autoplay">
+    <audio
+      v-if="audio"
+      class="audio"
+      id="audio1"
+      :src="audio"
+      preload
+      autoplay
+      loop
+      ref="musicBg"
+    ></audio>
+    <div
+      class="content"
+      v-if="fixIcon.length > 0"
+      :style="{ height: isMobile ? '100%' : '80%' }"
+    >
+      <div
+        v-if="!isMobile"
+        @click="slideto('slidePrev')"
+        class="swiper-button-prev"
+      ></div>
+      <div class="mb-intro" v-if="active === 'title' && isMobile">
+        <p v-html="data.title"></p>
+        <p v-html="data.content"></p>
+      </div>
+      <swiper v-else class="warpper" ref="mySwiper" :options="swiperOptions">
+        <swiper-slide v-for="(item, i) in data[active]" :key="i">
+          <div class="slide">
+            <img
+              style="cursor: pointer"
+              v-viewer
+              v-if="active === 'images'"
+              :src="fixUrl(item)"
+              alt=""
+            />
+            <video
+              v-else-if="active === 'video'"
+              :src="fixUrl(item.url)"
+              controls
+              autoplay
+            ></video>
+            <iframe
+              @click="colseParent(item)"
+              v-else
+              :src="fixUrl(item)"
+              frameborder="0"
+            ></iframe>
+          </div>
+        </swiper-slide>
+        <div class="swiper-pagination" slot="pagination"></div>
+      </swiper>
+      <div
+        v-if="!isMobile"
+        @click="slideto('slideNext')"
+        class="swiper-button-next"
+      ></div>
+    </div>
+    <ul class="iconarr" v-if="fixIcon.length > 1">
+      <li
+        :class="{ active: item.id === active }"
+        @click="active = item.id"
+        v-for="(item, i) in fixIcon"
+        :key="i"
+      >
+        <img :src="require(`@/assets/images/${item.img}.png`)" alt="" />
+        <span>{{ item.name }}</span>
+      </li>
+    </ul>
+    <div
+      class="intro"
+      :class="{ ismtop: fixIcon.length <= 0 }"
+      v-if="!isMobile || (isMobile && fixIcon.length <= 0)"
+    >
+      <h3 v-html="data.title"></h3>
+      <p v-html="data.content"></p>
+    </div>
   </div>
 </template>
 
 <script>
-// @ is an alias to /src
-import HelloWorld from '@/components/HelloWorld.vue'
+import { Swiper, SwiperSlide } from "vue-awesome-swiper";
+import "swiper/css/swiper.css";
+import browser from "@/utils/browser";
+
+let iconArr = [
+  { name: "图片", id: "images", img: "img-icon", display: false },
+  { 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 });
 
 export default {
-  name: 'Home',
+  name: "Home",
+  data() {
+    return {
+      loadAuto: false,
+      audio: "",
+      m: this.$route.query.m,
+      id: this.$route.query.id,
+      isMobile: browser.mobile,
+      isAndriod: browser.android,
+      swiperOptions: browser.mobile
+        ? {
+            pagination: {
+              el: ".swiper-pagination",
+              clickable: true,
+            },
+          }
+        : {
+            slidesPerView: 3,
+            spaceBetween: 0,
+            centeredSlides: true,
+            pagination: {
+              el: ".swiper-pagination",
+              clickable: true,
+            },
+          },
+      data: {},
+      iconArr,
+      active: "",
+    };
+  },
+  watch: {
+    active(newVal) {
+      if (!newVal) {
+        return;
+      }
+      if (!this.$refs.musicBg) {
+        return;
+      }
+      setTimeout(() => {
+        if (newVal == "video") {
+          if (!this.$refs.musicBg.paused) {
+            this.$refs.musicBg.pause();
+          }
+        } else {
+          if (this.$refs.musicBg.paused) {
+            this.$refs.musicBg.play(); // 暂停
+          }
+        }
+      }, 500);
+    },
+  },
+  computed: {
+    swiper() {
+      return this.$refs.mySwiper.$swiper;
+    },
+    fixIcon() {
+      let arr = this.iconArr.filter((item) => !!item.display);
+      return arr;
+    },
+  },
   components: {
-    HelloWorld
+    Swiper,
+    SwiperSlide,
+  },
+  methods: {
+    autoplay() {
+      if (this.loadAuto) {
+        return;
+      }
+      try {
+        this.$refs.musicBg.play();
+        this.loadAuto = true;
+      } catch (error) {
+        error;
+      }
+    },
+    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];
+      if (!this.data) {
+        return alert("热点解析错误");
+      }
+
+      this.audio = this.data["backgroundMusic"];
+
+      if (!this.data.content && this.isMobile) {
+        this.iconArr.pop();
+      }
+      this.iconArr.forEach((item) => {
+        if (this.data[item.id]) {
+          this.active = !this.active ? item.id : this.active;
+          item.display = true;
+        }
+      });
+    },
+
+    colseParent(item) {
+      if (this.isMobile) {
+        if (
+          item.indexOf("mp.weixin.qq.com/mp/") > -1 &&
+          this.active === "iframe"
+        ) {
+          window.parent.document.getElementById("closepop").click();
+        }
+      }
+    },
+    fixUrl(item) {
+      let condition =
+        item.indexOf("http://") > -1 || item.indexOf("https://") > -1;
+      if (this.isMobile) {
+        if (
+          item.indexOf("mp.weixin.qq.com/mp/") > -1 &&
+          this.active === "iframe"
+        ) {
+          return `https://www.4dmodel.com/SuperTwo/hot_online1/linktoWC.html?url=${encodeURIComponent(
+            item
+          )}`;
+        }
+      }
+      if (!condition) {
+        return "https://" + item;
+      }
+      return item;
+    },
+    slideto(action) {
+      this.swiper[action]();
+    },
+  },
+  mounted() {
+    this.getData();
+    document.addEventListener(
+      "WeixinJSBridgeReady",
+      () => {
+        this.autoplay();
+      },
+      false
+    );
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.audio {
+  position: fixed;
+  top: -100px;
+  left: -100px;
+  opacity: 0;
+}
+
+.mb-intro {
+  color: #fff;
+  padding: 10px;
+  > p {
+    line-height: 1.5;
+    letter-spacing: 1px;
+    &:first-of-type {
+      font-weight: bold;
+      font-size: 20px;
+    }
   }
 }
-</script>
+.home {
+  width: 100%;
+  height: 100%;
+  position: relative;
+  .ismtop {
+    padding-top: 40px !important;
+  }
+  .content {
+    width: 100%;
+    height: 80%;
+    .warpper {
+      width: 100%;
+      height: 100%;
+      .slide {
+        font-size: 0;
+        img,
+        video,
+        iframe {
+          max-height: 570px;
+          border-radius: 14px;
+          box-shadow: 0 0 16px rgba(0, 0, 0, 0.6);
+        }
+       
+        iframe {
+          height: 570px;
+          width: 1000px;
+        }
+      }
+    }
+  }
+
+  .iconarr {
+    list-style: none;
+    display: flex;
+    justify-content: flex-end;
+    margin-right: 30px;
+    li {
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      color: #fff;
+      list-style: none;
+      font-size: 14px;
+      width: 90px;
+      height: 32px;
+      line-height: 32px;
+      cursor: pointer;
+      border-radius: 10px;
+      border: solid 1px #fff;
+      margin-right: 10px;
+      span {
+        margin-left: 4px;
+      }
+    }
+    .active {
+      background: #19bbed;
+      border: none;
+    }
+  }
+  .intro {
+    max-height: 20vh;
+    overflow: auto;
+    width: 70%;
+    color: #fff;
+    margin: 0 auto;
+    > h3 {
+      font-size: 20px;
+      font-weight: 600;
+    }
+    > p {
+      line-height: 1.5;
+      margin-top: 10px;
+      font-size: 16px;
+      text-indent: 32px;
+    }
+  }
+}
+
+@media screen and (max-width: 1400px) {
+  .home {
+    .content {
+      .warpper {
+        .slide {
+          img,
+          video,
+          iframe {
+            max-height: 500px;
+          }
+          img{
+            max-height: 80vh;
+            width: auto;
+          }
+          iframe {
+            height: 500px;
+          }
+        }
+      }
+    }
+  }
+}
+
+@media screen and (max-width: 1000px) {
+  .home {
+    background: rgba(0, 0, 0, 0.8);
+    .content {
+      .warpper {
+        .slide {
+          width: 100%;
+          img,
+          video,
+          iframe {
+            max-height: none;
+            width: 100%;
+            border-radius: 0;
+          }
+          img{
+            max-height: 80vh;
+            width: auto;
+          }
+          iframe {
+            width: 100%;
+            height: 100vh;
+          }
+        }
+      }
+    }
+    .iconarr {
+      list-style: none;
+      margin-right: 0px;
+      position: fixed;
+      bottom: 10px;
+      right: 0px;
+      z-index: 10000;
+      li {
+        width: 70px;
+      }
+    }
+  }
+}
+
+@media only screen and (max-width: 906px) and (orientation: landscape) {
+  .home {
+    .content {
+      .warpper {
+        .slide {
+          width: 100%;
+          img,
+          video,
+          iframe {
+            max-width: 70%;
+            max-height: 80vh;
+          }
+          iframe {
+            width: 100%;
+            max-width: unset;
+            height: 100vh;
+          }
+        }
+      }
+    }
+  }
+}
+</style>
+
+<style>
+.swiper-container {
+  width: 100%;
+  height: 100%;
+}
+
+.swiper-pagination-bullet {
+  background: #fff;
+}
+.swiper-slide {
+  text-align: center;
+  font-size: 18px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  transition: 300ms;
+  transform: scale(0.8);
+  position: relative;
+  opacity: 0.5;
+}
+
+.swiper-slide-active,
+.swiper-slide-duplicate-active {
+  transform: scale(1);
+  opacity: 1;
+  z-index: 999;
+}
+
+.swiper-button-prev,
+.swiper-button-next {
+  background: rgba(0, 0, 0, 0.4);
+  padding: 10px 20px;
+  color: #fff !important;
+}
+.swiper-button-prev {
+  left: 0;
+}
+.swiper-button-next {
+  right: 0;
+}
+
+@media screen and (max-width: 500px) {
+  .swiper-slide {
+    width: 100%;
+  }
+}
+</style>

+ 3 - 0
vue.config.js

@@ -0,0 +1,3 @@
+module.exports = {
+  publicPath: "./"
+};