Explorar el Código

BUG修复/新增巡检完成提示音模块

fanghuisheng hace 1 año
padre
commit
476a92ad26

+ 70 - 0
src/components/oa-ttsAudio/index.vue

@@ -0,0 +1,70 @@
+<template></template>
+<script setup>
+import { onReady, onLoad, onUnload, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
+import { defineComponent, getCurrentInstance, inject, nextTick, onMounted, watchEffect, ref } from "vue";
+
+const emit = defineEmits(["onEnded", "onError"]);
+const props = defineProps({
+  //播放原地址
+  audioUrl: {
+    type: String,
+    defualt: "",
+  },
+  //是否开启
+  audioBool: {
+    type: Boolean,
+    defualt: "",
+  },
+});
+
+const isPlay = ref(false);
+const innerAudio = ref(null);
+
+function handleTTS() {
+  if (!audioBool) {
+    return;
+  }
+
+  if (innerAudio.value) {
+    try {
+      innerAudio.value.pause();
+      innerAudio.value.destroy();
+      innerAudio.value = null;
+    } catch (e) {
+      //TODO handle the exception
+    }
+  }
+
+  innerAudio.value = uni.createInnerAudioContext();
+  innerAudio.value.autoplay = true;
+  innerAudio.value.volume = 1;
+  innerAudio.value.src = props.audioUrl;
+  innerAudio.value.onPlay(() => {
+    console.log("开始播放");
+  });
+  innerAudio.value.onEnded((res) => {
+    console.log("音频播放结束");
+    isPlay.value = false;
+  });
+  innerAudio.value.onError((res) => {
+    console.log("音频播放出错" + res);
+    console.log(res.errCode);
+  });
+
+  innerAudio.value.play();
+}
+
+watchEffect(() => {
+  if (props.audioUrl) {
+    handleTTS();
+  }
+});
+
+onUnload(() => {
+  if (innerAudio.value) {
+    innerAudio.value.stop();
+    innerAudio.value.destroy();
+  }
+});
+</script>
+<style lang="scss" scoped></style>

+ 2 - 0
src/main.js

@@ -23,6 +23,7 @@ import oaTouch from "@/components/oa-touch/index"
 import oaDropdown from "@/components/oa-dropdown/index"
 import oaUpgrade from "@/components/oa-upgrade/index"
 import oaTransForm from "@/components/oa-transForm/index"
+import oaTtsAudio from "@/components/oa-ttsAudio/index"
 
 export function createApp() {
   const app = createSSRApp(App);
@@ -38,6 +39,7 @@ export function createApp() {
   app.component('oa-dropdown', oaDropdown)
   app.component('oa-upgrade', oaUpgrade)
   app.component('oa-transForm', oaTransForm)
+  app.component('oa-ttsAudio', oaTtsAudio)
 
   // 挂载全局json导出
   app.component("downloadExcel", JsonExcel);

+ 14 - 5
src/pages.json

@@ -285,12 +285,10 @@
         }
       ]
     },
-    // 闵行消
+    // 智慧安
     {
-      "root": "pages/business/mhxf",
+      "root": "pages/business/zhaf",
       "pages": [
-        //消防督察单模块 开始
-        //消防督察单模块 结束
         //巡检模块 开始
         {
           "path": "xunJian/xunJian",
@@ -389,8 +387,19 @@
               }
             }
           }
-        },
+        }
         //巡检模块 结束
+      ]
+    },
+    // 智慧安防
+
+    // 闵行消防
+    {
+      "root": "pages/business/mhxf",
+      "pages": [
+        //消防督察单模块 开始
+        //消防督察单模块 结束
+
         //信息查询 开始
         {
           "path": "informationSelect/index",

+ 0 - 10
src/pages/business/mhxf/informationSelect/index.vue

@@ -570,16 +570,6 @@ function addZero(s) {
 
 // end
 
-// 自定义导航事件
-onNavigationBarButtonTap((e) => {
-  if (e.float == "right") {
-    uni.navigateTo({
-      url: "/pages/business/zhaf/xunJian/collect/components/collectRecord",
-    });
-  } else {
-  }
-});
-
 onLoad((options) => {
   getNowTime(); //进入页面调用该方法获取当前时间
   clearInterval(myTimeDisplay); //销毁之前定时器

+ 5 - 2
src/pages/business/zhaf/xunJian/plan/components/content.vue

@@ -73,6 +73,9 @@
     </view>
 
     <u-modal ref="uModal" :show="show" :title="title" :content="content" @confirm="confirm"></u-modal>
+
+    <!-- 巡检完成提示 -->
+    <oa-ttsAudio v-if="audioUrl" :audioUrl="audioUrl" :audioBool="true"></oa-ttsAudio>
   </scroll-view>
 </template>
 
@@ -80,12 +83,10 @@
 import { onLoad, onShow } from "@dcloudio/uni-app";
 import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef } from "vue";
 import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
-
 import { updatePlan } from "@/api/business/mhxf/xunJian/plan.js";
 
 const BASE_URL = inject("$BASE_URL");
 const xunJianStore = xunJianStores(); //全局变量值Store
-
 const { proxy } = getCurrentInstance();
 
 const contentList = ref([]);
@@ -108,7 +109,9 @@ function remarksClick(index) {
 const show = ref(false);
 const title = ref("");
 const content = ref("");
+const audioUrl = ref("");
 function confirm() {
+  audioUrl.value = "/static/mp3/XJWC.mp3";
   show.value = false;
   uni.$emit("planSelect"); //执行页面中的自定义方法
   uni.navigateBack({

BIN
src/static/mp3/XJWC.mp3