jwyu пре 2 година
родитељ
комит
b60b2d5154
3 измењених фајлова са 17 додато и 5 уклоњено
  1. 3 0
      src/hooks/common.js
  2. 10 4
      src/views/report/chapter/Detail.vue
  3. 4 1
      src/views/report/components/AudioBox.vue

+ 3 - 0
src/hooks/common.js

@@ -18,5 +18,8 @@ export function useUserInfo(){
 export function isWeiXin(){
     const ua = navigator.userAgent.toLowerCase();
     const flag = ua.indexOf('micromessenger') != -1;
+    if(flag){
+        console.log('在微信浏览器中', flag)
+    }
     return flag
 }

+ 10 - 4
src/views/report/chapter/Detail.vue

@@ -193,7 +193,8 @@ function handleShowUploadAudio(){
 // 获取音频时长
 function handleGetAudioDuration(file){
     return new Promise((resolve,reject)=>{
-        if(isWeiXin){
+        if(isWeiXin()){
+            console.log('微信?');
             resolve(0)
         }
 
@@ -231,6 +232,7 @@ async function handleAudioUploadAfterRead(e){
     temAudioData.time=duration
     temAudioData.size=e.file.size/1024/1024 //单位MB
     temAudioData.name=e.file.name
+    console.log('音频数据temAudioData',temAudioData);
     // 生成文件名
     const t=new Date().getTime().toString()
     const temName=`static/yb/audio/${import.meta.env.MODE}/${MD5(t)}.${e.file.type.split('/')[1]}`
@@ -243,6 +245,10 @@ function handleUpdateAudio(){
     chapterBaseInfo.audioSize=temAudioData.size
     showUploadAudio.value=false
 }
+//更新下音频时长
+function handleUpdateAudioTime(e){
+    temAudioData.time=e
+}
 
 // 报告插入数据弹窗
 const showReportInsertPop=ref(false)
@@ -486,11 +492,11 @@ async function handleReportOpt(type){
         :style="{height:'60%'}"
     >
         <div class="upload-audio-wrap" v-if="showUploadAudio">
-            <div style="font-size:12px;color:#666">tips:如果是在微信内访问请上传完音频点击播放获取音频时长后方可保存</div>
+            <div style="font-size:12px;color:#666">tips:如何是在微信中访问,请上传完音频点击播放,获取音频时长后方可保存</div>
             <template v-if="temAudioData.url">
                 <h2>音频链接</h2>
                 <p>{{temAudioData.url}}</p>
-                <AudioBox :url="temAudioData.url" @updateDuration="e=>temAudioData.time=e"/>
+                <AudioBox :time="temAudioData.time" :url="temAudioData.url" @updateDuration="handleUpdateAudioTime"/>
             </template>
             <div class="bot-btns">
                 <van-uploader 
@@ -500,7 +506,7 @@ async function handleReportOpt(type){
                 >
                     <van-button class="bot-btn" type="default">{{temAudioData.url?'重新上传':'上传音频'}}</van-button>
                 </van-uploader>
-                <van-button class="bot-btn" type="primary" :disabled="!temAudioData.url||!temAudioData.time" @click="handleUpdateAudio">保存</van-button>
+                <van-button class="bot-btn" type="primary" :disabled="!temAudioData.url||temAudioData.time===0" @click="handleUpdateAudio">保存</van-button>
             </div>
         </div>
     </van-popup>

+ 4 - 1
src/views/report/components/AudioBox.vue

@@ -4,7 +4,8 @@ const props=defineProps({
     url:{
         type:String,
         defalut:''
-    }
+    },
+    time:0
 })
 
 const emits=defineEmits(['updateDuration'])
@@ -15,6 +16,8 @@ watch(
         if(audioIns.value){
             audioIns.value.src=props.url
         }
+        console.log(props.time);
+        duration.value=props.time
     }
 )