|
@@ -12,17 +12,16 @@
|
|
/>
|
|
/>
|
|
<view>暂无数据</view>
|
|
<view>暂无数据</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">
|
|
<view class="item" v-for="item in list" :key="item.BroadcastId">
|
|
<view class="title">{{item.BroadcastName}}</view>
|
|
<view class="title">{{item.BroadcastName}}</view>
|
|
<view class="time">发布时间:{{item.CreateTime|formatTime}}</view>
|
|
<view class="time">发布时间:{{item.CreateTime|formatTime}}</view>
|
|
<view class="flex audio-box" @click="handlePlay(item)">
|
|
<view class="flex audio-box" @click="handlePlay(item)">
|
|
<image
|
|
<image
|
|
- :src="item.BroadcastId==temAudio.id&&!temAudio.paused?require('@/static/voice/playing.png'):require('@/static/voice/pause.png')"
|
|
|
|
|
|
+ :src="item.VoiceUrl==curVoiceUrl&&item.BroadcastId==curVoiceId&&temAudio.play?require('@/static/voice/playing.png'):require('@/static/voice/pause.png')"
|
|
mode="widthFix"
|
|
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>
|
|
</view>
|
|
<image class="del-btn" src="@/static/voice/del.png" @click="handleDelItem(item)" mode="widthFix" v-if="item.IsAuthor" />
|
|
<image class="del-btn" src="@/static/voice/del.png" @click="handleDelItem(item)" mode="widthFix" v-if="item.IsAuthor" />
|
|
<button
|
|
<button
|
|
@@ -36,7 +35,7 @@
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<navigator url="/pages-voice/addVoice">
|
|
<navigator url="/pages-voice/addVoice">
|
|
- <view class="add-btn" v-if="IsVoiceAdmin">新建语音</view>
|
|
|
|
|
|
+ <view class="add-btn" :style="{bottom:temAudio.item?temAudio.showBig?'440rpx':'340rpx':'180rpx'}" v-if="IsVoiceAdmin">新建语音</view>
|
|
</navigator>
|
|
</navigator>
|
|
|
|
|
|
<!-- 筛选弹窗 -->
|
|
<!-- 筛选弹窗 -->
|
|
@@ -64,6 +63,15 @@
|
|
</view>
|
|
</view>
|
|
</van-popup>
|
|
</van-popup>
|
|
|
|
|
|
|
|
+ <!-- 音频悬浮 -->
|
|
|
|
+ <voiceBox
|
|
|
|
+ @stateChange="handleVoiceStateChange"
|
|
|
|
+ @popChange="handleVoicePopChange"
|
|
|
|
+ @closeVoice="handleCloseVoice"
|
|
|
|
+ :voiceData="temAudio.item"
|
|
|
|
+ v-if="temAudio.item"
|
|
|
|
+ />
|
|
|
|
+
|
|
<van-dialog id="van-dialog" />
|
|
<van-dialog id="van-dialog" />
|
|
</view>
|
|
</view>
|
|
<noAuth :info="noAuthData" v-else/>
|
|
<noAuth :info="noAuthData" v-else/>
|
|
@@ -73,11 +81,12 @@
|
|
import {apiVoiceList,apiVoiceSectionList,apiVoicePlayRecord,apiVoiceDel} from '@/api/voice'
|
|
import {apiVoiceList,apiVoiceSectionList,apiVoicePlayRecord,apiVoiceDel} from '@/api/voice'
|
|
import {apiGetSceneToParams} from '@/api/common'
|
|
import {apiGetSceneToParams} from '@/api/common'
|
|
import noAuth from './components/noAuth.vue'
|
|
import noAuth from './components/noAuth.vue'
|
|
|
|
+import voiceBox from '@/components/voiceBox/voiceBox.vue'
|
|
const moment=require('@/utils/moment-with-locales.min')
|
|
const moment=require('@/utils/moment-with-locales.min')
|
|
-let innerAudioContext = uni.createInnerAudioContext();//播放音频实例
|
|
|
|
export default {
|
|
export default {
|
|
components:{
|
|
components:{
|
|
- noAuth
|
|
|
|
|
|
+ noAuth,
|
|
|
|
+ voiceBox
|
|
},
|
|
},
|
|
filters:{
|
|
filters:{
|
|
formatTime(e){
|
|
formatTime(e){
|
|
@@ -89,9 +98,35 @@ export default {
|
|
return `${m>9?m:'0'+m}:${s>9?s:'0'+s}`
|
|
return `${m>9?m:'0'+m}:${s>9?s:'0'+s}`
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ computed:{
|
|
|
|
+ curVoiceUrl(){
|
|
|
|
+ return this.temAudio.item&&this.temAudio.item.url||""
|
|
|
|
+ },
|
|
|
|
+ curVoiceId(){
|
|
|
|
+ return this.temAudio.item&&this.temAudio.item.id||""
|
|
|
|
+ },
|
|
|
|
+ pagePaddingBot(){
|
|
|
|
+ let num=34
|
|
|
|
+ if(this.IsVoiceAdmin){
|
|
|
|
+ num=num+160
|
|
|
|
+ }else{
|
|
|
|
+ num=34
|
|
|
|
+ }
|
|
|
|
+ if(this.temAudio.item){
|
|
|
|
+ if(this.temAudio.showBig){
|
|
|
|
+ num=num+260
|
|
|
|
+ }else{
|
|
|
|
+ num=num+180
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ num=num+0
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return num+'rpx'
|
|
|
|
+ }
|
|
|
|
+ },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- // innerAudioContext:null,//播放音频实例
|
|
|
|
list:[],
|
|
list:[],
|
|
page:1,
|
|
page:1,
|
|
pageSize:20,
|
|
pageSize:20,
|
|
@@ -109,11 +144,9 @@ export default {
|
|
activeId:0,//选择的板块id
|
|
activeId:0,//选择的板块id
|
|
|
|
|
|
temAudio:{
|
|
temAudio:{
|
|
- paused:true,
|
|
|
|
- url:'',//临时音频地址
|
|
|
|
- duration:'',//时长
|
|
|
|
- id:0,
|
|
|
|
- curTime:''
|
|
|
|
|
|
+ item:null,
|
|
|
|
+ play:false,
|
|
|
|
+ showBig:false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -127,21 +160,9 @@ export default {
|
|
if(!this.isAuth){
|
|
if(!this.isAuth){
|
|
this.getVoiceList()
|
|
this.getVoiceList()
|
|
}
|
|
}
|
|
- innerAudioContext=uni.createInnerAudioContext();
|
|
|
|
- this.listenAudio()
|
|
|
|
- },
|
|
|
|
- onHide(){
|
|
|
|
- innerAudioContext.destroy()
|
|
|
|
- this.temAudio.id=0
|
|
|
|
- this.temAudio.paused=true
|
|
|
|
- this.temAudio.curTime=''
|
|
|
|
},
|
|
},
|
|
onUnload(){
|
|
onUnload(){
|
|
uni.$off('addVoiceSuccess')
|
|
uni.$off('addVoiceSuccess')
|
|
- innerAudioContext.destroy()
|
|
|
|
- this.temAudio.id=0
|
|
|
|
- this.temAudio.paused=true
|
|
|
|
- this.temAudio.curTime=''
|
|
|
|
},
|
|
},
|
|
onShareAppMessage({from,target}) {
|
|
onShareAppMessage({from,target}) {
|
|
console.log(from,target);
|
|
console.log(from,target);
|
|
@@ -303,53 +324,38 @@ export default {
|
|
}).catch(()=>{})
|
|
}).catch(()=>{})
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ //点击音频 播放或者暂停
|
|
handlePlay(item){
|
|
handlePlay(item){
|
|
- if(this.temAudio.id==item.BroadcastId){
|
|
|
|
- if(innerAudioContext.paused){
|
|
|
|
- innerAudioContext.play()
|
|
|
|
- }else{
|
|
|
|
- innerAudioContext.pause()
|
|
|
|
|
|
+ if(!this.temAudio.item||this.temAudio.item.id!=item.BroadcastId){
|
|
|
|
+ this.temAudio.item={
|
|
|
|
+ title:item.BroadcastName,
|
|
|
|
+ duration:item.VoicePlaySeconds,
|
|
|
|
+ url:item.VoiceUrl,
|
|
|
|
+ id:item.BroadcastId
|
|
}
|
|
}
|
|
|
|
+ this.handleVoicePlayRecord(item)
|
|
}else{
|
|
}else{
|
|
- if(!innerAudioContext.paused){
|
|
|
|
- innerAudioContext.stop()
|
|
|
|
|
|
+ if(this.globalBgMusic.paused){
|
|
|
|
+ this.globalBgMusic.play()
|
|
|
|
+ }else{
|
|
|
|
+ this.globalBgMusic.pause()
|
|
}
|
|
}
|
|
- this.temAudio.id=item.BroadcastId
|
|
|
|
- this.temAudio.duration=item.VoicePlaySeconds
|
|
|
|
- this.temAudio.curTime=item.VoicePlaySeconds
|
|
|
|
- innerAudioContext.src=item.VoiceUrl
|
|
|
|
- innerAudioContext.play()
|
|
|
|
- this.handleVoicePlayRecord(item)
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ //关闭音频
|
|
|
|
+ handleCloseVoice(){
|
|
|
|
+ this.temAudio.item=null
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ //音频播放状态
|
|
|
|
+ handleVoiceStateChange(e){
|
|
|
|
+ this.temAudio.play=e
|
|
},
|
|
},
|
|
|
|
|
|
- //音频播放事件
|
|
|
|
- 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)
|
|
|
|
- })
|
|
|
|
|
|
+ //音频弹窗大小变化
|
|
|
|
+ handleVoicePopChange(e){
|
|
|
|
+ this.temAudio.showBig=e
|
|
},
|
|
},
|
|
|
|
|
|
//上报音频播放记录
|
|
//上报音频播放记录
|
|
@@ -396,17 +402,7 @@ export default {
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
.voice-play-page{
|
|
.voice-play-page{
|
|
-
|
|
|
|
.top-filter-box{
|
|
.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;
|
|
display: flex;
|
|
flex: auto;
|
|
flex: auto;
|
|
align-items: center;
|
|
align-items: center;
|
|
@@ -507,4 +503,5 @@ export default {
|
|
box-shadow: 0px 4rpx 20rpx rgba(160, 126, 84, 0.25);
|
|
box-shadow: 0px 4rpx 20rpx rgba(160, 126, 84, 0.25);
|
|
border-radius: 40rpx;
|
|
border-radius: 40rpx;
|
|
}
|
|
}
|
|
|
|
+
|
|
</style>
|
|
</style>
|