123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593 |
- <template>
- <div class="home" @click="autoplay" @touchstart="autoplay">
- <audio
- v-if="audio"
- class="audio"
- id="audio1"
- :src="audio"
- preload
- autoplay
- ref="musicBg"
- ></audio>
- <div class="content" v-if="fixIcon.length > 0">
- <img
- class="close"
- @click="colseParent"
- :src="require('@/assets/images/close@2x.png')"
- alt=""
- />
- <img class="bg" :src="require('@/assets/images/bg.png')" alt="" />
- <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/icon/${item.img}${
- item.id === active ? '2' : '1'
- }.png`)
- "
- alt=""
- />
- <span>{{ item.name }}</span>
- </li>
- </ul>
- <div class="title" v-html="data.title"></div>
- <div
- @click="slideto('slidePrev')"
- v-if="data[active].length > 1"
- class="swiper-button-prev"
- ></div>
- <swiper class="warpper" ref="mySwiper" :options="swiperOptions">
- <swiper-slide v-for="(item, i) in data[active]" :key="i">
- <div class="slide">
- <div class="tips" v-if="active === 'video'">
- 如遇视频抖动,请点击“新窗口打开”观看。<span class="btn" @click="openVideo(item.url)">新窗口打开</span>
- </div>
- <img
- style="cursor: pointer"
- v-viewer
- v-if="active === 'images'"
- :src="fixUrl(item)"
- alt=""
- />
- <video
- v-else-if="active === 'video'"
- controls
- autoplay
- :id="'video'+ (i + 1)"
- >
- <source :src="fixUrl(item.url)" type="video/mp4" />
- </video>
- <iframe v-else :src="fixUrl(item)" frameborder="0"></iframe>
- </div>
- </swiper-slide>
- <div
- class="swiper-pagination"
- v-if="data[active].length > 1"
- slot="pagination"
- ></div>
- </swiper>
- <div
- @click="slideto('slideNext')"
- v-if="data[active].length > 1"
- class="swiper-button-next"
- ></div>
- <p
- class="desc"
- ref="desc"
- :class="{ 'desc-duo': data.content && data.content.length > 60 }"
- v-html="data.content"
- ></p>
- </div>
- <div class="content" v-if="fixIcon.length <= 0 && hadLoad">
- <img
- class="close"
- @click="colseParent"
- :src="require('@/assets/images/close@2x.png')"
- alt=""
- />
- <img class="bg" :src="require('@/assets/images/bg.png')" alt="" />
- <div class="norecord">该热点无数据</div>
- </div>
- <div class="intro" :class="{ ismtop: fixIcon.length <= 0 }"></div>
- </div>
- </template>
- <script>
- import { Swiper, SwiperSlide } from "vue-awesome-swiper";
- import "swiper/css/swiper.css";
- import browser from "@/utils/browser";
- let iconArr = [
- { name: "图片", id: "images", img: "ICON_xiangpian", display: false },
- { name: "视频", id: "video", img: "ICON_bofang", display: false },
- { name: "网页", id: "iframe", img: "ICON_wangluo", display: false },
- { name: "模型", id: "model", img: "ICON_moxing", display: false },
- ];
- browser.mobile &&
- iconArr.push({ name: "介绍", id: "title", img: "txt-icon", display: false });
- export default {
- name: "Home",
- data() {
- return {
- // http://8.135.106.227:8009
- server: "http://192.168.1.101",
- loadAuto: false,
- hadLoad: false,
- audio: "",
- m: this.$route.query.m,
- id: this.$route.query.id,
- isAndriod: browser.android,
- swiperOptions: browser.mobile
- ? {
- pagination: {
- el: ".swiper-pagination",
- clickable: true,
- },
- }
- : {
- 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: {
- Swiper,
- SwiperSlide,
- },
- methods: {
- autoplay() {
- if (this.loadAuto) {
- return;
- }
- try {
- this.$refs.musicBg.play();
- this.loadAuto = true;
- } catch (error) {
- error;
- }
- },
- openVideo(url){
- if (this.active == "video") {
- for (let i = 0; i < this.data[this.active].length; i++) {
- console.log(document.querySelector("#video" + (i + 1)));
- document.querySelector("#video" + (i + 1)).pause()
- }
- }
- window.open(this.fixUrl(url),'_blank')
- },
- async getData() {
- // http://super.4dage.com
- let url = `${this.server}/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;
- }
- });
- this.hadLoad = true;
- },
- colseParent() {
- window.parent.document.getElementById("closepop").click();
- },
- fixUrl(item) {
- return this.server + 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;
- }
- .swiper-button-prev,
- .swiper-button-next {
- background: none !important;
- padding: 10px 30px !important;
- }
- .mb-intro {
- color: #fff;
- padding: 10px;
- > p {
- line-height: 1.5;
- letter-spacing: 1px;
- &:first-of-type {
- font-weight: bold;
- font-size: 20px;
- }
- }
- }
- .home {
- width: 100%;
- height: 100%;
- position: relative;
- .ismtop {
- padding-top: 40px !important;
- }
- .content {
- width: 1200px;
- height: 86%;
- margin: 2% auto;
- position: relative;
- .norecord {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- color: #fff;
- }
- .warpper {
- width: 100%;
- height: calc(100% - 40px);
- margin: 0 auto;
- .slide {
- font-size: 0;
- width: 100%;
- height: calc(100% - 180px);
- position: relative;
- .tips{
- top: 10px;
- left: 100px;
- z-index: 999;
- font-size: 16px;
- color: #fff;
- position: absolute;
- .btn{
- font-size: 16px;
- color: #fcd67b;
- background-color: #a01c26;
- border-radius: 36px;
- display: inline-block;
- cursor: pointer;
- letter-spacing: 2px;
- padding: 10px 20px;
- }
- }
- img,
- video,
- iframe {
- max-height: 100%;
- max-width: calc(100% - 220px);
- border-radius: 14px;
- box-shadow: 0 0 16px rgba(0, 0, 0, 0.6);
- transform: translate(-50%, -50%);
- top: 50%;
- left: 50%;
- position: absolute;
- }
- iframe {
- width: calc(100% - 220px);
- height: 100%;
- }
- video {
- width: 100%;
- }
- }
- }
- .desc {
- color: #fff;
- width: 76%;
- margin: -40px auto 0;
- max-height: 120px;
- overflow-y: auto;
- overflow-x: hidden;
- text-align: center;
- position: relative;
- z-index: 999;
- }
- .desc-duo {
- text-indent: 32px;
- text-align: left;
- }
- .close {
- position: absolute;
- bottom: 50px;
- right: 50px;
- box-shadow: none;
- width: 24px;
- cursor: pointer;
- z-index: 999;
- }
- .bg {
- position: absolute;
- box-shadow: none;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- max-height: unset;
- z-index: -1;
- }
- }
- .iconarr {
- list-style: none;
- display: flex;
- justify-content: flex-end;
- margin-right: 30px;
- position: absolute;
- left: 40px;
- top: 20px;
- z-index: 999;
- 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;
- span {
- margin-left: 10px;
- }
- > img {
- width: 24px;
- }
- }
- .active {
- color: rgba(252, 214, 123, 1);
- border: none;
- }
- }
- .title {
- color: rgba(252, 214, 123, 1);
- width: 100%;
- text-align: center;
- transform: translateX(-50%);
- top: 24px;
- left: 50%;
- font-size: 18px;
- position: absolute;
- }
- .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 {
- }
- iframe {
- }
- }
- }
- }
- }
- }
- @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;
- }
- 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>
- * {
- word-break: break-all;
- }
- .swiper-container {
- width: 100%;
- height: 100%;
- }
- .swiper-pagination-bullet {
- background: #fff;
- }
- .swiper-pagination-bullets {
- bottom: 40px !important;
- }
- .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%;
- }
- }
- ::-webkit-scrollbar-track-piece {
- background-color: #ffffff;
- }
- ::-webkit-scrollbar {
- width: 8px;
- overflow: hidden;
- height: 13px;
- }
- ::-webkit-scrollbar-thumb {
- background-color: #ccc;
- background-clip: padding-box;
- min-height: 10px;
- border-radius: 4px;
- }
- ::-webkit-scrollbar-thumb:hover {
- background-color: #929292;
- }
- </style>
|