|
@@ -12,17 +12,16 @@
|
|
|
/>
|
|
|
<view>暂无数据</view>
|
|
|
</view>
|
|
|
- <view class="list-wrap" :style="{paddingBottom:IsVoiceAdmin&&'200rpx'}" v-else>
|
|
|
+ <view class="list-wrap" :style="{paddingBottom:pagePaddingBot}" v-else>
|
|
|
<view class="item" v-for="item in list" :key="item.BroadcastId" @click="handleGoDetail(item)">
|
|
|
<view class="title">{{item.BroadcastName}}</view>
|
|
|
<view class="time">发布时间:{{item.CreateTime|formatTime}}</view>
|
|
|
<view class="flex audio-box" @click.stop="handlePlay(item)">
|
|
|
<image
|
|
|
- :src="item.BroadcastId==temAudio.id&&!temAudio.paused?require('@/static/voice/playing.png'):require('@/static/voice/pause.png')"
|
|
|
+ :src="item.BroadcastId==curVoiceId&&!curAudioPaused?require('@/static/voice/playing.png'):require('@/static/voice/pause.png')"
|
|
|
mode="widthFix"
|
|
|
/>
|
|
|
- <text v-if="item.BroadcastId==temAudio.id">{{temAudio.curTime|formatVoiceTime}}</text>
|
|
|
- <text v-else>{{item.VoicePlaySeconds|formatVoiceTime}}</text>
|
|
|
+ <text>{{item.VoicePlaySeconds|formatVoiceTime}}</text>
|
|
|
</view>
|
|
|
<button class="publish-btn" @click.stop="handleSendMsgItem(item)" v-if="item.CouldSendMsg">
|
|
|
<image class="publish-img" src="@/static/voice/publish.png" mode="widthFix" />
|
|
@@ -42,7 +41,7 @@
|
|
|
</view>
|
|
|
|
|
|
<navigator url="/pages-voice/addVoice">
|
|
|
- <view class="add-btn" v-if="IsVoiceAdmin">新建语音</view>
|
|
|
+ <view :class="['add-btn',showAudioPop?showAudioBigPop?'add-btn-bot3':'add-btn-bot2':'add-btn-bot1']" v-if="IsVoiceAdmin">新建语音</view>
|
|
|
</navigator>
|
|
|
|
|
|
<!-- 筛选弹窗 -->
|
|
@@ -70,6 +69,13 @@
|
|
|
</view>
|
|
|
</van-popup>
|
|
|
|
|
|
+ <!-- 音频悬浮 -->
|
|
|
+ <view v-if="showPage">
|
|
|
+ <audioBox v-if="showAudioPop"/>
|
|
|
+ </view>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
<van-dialog id="van-dialog" />
|
|
|
</view>
|
|
|
<noAuth :info="noAuthData" v-else/>
|
|
@@ -79,11 +85,12 @@
|
|
|
import {apiVoiceList,apiVoiceSectionList,apiVoicePlayRecord,apiVoiceDel,apiVoiceSendMsg} from '@/api/voice'
|
|
|
import {apiGetSceneToParams} from '@/api/common'
|
|
|
import noAuth from './components/noAuth.vue'
|
|
|
+import audioBox from '@/components/audioBox/audioBox.vue'
|
|
|
const moment=require('@/utils/moment-with-locales.min')
|
|
|
-let innerAudioContext = uni.createInnerAudioContext();//播放音频实例
|
|
|
export default {
|
|
|
components:{
|
|
|
- noAuth
|
|
|
+ noAuth,
|
|
|
+ audioBox
|
|
|
},
|
|
|
filters:{
|
|
|
formatTime(e){
|
|
@@ -95,9 +102,42 @@ export default {
|
|
|
return `${m>9?m:'0'+m}:${s>9?s:'0'+s}`
|
|
|
}
|
|
|
},
|
|
|
+ computed:{
|
|
|
+ showAudioPop(){//是否显示音频弹窗
|
|
|
+ return this.$store.state.audio.show
|
|
|
+ },
|
|
|
+ showAudioBigPop(){
|
|
|
+ return this.$store.state.audio.showBig
|
|
|
+ },
|
|
|
+ curVoiceId(){//当前正在播放的音频id
|
|
|
+ return this.$store.state.audio.voiceId
|
|
|
+ },
|
|
|
+ curAudioPaused(){//当前音频是否暂停状态
|
|
|
+ return this.$store.state.audio.paused
|
|
|
+ },
|
|
|
+
|
|
|
+ pagePaddingBot(){
|
|
|
+ let num=34
|
|
|
+ if(this.IsVoiceAdmin){
|
|
|
+ num=num+160
|
|
|
+ }else{
|
|
|
+ num=34
|
|
|
+ }
|
|
|
+ if(this.$store.state.audio.show){
|
|
|
+ if(this.$store.state.audio.showBig){
|
|
|
+ num=num+260
|
|
|
+ }else{
|
|
|
+ num=num+180
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ num=num+0
|
|
|
+ }
|
|
|
+
|
|
|
+ return num+'rpx'
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- // innerAudioContext:null,//播放音频实例
|
|
|
list:[],
|
|
|
page:1,
|
|
|
pageSize:20,
|
|
@@ -114,13 +154,7 @@ export default {
|
|
|
mainActiveIndex:0,
|
|
|
activeId:0,//选择的板块id
|
|
|
|
|
|
- temAudio:{
|
|
|
- paused:true,
|
|
|
- url:'',//临时音频地址
|
|
|
- duration:'',//时长
|
|
|
- id:0,
|
|
|
- curTime:''
|
|
|
- }
|
|
|
+ showPage:false,
|
|
|
}
|
|
|
},
|
|
|
onLoad(){
|
|
@@ -133,21 +167,13 @@ export default {
|
|
|
if(!this.isAuth){
|
|
|
this.getVoiceList()
|
|
|
}
|
|
|
- innerAudioContext=uni.createInnerAudioContext();
|
|
|
- this.listenAudio()
|
|
|
+ this.showPage=true
|
|
|
},
|
|
|
onHide(){
|
|
|
- innerAudioContext.destroy()
|
|
|
- this.temAudio.id=0
|
|
|
- this.temAudio.paused=true
|
|
|
- this.temAudio.curTime=''
|
|
|
+ this.showPage=false
|
|
|
},
|
|
|
onUnload(){
|
|
|
uni.$off('addVoiceSuccess')
|
|
|
- innerAudioContext.destroy()
|
|
|
- this.temAudio.id=0
|
|
|
- this.temAudio.paused=true
|
|
|
- this.temAudio.curTime=''
|
|
|
},
|
|
|
onShareAppMessage({from,target}) {
|
|
|
console.log(from,target);
|
|
@@ -306,6 +332,11 @@ export default {
|
|
|
message: '确定要删除该语音播报吗?',
|
|
|
confirmButtonText:'确定'
|
|
|
}).then(()=>{
|
|
|
+ if(this.temAudio.item&&this.temAudio.item.id==item.BroadcastId){
|
|
|
+ //删除的音频正好在播放则暂停
|
|
|
+ this.globalBgMusic.stop()
|
|
|
+ }
|
|
|
+
|
|
|
apiVoiceDel({broadcast_id:Number(item.BroadcastId)}).then(res=>{
|
|
|
if(res.code===200){
|
|
|
uni.showToast({
|
|
@@ -321,56 +352,24 @@ export default {
|
|
|
}).catch(()=>{})
|
|
|
},
|
|
|
|
|
|
+ //点击音频 播放或者暂停
|
|
|
handlePlay(item){
|
|
|
- if(this.temAudio.id==item.BroadcastId){
|
|
|
- if(innerAudioContext.paused){
|
|
|
- innerAudioContext.play()
|
|
|
+ if(this.$store.state.audio.voiceId==item.BroadcastId){
|
|
|
+ if(this.globalBgMusic.paused){
|
|
|
+ this.globalBgMusic.play()
|
|
|
}else{
|
|
|
- innerAudioContext.pause()
|
|
|
+ this.globalBgMusic.pause()
|
|
|
}
|
|
|
}else{
|
|
|
- if(!innerAudioContext.paused){
|
|
|
- innerAudioContext.stop()
|
|
|
- }
|
|
|
- this.temAudio.id=item.BroadcastId
|
|
|
- this.temAudio.duration=item.VoicePlaySeconds
|
|
|
- this.temAudio.curTime=item.VoicePlaySeconds
|
|
|
- innerAudioContext.src=item.VoiceUrl
|
|
|
- innerAudioContext.obeyMuteSwitch=false
|
|
|
- innerAudioContext.play()
|
|
|
+ const list=[{url:item.VoiceUrl,time:item.VoicePlaySeconds,title:item.BroadcastName,}]
|
|
|
+ this.$store.commit('audio/addAudio',{
|
|
|
+ list:list,
|
|
|
+ voiceId:item.BroadcastId
|
|
|
+ })
|
|
|
this.handleVoicePlayRecord(item)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- //音频播放事件
|
|
|
- listenAudio(){
|
|
|
- innerAudioContext.onPlay(()=>{
|
|
|
- console.log('开始播放录音');
|
|
|
- this.temAudio.paused=false
|
|
|
- })
|
|
|
- innerAudioContext.onPause(()=>{
|
|
|
- console.log('录音播放暂停');
|
|
|
- this.temAudio.paused=true
|
|
|
- })
|
|
|
- // innerAudioContext.onStop(()=>{
|
|
|
- // console.log('录音播放停止');
|
|
|
- // this.temAudio.paused=true
|
|
|
- // // setTimeout(() => {
|
|
|
- // this.temAudio.id=0
|
|
|
- // // }, 100);
|
|
|
- // })
|
|
|
- innerAudioContext.onEnded(()=>{
|
|
|
- console.log('录音播放自然结束');
|
|
|
- this.temAudio.paused=true
|
|
|
- this.temAudio.id=0
|
|
|
-
|
|
|
- })
|
|
|
- innerAudioContext.onTimeUpdate(()=>{
|
|
|
- // console.log('时间更新');
|
|
|
- this.temAudio.curTime=parseInt(this.temAudio.duration)-parseInt(innerAudioContext.currentTime)
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
//上报音频播放记录
|
|
|
async handleVoicePlayRecord(item){
|
|
|
const res=await apiVoicePlayRecord({
|
|
@@ -415,17 +414,7 @@ export default {
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
.voice-play-page{
|
|
|
-
|
|
|
.top-filter-box{
|
|
|
- // padding-left: 34rpx;
|
|
|
- // padding-bottom: 10rpx;
|
|
|
- // position: sticky;
|
|
|
- // top: 0;
|
|
|
- // left: 0;
|
|
|
- // z-index: 99;
|
|
|
- // background-color: #fff;
|
|
|
- // display: flex;
|
|
|
- // align-items: center;
|
|
|
display: flex;
|
|
|
flex: auto;
|
|
|
align-items: center;
|
|
@@ -547,11 +536,24 @@ export default {
|
|
|
color: #E3B377;
|
|
|
font-size: 32rpx;
|
|
|
left: 50%;
|
|
|
- bottom: calc(80px + constant(safe-area-inset-bottom));
|
|
|
- bottom: calc(80px + env(safe-area-inset-bottom));
|
|
|
+ bottom: calc(150rpx + constant(safe-area-inset-bottom));
|
|
|
+ bottom: calc(150rpx + env(safe-area-inset-bottom));
|
|
|
transform: translateX(-50%);
|
|
|
background: #333333;
|
|
|
box-shadow: 0px 4rpx 20rpx rgba(160, 126, 84, 0.25);
|
|
|
border-radius: 40rpx;
|
|
|
}
|
|
|
+.add-btn-bot1{
|
|
|
+ bottom: calc(120rpx + constant(safe-area-inset-bottom));
|
|
|
+ bottom: calc(120rpx + env(safe-area-inset-bottom));
|
|
|
+}
|
|
|
+.add-btn-bot2{
|
|
|
+ bottom: calc(260rpx + constant(safe-area-inset-bottom));
|
|
|
+ bottom: calc(260rpx + env(safe-area-inset-bottom));
|
|
|
+}
|
|
|
+.add-btn-bot3{
|
|
|
+ bottom: calc(355rpx + constant(safe-area-inset-bottom));
|
|
|
+ bottom: calc(355rpx + env(safe-area-inset-bottom));
|
|
|
+}
|
|
|
+
|
|
|
</style>
|