Explorar o código

feat: 热点只播放音频

chenlei hai 5 meses
pai
achega
b66b7cc705

BIN=BIN
public/fonts/SOURCEHANSERIFCN-BOLD.OTF


BIN=BIN
public/fonts/SOURCEHANSERIFCN-REGULAR.OTF


BIN=BIN
public/images/hljng/point.png


BIN=BIN
public/images/hljng/point2.png


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 2103 - 0
public/js/Hot.hljng.js


BIN=BIN
src/hotspot/assets/images/hljng/bg.png


BIN=BIN
src/hotspot/assets/images/hljng/close.png


BIN=BIN
src/hotspot/assets/images/hljng/mobile/bg.png


BIN=BIN
src/hotspot/assets/images/hljng/mobile/close.png


+ 178 - 0
src/hotspot/views/hotspot/index.hljng.scss

@@ -0,0 +1,178 @@
+.hotspot-page {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding: 30px;
+  overflow: hidden;
+  background: url('@hotspot/assets/images/hljng/bg.png') no-repeat center / cover;
+  z-index: var(--z-index-popper);
+
+  h3 {
+    margin-bottom: 30px;
+    font-size: 24px;
+    font-weight: bold;
+    text-align: center;
+    color: #981b23;
+  }
+  .audioIcon {
+    position: absolute;
+    right: 20px;
+    bottom: 5px;
+
+    img {
+      width: 57px;
+      height: 57px;
+      cursor: pointer;
+    }
+  }
+  &-info {
+    width: 100%;
+    color: #644e36;
+    font-size: 18px;
+    text-indent: 2em;
+  }
+
+  &-container {
+    position: relative;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    width: 100%;
+    max-height: calc(100% - 150px - 66px);
+    box-sizing: border-box;
+  }
+
+  &-swiper {
+    &__left,
+    &__right {
+      position: absolute;
+      top: 50%;
+      width: 25px;
+      height: 24px;
+      cursor: pointer;
+      transform: translateY(-50%);
+      z-index: 1;
+    }
+    &__left {
+      left: -70px;
+      background: url('@hotspot/assets/images/icon-previous@2x-min.png') no-repeat center / contain;
+    }
+    &__right {
+      right: -70px;
+      background: url('@hotspot/assets/images/icon-next@2x-min.png') no-repeat center / contain;
+    }
+  }
+  &-model {
+    width: 100%;
+    height: 100%;
+
+    iframe {
+      width: 100%;
+      height: 100%;
+    }
+  }
+  .swiper-slide {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+  }
+  &-video {
+    height: 100%;
+    max-height: 100%;
+  }
+  &-img {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    height: inherit;
+
+    &-swiper {
+      flex: 1;
+      width: 100%;
+      height: 0;
+    }
+  }
+
+  &-nav {
+    position: absolute;
+    left: 50%;
+    bottom: 5px;
+    display: flex;
+    align-items: center;
+    gap: 10px;
+    transform: translateX(-50%);
+
+    &__item {
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      gap: 9px;
+      width: 57px;
+      height: 57px;
+      box-sizing: border-box;
+      cursor: pointer;
+
+      &.active {
+      }
+      img {
+        width: 100%;
+        height: 100%;
+      }
+    }
+  }
+}
+
+@media only screen and (max-width: 600px) {
+  .hotspot-page {
+    padding: 25px 15px;
+
+    h3 {
+      margin-bottom: 19px;
+      font-size: 18px;
+    }
+    &-container {
+      max-width: 100%;
+      width: 100%;
+      background: none;
+    }
+    &-swiper {
+      &__left,
+      &__right {
+        top: unset;
+        bottom: 12px;
+        transform: none;
+      }
+      &__left {
+        left: 14px;
+      }
+      &__right {
+        right: 14px;
+      }
+    }
+    &-nav {
+      bottom: 0;
+
+      &__item {
+        width: 48px;
+        height: 48px;
+      }
+    }
+    &-info {
+      font-size: 15px;
+    }
+    .audioIcon {
+      right: 35px;
+      bottom: 1px;
+
+      img {
+        width: 48px;
+        height: 48px;
+      }
+    }
+  }
+}

+ 279 - 0
src/hotspot/views/hotspot/index.hljng.vue

@@ -0,0 +1,279 @@
+<template>
+  <div class="hotspot-page">
+    <h3>{{ myTitle }}</h3>
+
+    <div class="hotspot-page-container">
+      <!-- 音频播放器 -->
+      <audio
+        id="myAudio"
+        v-if="audio"
+        ref="volumeRef"
+        v-show="isOneAduio"
+        :src="audio"
+        controls
+      ></audio>
+
+      <!-- 模型页面 -->
+      <Swiper
+        v-if="myType === 'model'"
+        class="hotspot-page-swiper hotspot-page-model"
+        @swiper="initSwiper"
+        @slideChange="handleChange"
+      >
+        <SwiperSlide v-for="(item, index) in curList" :key="item.url">
+          <iframe v-if="index === myInd" :src="item" frameborder="0" />
+        </SwiperSlide>
+      </Swiper>
+
+      <!-- 视频页面 -->
+      <div v-if="myType === 'video'" class="hotspot-page-swiper hotspot-page-video">
+        <template v-for="(item, index) in curList" :key="item.url">
+          <video
+            v-if="index === myInd"
+            id="videoID"
+            class="hotspot-page-video"
+            controls
+            :src="item.url"
+            autoplay
+          />
+        </template>
+      </div>
+
+      <!-- 图片页面 -->
+      <Swiper
+        v-if="myType === 'img'"
+        class="hotspot-page-swiper hotspot-page-img-swiper"
+        @swiper="initSwiper"
+        @slideChange="handleChange"
+      >
+        <SwiperSlide v-for="(item, idx) in curList" :key="item">
+          <div class="hotspot-page-img">
+            <el-image
+              :src="item"
+              fit="contain"
+              style="width: 100%; height: 100%"
+              preview-teleported
+              :preview-src-list="curList"
+              :initial-index="idx"
+            />
+          </div>
+        </SwiperSlide>
+      </Swiper>
+
+      <template v-if="curList.length > 1">
+        <div class="hotspot-page-swiper__left" @click="handlePre" />
+        <div class="hotspot-page-swiper__right" @click="handleNext" />
+      </template>
+
+      <!-- 底部的tab -->
+      <div v-if="flooTab.length > 1" class="hotspot-page-nav">
+        <div
+          v-for="item in flooTab"
+          :key="item.id"
+          :class="[
+            'hotspot-page-nav__item',
+            {
+              active: myType === item.type,
+            },
+          ]"
+          @click="handleTab(item)"
+        >
+          <img :class="`${item.type}-icon`" :src="myType === item.type ? item.acIcon : item.icon" />
+          <!-- {{ item.name }}
+          {{ item.type === 'img' ? `${myInd + 1}/${data.img.length}` : '' }} -->
+        </div>
+      </div>
+
+      <!-- 音频图标 -->
+      <div
+        v-if="audio && !isOneAduio"
+        class="audioIcon"
+        :title="audioSta ? '关闭音频' : '打开音频'"
+        @click="audioSta = !audioSta"
+      >
+        <img :src="audioSta ? VolumeOff : VolumeOn" alt="" />
+      </div>
+    </div>
+
+    <el-scrollbar height="100%" style="margin-top: 20px; min-height: 150px">
+      <div class="hotspot-page-info">
+        <p>{{ myTxt }}</p>
+      </div>
+    </el-scrollbar>
+  </div>
+</template>
+
+<script>
+  import { Swiper, SwiperSlide } from 'swiper/vue';
+  import 'swiper/css';
+  import { parseUrlParams } from '@/utils';
+
+  import ModelIcon from '@hotspot/assets/images/icon-model@2x.png';
+  import AcModelIcon from '@hotspot/assets/images/icon-model-1@2x.png';
+  import ImageIcon from '@hotspot/assets/images/icon-image@2x.png';
+  import AcImageIcon from '@hotspot/assets/images/icon-image-1@2x.png';
+  import VideoIcon from '@hotspot/assets/images/icon-video@2x.png';
+  import AcVideoIcon from '@hotspot/assets/images/icon-video-1@2x.png';
+  import VolumeOn from '@hotspot/assets/images/Volume-on.png';
+  import VolumeOff from '@hotspot/assets/images/Volume-off.png';
+
+  const urlParams = parseUrlParams(window.location.href);
+
+  export default {
+    name: 'hotspot',
+    components: {
+      Swiper,
+      SwiperSlide,
+    },
+    data() {
+      return {
+        VolumeOn,
+        VolumeOff,
+        m: urlParams.m,
+        id: urlParams.id,
+        // 音频地址
+        audio: '',
+        // 如果只有单独的音频
+        isOneAduio: false,
+        // 音频状态
+        audioSta: false,
+
+        data: {
+          // 模型数组
+          model: [],
+          // 视频数组
+          video: [],
+          // 图片数组
+          img: [],
+        },
+        // 当前 type
+        myType: '',
+
+        // 当前索引
+        myInd: 0,
+
+        // 底部的tab
+        flooTab: [],
+
+        // 标题
+        myTitle: '',
+        // 内容
+        myTxt: '',
+        // 视频内容
+        videoTxt: [],
+        imgTxt: [],
+
+        // 只有标题和文字(没有视频,没有模型,没有图片)
+        oneTxt: false,
+      };
+    },
+    computed: {
+      curList() {
+        return this.data[this.myType] || [];
+      },
+    },
+    watch: {
+      audioSta(val) {
+        if (val) {
+          this.$refs.volumeRef.play();
+          this.$refs.volumeRef.onended = () => {
+            // console.log("----音频播放完毕");
+            this.audioSta = false;
+          };
+        } else this.$refs.volumeRef.pause();
+      },
+    },
+    mounted() {
+      this.getData();
+    },
+    methods: {
+      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 fetch(url).then((response) => response.json());
+        const resData = result[this.m];
+        console.log('----', resData);
+        if (resData) {
+          this.audio = resData.backgroundMusic;
+          // 只有单独的音频上传
+          if (resData.backgroundMusic && !resData.model && !resData.video && !resData.images) {
+            this.isOneAduio = true;
+          }
+          // 底部的tab
+          const arr = [];
+          const obj = {};
+          if (resData.model) {
+            obj.model = resData.model;
+            arr.push({ id: 1, type: 'model', name: '模型', icon: ModelIcon, acIcon: AcModelIcon });
+          }
+          if (resData.video) {
+            obj.video = resData.video;
+            arr.push({ id: 2, type: 'video', name: '视频', icon: VideoIcon, acIcon: AcVideoIcon });
+          } else {
+            this.$nextTick(() => {
+              if (
+                !window.navigator.userAgent.match(
+                  /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
+                )
+              ) {
+                this.audioSta = true;
+                this.$refs.volumeRef.play();
+              }
+            });
+          }
+          if (resData.images) {
+            obj.img = resData.images;
+            arr.push({ id: 3, type: 'img', name: '图片', icon: ImageIcon, acIcon: AcImageIcon });
+          }
+          this.flooTab = arr;
+          this.data = obj;
+
+          // 当前type的值 应该为
+          if (resData.model) this.myType = 'model';
+          else if (resData.video) this.myType = 'video';
+          else if (resData.images) this.myType = 'img';
+
+          this.myTitle = resData.title || '';
+          this.myTxt = resData.content || '';
+          this.videoTxt = resData.videosDesc || [];
+          this.imgTxt = resData.imagesDesc || [];
+
+          // 只有 标题和 文字介绍(没有视频,没有模型,没有图片)
+          if (!obj.model && !obj.video && !obj.img && !resData.backgroundMusic) {
+            this.oneTxt = true;
+          }
+        }
+      },
+
+      handleTab(item) {
+        this.myInd = 0;
+        this.myType = item.type;
+      },
+
+      initSwiper(swiper) {
+        this.swiper = swiper;
+      },
+      handleChange({ activeIndex }) {
+        this.myInd = activeIndex;
+      },
+      handlePre() {
+        if (this.myType === 'video') {
+          this.myInd = this.myInd > 0 ? this.myInd - 1 : this.curList.length - 1;
+        } else {
+          this.swiper?.slidePrev();
+        }
+      },
+      handleNext() {
+        if (this.myType === 'video') {
+          this.myInd = this.myInd < this.curList.length - 1 ? this.myInd + 1 : 0;
+        } else {
+          this.swiper?.slideNext();
+        }
+      },
+    },
+  };
+</script>
+
+<style lang="scss">
+  @use './index.hljng.scss';
+</style>

+ 3 - 3
src/index/app.scss

@@ -43,7 +43,7 @@ body {
   margin: 0px;
   font-size: 14px;
   color: rgba(255, 255, 255, 0.9);
-  font-family: 'Source Han Sans CN-Medium';
+  font-family: 'Source Han Sans CN-Regular';
   -webkit-tap-highlight-color: transparent;
 }
 a {
@@ -74,11 +74,11 @@ iframe {
 
 @font-face {
   font-family: 'Source Han Sans CN-Regular';
-  src: url('/fonts/SourceHanSansCN-Regular.otf');
+  src: url('/fonts/SOURCEHANSERIFCN-REGULAR.OTF');
 }
 @font-face {
   font-family: 'Source Han Sans CN-Bold';
-  src: url('/fonts/SourceHanSansCN-Bold.otf');
+  src: url('/fonts/SOURCEHANSERIFCN-BOLD.OTF');
 }
 @font-face {
   font-family: 'Source Han Sans CN-Medium';

BIN=BIN
src/index/assets/images/hljng/close.png


BIN=BIN
src/index/assets/images/hljng/hotlist_bg.png


BIN=BIN
src/index/assets/images/hljng/mobile/hotlist_bg.png


+ 148 - 0
src/index/views/home/components/hot-spot-list/index.hljng.scss

@@ -0,0 +1,148 @@
+#hotListWrap {
+  display: flex;
+  flex-direction: column;
+  position: absolute;
+  top: 0;
+  right: -400px;
+  width: 260px;
+  max-width: 260px;
+  height: 100%;
+  transition: right 0.4s, width 0.5s;
+  z-index: var(--z-index-popper);
+  background: url('@/assets/images/hljng/hotlist_bg.png') repeat top / contain;
+}
+
+.hotListActive {
+  right: 0 !important;
+}
+
+#hotListTitle {
+  position: relative;
+  margin: 50px 0 45px;
+  text-align: center;
+}
+
+#hotListContent {
+  width: 100%;
+  /* opacity: 0.65; */
+  flex-grow: 1;
+  height: 100%;
+  overflow-y: scroll;
+  overflow-x: hidden;
+}
+
+#hotListBottom {
+  margin: 30px 0;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+#hotListClose {
+  width: 18px;
+  cursor: pointer;
+}
+
+#hotListContent ul {
+  font-size: 18px;
+  letter-spacing: 3px;
+}
+
+#hotListContent ul li {
+  padding: 0 20px;
+  height: 54px;
+  line-height: 54px;
+  text-align: center;
+  color: #644e36;
+  transition: color 0.3s, background 0.6s;
+  overflow: hidden;
+  white-space: nowrap;
+  text-overflow: ellipsis;
+  cursor: pointer;
+}
+
+#hotListContent ul li:hover,
+#hotListContent ul li.active {
+  background: rgba(157, 114, 66, 0.15);
+}
+
+#hotListText {
+  font-size: 24px;
+  color: #981b23;
+  font-family: 'Source Han Sans CN-Bold';
+  letter-spacing: 4px;
+}
+
+#hotListIcon {
+  width: 34px;
+  margin-left: 48px;
+}
+
+#hotListContent::-webkit-scrollbar {
+  width: 6px;
+}
+
+#hotListContent::-webkit-scrollbar-thumb {
+  border-radius: 10px;
+  background-color: #979cab;
+}
+
+#hotListContent::-webkit-scrollbar-track {
+  border-radius: 10px;
+}
+
+@media only screen and (max-width: 910px) {
+  #hotListWrap {
+    top: -100%;
+    right: 0;
+    width: 100%;
+    max-width: 100%;
+    height: 58%;
+    transition: top 0.4s, width 0.5s;
+    background: url('@/assets/images/hljng/mobile/hotlist_bg.png') no-repeat center / cover;
+  }
+  .hotListActive {
+    top: 0 !important;
+  }
+
+  #hotListTitle {
+    margin: 50px 0 25px;
+  }
+  #hotListContent {
+    /* background: rgba(34, 36, 37,0.9); */
+    background: none;
+  }
+  #hotListText {
+    font-size: 20px;
+    letter-spacing: 3px;
+    font-weight: 100;
+    position: absolute;
+    top: 50%;
+    left: 50%;
+    transform: translate(-50%, -50%);
+  }
+  #hotListIcon {
+    width: 24px;
+    margin-left: 26px;
+    position: absolute;
+    top: 50%;
+    left: 50%;
+    transform: translate(165%, -50%);
+  }
+  #hotListContent ul li {
+    text-align: center;
+    height: 65px;
+    line-height: 65px;
+  }
+  #hotListContent ul {
+    font-size: 15px;
+  }
+  #hotListBottom {
+    display: none;
+  }
+  #hotListClose {
+    display: none;
+    position: initial;
+    width: 18px;
+  }
+}

+ 24 - 0
src/index/views/home/components/hot-spot-list/index.hljng.tsx

@@ -0,0 +1,24 @@
+import { defineComponent } from 'vue';
+import CloseIcon from '@/assets/images/hljng/close.png';
+import './index.hljng.scss';
+
+export default defineComponent({
+  name: 'HomeHotSpotList',
+  render() {
+    return (
+      <div id="hotListWrap">
+        <div id="hotListTitle">
+          <div>
+            <span id="hotListText">热点列表</span>
+          </div>
+        </div>
+        <div id="hotListContent">
+          <ul></ul>
+        </div>
+        <div id="hotListBottom">
+          <img id="hotListClose" src={CloseIcon} alt="" />
+        </div>
+      </div>
+    );
+  },
+});

+ 8 - 2
src/index/views/home/components/menu/index.hljng.scss

@@ -86,6 +86,7 @@
 #gui-fullscreen-exit,
 #thumb,
 #volume,
+#volume2,
 #viewer,
 #sharing {
   display: flex;
@@ -165,13 +166,16 @@
   }
 }
 
-#volume {
+#volume,
+#volume2 {
   .icon-slot {
     background: url('@/assets/images/hljng/Volume btn_off.png') no-repeat center / contain;
   }
 
   &.active {
-    background-image: url('@/assets/images/hljng/Volume btn_on.png');
+    .icon-slot {
+      background-image: url('@/assets/images/hljng/Volume btn_on.png');
+    }
   }
 }
 
@@ -215,7 +219,9 @@
 
         #sharing,
         #volume,
+        #volume2,
         #viewer,
+        #thumb,
         .good-btn {
           .icon-slot {
             width: 35px;

+ 22 - 4
src/index/views/home/components/menu/index.hljng.vue

@@ -26,10 +26,6 @@
             <span>导览列表</span>
           </div>
 
-          <div id="hotList" title="热点列表" data-original-title="热点列表" style="display: none">
-            <div class="icon-slot" />
-            <span>热点列表</span>
-          </div>
           <div data-original-title="全景漫游" id="gui-modes-inside" title="" class="">
             <div class="icon-slot" />
             <span>全景漫游</span>
@@ -42,6 +38,10 @@
             <div class="icon-slot" />
             <span>顶部视图</span>
           </div>
+          <div id="hotList" title="热点列表" data-original-title="热点列表" style="display: none">
+            <div class="icon-slot" />
+            <span>热点列表</span>
+          </div>
           <div data-original-title="VR" id="vr" title="" style="display: none"></div>
           <div
             data-original-title="消除外壳"
@@ -56,6 +56,10 @@
     </div>
     <div class="pinBottom right hideTarget">
       <div class="rightViewContainer clearfix">
+        <div id="volume2" class="ui-icon wide" style="display: none" @click="handleAudio">
+          <div class="icon-slot" />
+          <span>音频</span>
+        </div>
         <div id="sharing" class="ui-icon wide" title="分享" @click="shareVisible = true">
           <div class="icon-slot" />
           <span>分享</span>
@@ -166,6 +170,20 @@
     starSum.value = data.starSum;
   };
 
+  const handleAudio = () => {
+    // @ts-ignore
+    const audio = $('#audio2').get(0);
+    if (audio?.paused) {
+      audio?.play();
+      // @ts-ignore
+      $('#volume2').addClass('active');
+    } else {
+      audio?.pause();
+      // @ts-ignore
+      $('#volume2').removeClass('active');
+    }
+  };
+
   onMounted(() => {
     getDetail();
 

+ 55 - 0
src/index/views/home/components/popup/index.hljng.scss

@@ -0,0 +1,55 @@
+#popup {
+  display: none;
+  position: relative;
+  padding: 0;
+  width: 100%;
+  height: 100%;
+  text-align: center;
+  background: rgba(0, 0, 0, 0.6);
+  z-index: var(--z-hot-popper);
+
+  &.wait {
+    opacity: 0.1;
+  }
+}
+#id1 {
+  width: 100%;
+  height: 100%;
+}
+.popup-content {
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  width: 760px;
+  height: 590px;
+  transform: translate(-50%, -50%);
+}
+#closepop {
+  position: absolute;
+  top: 20px;
+  right: 20px;
+  width: 18px;
+  height: 18px;
+  cursor: pointer;
+  text-indent: -999em;
+  background-size: 100% 100%;
+  background: url('@hotspot/assets/images/hljng/close.png') no-repeat center / contain;
+}
+
+@media only screen and (max-width: 600px) {
+  .popup-content {
+    top: 45%;
+    width: calc(100% - 30px);
+    height: 65%;
+  }
+  #closepop {
+    top: unset;
+    left: 50%;
+    right: unset;
+    bottom: -50px;
+    width: 30px;
+    height: 30px;
+    background-image: url('@hotspot/assets/images/hljng/mobile/close.png');
+    transform: translateX(-50%);
+  }
+}

+ 15 - 0
src/index/views/home/components/popup/index.hljng.tsx

@@ -0,0 +1,15 @@
+import { defineComponent } from 'vue';
+import './index.hljng.scss';
+
+export default defineComponent({
+  name: 'HomePopup',
+  render() {
+    return (
+      <div id="popup">
+        <div class="popup-content">
+          <div id="closepop">close</div>
+        </div>
+      </div>
+    );
+  },
+});

+ 14 - 1
src/index/views/home/index.hljng.tsx

@@ -13,6 +13,12 @@ import useBaseStore from '@/store/module/base';
 import BackIcon from '@/assets/images/hljng/back.png';
 import './index.hljng.scss';
 
+// @ts-ignore
+window.hoticon = {
+  default: './images/hljng/point.png',
+  higt: './images/hljng/point2.png',
+};
+
 export default defineComponent({
   name: 'home',
   components: {
@@ -29,10 +35,15 @@ export default defineComponent({
     const manageJsLoaded = ref(false);
     const hotJsLoaded = ref(false);
 
+    const hideAudio = () => {
+      document.getElementById('volume2')!.style.display = 'none';
+    };
+
     return {
       manageJsLoaded,
       hotJsLoaded,
       baseStore,
+      hideAudio,
     };
   },
   render() {
@@ -96,7 +107,7 @@ export default defineComponent({
         {this.manageJsLoaded && (
           <div>
             <JsScript
-              src="./js/Hot.js"
+              src="./js/Hot.hljng.js"
               onLoad={() => {
                 this.hotJsLoaded = true;
                 this.baseStore.handleJSLoaded('hotJsLoaded');
@@ -114,6 +125,8 @@ export default defineComponent({
             )}
           </div>
         )}
+
+        <audio id="audio2" src="" style="display: none" onEnded={this.hideAudio} />
       </div>
     );
   },