瀏覽代碼

Merge branch 'master' into localversion

tremble 3 年之前
父節點
當前提交
779bf8a940

+ 2 - 1
public/showMobile.html

@@ -29,7 +29,8 @@
     <!-- built files will be auto injected -->
     <script src="<%= VUE_APP_STATIC_DIR %>/lib/jquery-2.1.1.min.js"></script>
     <script src="<%= VUE_APP_STATIC_DIR %>/lib/krpano/js/tour.js"></script>
-    <!-- <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
+    <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
+
 <!-- 
     <script>
       let href = window.location.href

+ 1 - 1
src/api/index.js

@@ -332,7 +332,7 @@ export function checkLogin() {
  */
  export function checkPassword(data, ok, no) {
     data.workId = number()
-    return http.post(`${URL_FILL}/web/common/checkPwd`, data, ok, no)
+    return http.postJson(`${URL_FILL}/web/common/checkPwd`, data, ok, no)
 }
 
 

+ 36 - 6
src/framework/showMobile/iframe.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="ifrcon">
-    <Header :params="params" :title="'111'" />
+    <Header :bgmUrl="tempBgm" @toggleBGM="handleBGM" :somedatainfo="somedatainfo" :bgmstatus="bgmstatus" :params="params" />
     <iframe allowfullscreen="true" ref="iframe" id="showifr" :src="url" frameborder="0" @load="onIframLoad"></iframe>
   </div>
 </template>
@@ -10,11 +10,17 @@ import Header from "./ui/Show.Header";
 import browser from "@/utils/browser"
 
 export default {
-  props:['url'],
+  props:['url','bgmUrl','somedatainfo'],
   components:{Header},
   data(){
     return {
-      params:''
+      params:'',
+      bgmstatus: false
+    }
+  },
+  computed:{
+    tempBgm(){
+      return this.bgmUrl
     }
   },
   methods:{
@@ -34,7 +40,6 @@ export default {
             ||e.data.params.url.indexOf('https://test.4dkankan.com/spc.html?')>-1
             ||e.data.params.url.indexOf('https://test.4dkankan.com/smobile.html?')>-1) {
               let m = browser.urlHasValueFromUrl('m',e.data.params.url)
-              console.log(m);
               this.$emit('changeUrl',m)
             } else{
               this.$emit('otherUrl',e.data.params.url)
@@ -42,22 +47,47 @@ export default {
 
         }
 
-        // if (e.data.event == "guide-status") {
-        // }
+
+
 
         if (e.data.event == "action") {
           this.$bus.emit('currentMode',e.data.params)
+          
+          if (e.data.params.type == "playMusic") {
+            console.log(e.data.params.data.status,'e.data');
+            this.bgmstatus = e.data.params.data.status
+            
+          }
         }
 
         if (e.data.event == "loaded") {
+          console.log(e.data.params);
           this.params = e.data.params
           this.$refs.iframe.contentWindow.postMessage({
               source: "mingyuan",
               event: 'guide-rooms'
           },"*")
+
+          this.$refs.iframe.contentWindow.postMessage({
+              source : "mingyuan",
+              event:"settings",
+              params:{
+                  playMusic:true
+              }
+          },"*")
         }
 
       }
+    },
+    handleBGM(status){
+
+       this.$refs.iframe.contentWindow.postMessage({
+            source : "mingyuan",
+            event:"settings",
+            params:{
+                playMusic:status
+            }
+        },"*")
     }
   }
 }

+ 88 - 104
src/framework/showMobile/index.vue

@@ -5,33 +5,20 @@
         v-if="activeItem.type == '4dkk'"
         @changeUrl="handleChange"
         @otherUrl="handleOther"
+        :bgmUrl="bgmUrl"
+        :somedatainfo="somedatainfo"
         :key="embeM||activeItem.sceneCode"
         :url="otherLink?otherLink:`local/4dkk/${activeItem.sceneCode}/wwwroot/embed.html?from=mingyuan&m=${embeM||activeItem.sceneCode}&lang=zh&scene-link=1&rnd=${rnd}`"
       />
-        <!-- -->
+      <!-- -->
 
       <div v-show="activeItem.type != '4dkk'" id="pano"></div>
-      
-      <div
-        class="pano-logo"
-        v-if="showInfo.isLogo && activeItem.type != '4dkk'"
-      >
-        <img
-          :src="
-            showInfo.logo ||
-            require('@/assets/images/default/img_logoshow@2x.png')
-          "
-          alt=""
-        />
+
+      <div class="pano-logo" v-if="showInfo.isLogo && activeItem.type != '4dkk'">
+        <img :src="showInfo.logo || require('@/assets/images/default/img_logoshow@2x.png')" alt="" />
       </div>
 
-      <list
-        v-if="canLoad&&!isVR"
-        @select="handleSelect"
-        :firstScene="firstScene"
-        :select="activeItem"
-        :mapvisit="mapvisit"
-      ></list>
+      <list v-if="canLoad && !isVR" @select="handleSelect" :firstScene="firstScene" :select="activeItem" :mapvisit="mapvisit"></list>
 
       <ul class="aside" v-show="activeItem.type != '4dkk'">
         <li v-for="(item, i) in aside" :key="i">
@@ -40,47 +27,20 @@
           </span>
         </li>
       </ul>
-      <div
-        class="oper-tips"
-        :class="{ hidetips: !showTips }"
-        v-if="localRemind"
-      >
-        <img
-          :src="
-            showInfo.appIcon ||
-            require('@/assets/images/default/show/img_tipsmb_default.png')
-          "
-          alt=""
-        />
+      <div class="oper-tips" :class="{ hidetips: !showTips }" v-if="localRemind">
+        <img :src="showInfo.appIcon || require('@/assets/images/default/show/img_tipsmb_default.png')" alt="" />
       </div>
-      <password
-        :bg="showInfo.icon"
-        :show="showPassword"
-        @submit="handlePassword"
-        @close="showPassword = false"
-      />
+      <password :bg="showInfo.icon" :show="showPassword" @submit="handlePassword" @close="showPassword = false" />
       <popup :title="'简介'" :show="showIntro" @close="showIntro = false">
         <div slot="content" class="introcon">
           <span>{{ showInfo.description || "暂无简介" }}</span>
         </div>
       </popup>
-      <imgview
-        @close="showImage = false"
-        v-if="showImage"
-        :image="currentHotspot.image"
-      />
+      <imgview @close="showImage = false" v-if="showImage" :image="currentHotspot.image" />
 
-      <preview
-        :item="currentHotspot"
-        :show="showPreview"
-        @close="showPreview = false"
-      />
+      <preview :item="currentHotspot" :show="showPreview" @close="showPreview = false" />
 
-      <popup
-        :title="currentHotspot.hotspotTitle"
-        :show="showTextarea"
-        @close="showTextarea = false"
-      >
+      <popup :title="currentHotspot.hotspotTitle" :show="showTextarea" @close="showTextarea = false">
         <div slot="content" class="introcon">
           <span>{{ currentHotspot.textarea }}</span>
         </div>
@@ -115,10 +75,10 @@
 
 <script>
 import * as krfn from "@/core/index.js";
-import { getPanoInfo, checkPassword, checkWork,getSceneInfomation } from "@/api";
+import { getPanoInfo, checkPassword, checkWork, getSceneInfomation } from "@/api";
 import password from "./popup/password";
 import preview from "./popup/preview";
-import { $smallWaiting } from '@/components/shared/loading'
+import { $smallWaiting } from "@/components/shared/loading";
 
 import imgview from "./popup/imgview";
 import vIfr from "./iframe";
@@ -132,6 +92,17 @@ import list from "./list";
 
 let __krfn = krfn.default;
 
+let bgmMap = {
+  欢快: "01.mp3",
+  空灵: "02.mp3",
+  节奏: "03.mp3",
+  怀旧: "04.mp3",
+  想念: "05.mp3",
+  复古: "06.mp3",
+  琴弦: "07.mp3",
+  愉快: "08.mp3",
+};
+
 export default {
   components: {
     list,
@@ -149,9 +120,11 @@ export default {
   },
   data() {
     return {
-      mapvisit:0,
-      isVR:false,
-      localRemind:false,
+      mapvisit: 0,
+      bgmUrl: "",
+      somedatainfo:'',
+      isVR: false,
+      localRemind: false,
       showPreview: false,
       audioUrl: "",
       showTips: false,
@@ -168,9 +141,9 @@ export default {
       currentHotspot: "",
       list: [],
       loadFinish: false,
-      embeM:null,
-      otherLink:null,
-      rnd:null,
+      embeM: null,
+      otherLink: null,
+      rnd: null,
       aside: [
         {
           id: "about",
@@ -184,17 +157,31 @@ export default {
     };
   },
   methods: {
-    handleOther(data){
-      this.otherLink=data
-      this.rnd = Math.random()
+    handleOther(data) {
+      this.otherLink = data;
+      this.rnd = Math.random();
     },
-    handleChange(data){
-      this.embeM=data
-      this.rnd = Math.random()
+    handleChange(data) {
+      this.embeM = data;
+      this.rnd = Math.random();
     },
-    getSceneInfomation(){
-      getSceneInfomation({id:this.activeItem.sceneCode}, (data) => {
-        this.mapvisit = data.data.mapVisi
+    getSceneInfomation() {
+      getSceneInfomation({ id: this.activeItem.sceneCode }, (data) => {
+        this.mapvisit = data.data.mapVisi;
+        this.somedatainfo = data.data
+        if (data.data.bgMusic) {
+          if (bgmMap[data.data.bgMusic]) {
+            this.bgmUrl =
+              window.location.href.indexOf("www.4dkankan.com") > -1
+                ? `https://4dkk.4dage.com/v3/audio/${bgmMap[data.data.bgMusic]}`
+                : `https://4dkk.4dage.com/v3-test/audio/${bgmMap[data.data.bgMusic]}`;
+          }
+
+          if (data.data.bgMusic == 'user') {
+            this.bgmUrl = data.data.bgMusic ? `https://4dkk.4dage.com/images/images${data.data.num}/${data.data.bgMusicName}` : "";
+          }
+
+        }
       });
     },
     handleEnded() {
@@ -205,16 +192,15 @@ export default {
         this.showIntro = true;
       }
       if (data.id == "vr") {
-        this.$iosGrantedTips(data=>{
-          if (data.code==1) {
+        this.$iosGrantedTips((data) => {
+          if (data.code == 1) {
             var krpano = document.getElementById("krpanoSWFObject");
             var webvr = krpano.get("webvr");
             webvr.entervr();
+          } else {
+            this.$alert({ content: "运动和方向访问失败,您需要完全关闭此应用,然后再次打开,并允许访问运动与方向" });
           }
-          else{
-            this.$alert({content:'运动和方向访问失败,您需要完全关闭此应用,然后再次打开,并允许访问运动与方向'})
-          }
-        })
+        });
       }
     },
 
@@ -260,11 +246,10 @@ export default {
       });
       rootmp = this.$unique(rootmp);
 
-      let sortArr = this.showInfo.catalogRoot.map(item=>item.name)
-      rootmp.sort((a,b)=>{
-        return sortArr.indexOf(a.name) - sortArr.indexOf(b.name)
-      })
-
+      let sortArr = this.showInfo.catalogRoot.map((item) => item.name);
+      rootmp.sort((a, b) => {
+        return sortArr.indexOf(a.name) - sortArr.indexOf(b.name);
+      });
 
       this.showInfo.catalogRoot = rootmp.map((item) => {
         let temp = [];
@@ -301,9 +286,7 @@ export default {
       }
 
       if (this.showInfo.firstScene) {
-        this.showInfo.firstScene = this.showInfo.scenes.find(
-          (item) => item.sceneCode == this.showInfo.firstScene.sceneCode
-        );
+        this.showInfo.firstScene = this.showInfo.scenes.find((item) => item.sceneCode == this.showInfo.firstScene.sceneCode);
       }
 
       this.$store.commit("SetShowInfo", this.showInfo);
@@ -320,7 +303,7 @@ export default {
   watch: {
     currentHotspot: {
       deep: true,
-      handler: function (newVal) {
+      handler: function(newVal) {
         if (newVal) {
           this.audioUrl = "";
           if (newVal.hotspotType == "link") {
@@ -351,7 +334,7 @@ export default {
     canLoad(newVal) {
       if (newVal) {
         setTimeout(() => {
-          this.showTips = this.localRemind
+          this.showTips = this.localRemind;
           setTimeout(() => {
             this.showTips = false;
           }, this.showInfo.remindTime * 1000);
@@ -361,7 +344,7 @@ export default {
     showInfo: {
       deep: true,
       immediate: true,
-      handler: function (newVal) {
+      handler: function(newVal) {
         if (newVal) {
           document.title = newVal.name || "无标题";
           let locoR = "localRemind" + newVal.id;
@@ -377,7 +360,7 @@ export default {
             localStorage.setItem(locoR, 0);
           }
           if (this.showInfo.firstScene) {
-            if (this.showInfo.firstScene.type == '4dkk') {
+            if (this.showInfo.firstScene.type == "4dkk") {
               this.localRemind = false;
             }
           }
@@ -399,15 +382,17 @@ export default {
             this.otherLink = null;
             removepano("#pano");
             $("#pano").empty();
-            this.getSceneInfomation()
+            this.getSceneInfomation();
             return;
+          } else {
+            this.bgmUrl = "";
           }
           removepano("#pano");
-          $smallWaiting.show()
+          $smallWaiting.show();
 
           $("#pano").empty();
           window.vrInitFn = () => {
-            $smallWaiting.hide()
+            $smallWaiting.hide();
             var krpano = document.getElementById("krpanoSWFObject");
             __krfn.utils.initHotspot(krpano, newVal && newVal.someData, false);
           };
@@ -446,19 +431,18 @@ export default {
   mounted() {
     window.__krfn = __krfn;
     this.$bus.on("clickHotspot", (data) => {
-       let someData = this.activeItem.someData
-      if (typeof someData == 'string') {
+      let someData = this.activeItem.someData;
+      if (typeof someData == "string") {
         someData = JSON.parse(this.activeItem.someData);
       }
       let idx = someData.hotspots.findIndex((item) => item.name == data);
       this.currentHotspot = someData.hotspots[idx];
     });
 
-    this.$bus.on('isVR',(data)=>{
-      this.isVR = data
-    })
+    this.$bus.on("isVR", (data) => {
+      this.isVR = data;
+    });
 
-    
     this.getSceneInfo();
   },
 };
@@ -522,14 +506,14 @@ export default {
     padding: 0 10px;
     &.active {
       background: rgba(0, 0, 0, 0.3);
-      border: 1px solid #0076F6;
-      color: #0076F6;
+      border: 1px solid #0076f6;
+      color: #0076f6;
     }
-    .iconedit_soundview{
-      color: #0076F6;
+    .icon-edit_soundview {
+      color: #0076f6;
       margin-right: 10px;
     }
-    .vaduio{
+    .vaduio {
       visibility: hidden;
       width: 0;
     }
@@ -594,8 +578,8 @@ export default {
     word-break: break-all;
     max-height: 75vh;
     overflow-y: auto;
-    -webkit-overflow-scrolling:touch;
-    >span{
+    -webkit-overflow-scrolling: touch;
+    > span {
       display: inline-block;
       -webkit-overflow-scrolling: touch;
       text-align: justify;

文件差異過大導致無法顯示
+ 558 - 491
src/framework/showMobile/ui/Show.Header.vue


+ 1 - 0
src/pages/edit.js

@@ -5,6 +5,7 @@ import router from '../router'
 import store from '../Store'
 import 'viewerjs/dist/viewer.css'
 import Viewer from 'v-viewer'
+
 Vue.use(Viewer,{
   defaultOptions: {
     toolbar: 0,

+ 5 - 0
src/utils/platform.js

@@ -0,0 +1,5 @@
+/**
+ * 微信
+ */
+export const IsWechat = /MicroMessenger/gi.test(window.navigator.userAgent)
+

+ 252 - 0
src/utils/sounds.js

@@ -0,0 +1,252 @@
+import config from "@/config";
+import { IsWechat } from "./platform";
+
+Howler._unlockAudio();
+// Howl.prototype.setSRC = function(newSrc) {
+
+//     var self = this;
+//     self.stop();
+//     self._src = newSrc;
+//     self._sprite = {};
+//     self._duration = 0;
+//     if (self._sounds[0] && self._sounds[0]._node) {
+//         self._sounds[0]._node.src = newSrc;
+//     }
+//     self.load();
+// }
+
+let isReady = false;
+export const checkReadyToPlay = function(resolve, isTouchToPlay) {
+  
+  if (isReady === true) {
+    return resolve();
+  }
+
+  try {
+    function ready() {
+      if (typeof parent.WeixinJSBridge !== "undefined") {
+        console.log("wx play");
+        parent.WeixinJSBridge.invoke(
+          "getNetworkType",
+          {},
+          function(e) {
+            resolve((isReady = true));
+          },
+          false
+        );
+      } else if (isTouchToPlay) {
+        resolve((isReady = true));
+        document.querySelector("body").removeEventListener("touchend", ready);
+        document.querySelector("#player") && document.querySelector("#player").removeEventListener("touchend", ready);
+      }
+    }
+    if (config.isMobile) {
+      if (IsWechat) {
+        if (typeof parent.WeixinJSBridge !== "undefined") {
+          ready();
+        } else {
+          parent.document.addEventListener("WeixinJSBridgeReady", ready);
+        }
+      } else if (isTouchToPlay) {
+        document.querySelector("body").addEventListener("touchend", ready);
+        document.querySelector("#player") && document.querySelector("#player").addEventListener("touchend", ready);
+        ready();
+      }
+    } else {
+      resolve((isReady = true));
+    }
+  } catch (error) {
+    resolve((isReady = true));
+  }
+};
+
+class SoundPlayer extends EventEmitter {
+  constructor(options = {}) {
+    super();
+    this._pause_byother = false;
+    this._disable = false;
+    this._canplay = false;
+    this._options = options;
+    // this._sound = new Howl({
+    //     src: [''],
+    //     loop: options.loop ? true : false,
+    //     html5: options.html5 ? true : false,
+    //     format: ['mp3', 'webm'],
+    // })
+
+    // this._sound.on('play', () => this.emit('play'))
+    // this._sound.on('end', () => this.emit('end') && this.emit('off'))
+    // this._sound.on('pause', () => this.emit('pause') && this.emit('off'))
+    // this._sound.on('stop', () => this.emit('stop') && this.emit('off'))
+    // this._sound.on('loaderror', err => this.emit('error', err))
+
+    // if (!options.html5) {
+    //     this._sound.on('load', () => {
+    //         this.emit('loaded', this._sound.duration())
+    //     })
+    // }
+  }
+  init(src) {
+    this.remove();
+    this._canplay = true;
+    this._sound = new Howl({
+      src: [src],
+      loop: this._options.loop ? true : false,
+      html5: this._options.html5 ? true : false,
+      //preload : this._options.html5 ? true : false,
+      format: ["mp3", "webm"],
+    });
+
+    this._sound.on("play", () => this.emit("play"));
+    this._sound.on("end", () => this.emit("end") && this.emit("off"));
+    this._sound.on("pause", () => this.emit("pause") && this.emit("off"));
+    this._sound.on("stop", () => this.emit("stop") && this.emit("off"));
+    this._sound.on("loaderror", (err) => this.emit("error", err));
+
+    this._sound.once("load", () => {
+      this.emit("loaded", this._sound.duration());
+    });
+  }
+  /**
+   * 设置播放源
+   * @param {String} src 音频地址
+   * @param {Boolean} isAutoplay 是否自动播放,default:true
+   */
+  setSRC(src) {
+    //this._sound.setSRC(src)
+    //this._pause_byother = false
+
+    if (src) {
+      this.init(src);
+    } else {
+      this.remove();
+      //this.emit('stop') && this.emit('off')
+    }
+  }
+  /**
+   * 设置是否循环
+   * @param {Boolean} isLoop
+   */
+  setLoop(isLoop) {
+    if (!this._canplay) {
+      return;
+    }
+    this._sound.loop(isLoop);
+  }
+  /**
+   * 播放
+   */
+  play() {
+    setTimeout(() => {
+      if (this._disable || !this._canplay || this._sound.playing()) {
+        return;
+      }
+
+      this._sound.play();
+      this._pause_byother = false;
+    }, 10);
+  }
+  /**
+   * 停止
+   */
+  stop() {
+    if (!this._canplay) {
+      return;
+    }
+    if (!this._sound.playing()) {
+      return;
+    }
+    this._sound.stop();
+  }
+  /**
+   * 暂停
+   * @param {Boolean} isByOther 是否由其他播放源导致的暂停,default:false
+   */
+  pause(isByOther = false) {
+    if (!this._canplay) {
+      return;
+    }
+    if (this._sound.playing()) {
+      this._sound.pause();
+      this._pause_byother = isByOther;
+    }
+  }
+  /**
+   * 强制标记为其他播放源引起的暂停行为
+   */
+  pauseByOther() {
+    if (this._canplay) {
+      this._pause_byother = true;
+    }
+  }
+  time(time) {
+    if (!this._canplay) {
+      return;
+    }
+    this._sound.seek(time);
+  }
+  /**
+   * 设置静音
+   */
+  mute(muted) {
+    if (!this._canplay) {
+      return;
+    }
+    this._sound.mute(muted);
+  }
+  /**
+   * 继续播放(如果pause方法中的isByOther为true,则可以继续播放,否则无效)
+   */
+  resume() {
+    if (!this._canplay) {
+      return;
+    }
+    if (this._pause_byother) {
+      this.play();
+    }
+  }
+  remove() {
+    this._canplay = false;
+    this._pause_byother = false;
+    if (this._sound) {
+      this._sound.stop();
+      this._sound.unload();
+    }
+  }
+  /**
+   * 禁用
+   */
+  disabel() {
+    this._disable = true;
+  }
+  /**
+   * 启用
+   */
+  enable() {
+    this._disable = false;
+  }
+
+  /**
+   * 是否正在播放
+   */
+  get isPlaying() {
+    if (!this._canplay) {
+      return false;
+    }
+
+    return this._sound.playing();
+  }
+}
+
+/**
+ * 背景音乐播放器
+ */
+export const backgroundMusicPlayer = new SoundPlayer({ html5: false, loop: true });
+/**
+ * 自动导览录音播放器
+ */
+export const guideSoundPlayer = new SoundPlayer({ html5: false });
+/**
+ * 热点音频播放器
+ */
+export const hotspotSoundPlayer = new SoundPlayer({ html5: true, loop: true });

+ 2 - 2
src/views/hotspot/EditPanel.vue

@@ -58,8 +58,8 @@
                 <input
                   type="text"
                   class="ui-input"
-                  placeholder="请填写标题限15字"
-                  :maxlength="15"
+                  placeholder="请填写标题限50字"
+                  :maxlength="50"
                   v-model="hotspot.hotspotTitle"
                 />
               </div>

+ 1 - 1
src/views/material/image/index.vue

@@ -88,7 +88,7 @@
           >
         </div>
       </tableList>
-      <UploadTaskList class="upload-task-list" fileType="AUDIO" :taskList="uploadListForUI" @cancel-task="onCancelTask"></UploadTaskList>
+      <UploadTaskList class="upload-task-list" fileType="IMAGE" :taskList="uploadListForUI" @cancel-task="onCancelTask"></UploadTaskList>
       <div class="total-number" v-if="list.length !== 0 || hasMoreData">已加载{{list.length}}条</div>
       <div class="nodata" v-if="list.length == 0 && !hasMoreData && lastestUsedSearchKey">
         <img :src="$noresult" alt="" />