|
@@ -10,6 +10,7 @@ import{ref,reactive} from "vue"
|
|
|
import {onBeforeRouteLeave,useRouter} from "vue-router"
|
|
|
import { useElementSize } from '@vueuse/core'
|
|
|
import {ElMessage,ElMessageBox} from "element-plus"
|
|
|
+import SelfList from '@/components/SelfList.vue'
|
|
|
import {useStore} from "vuex"
|
|
|
import moment from 'moment';
|
|
|
|
|
@@ -81,6 +82,7 @@ const getOptionList =async ()=>{
|
|
|
getQuestionList()
|
|
|
}
|
|
|
}
|
|
|
+getOptionList()
|
|
|
// 联系销售
|
|
|
const toContact = ()=>{
|
|
|
// 请求申请接口
|
|
@@ -196,7 +198,7 @@ const getQuestionList=()=>{
|
|
|
})
|
|
|
}
|
|
|
// 加载更多
|
|
|
-const loadingMore = ()=>{
|
|
|
+const onLoad = ()=>{
|
|
|
question.page_index++
|
|
|
getQuestionList()
|
|
|
}
|
|
@@ -250,86 +252,31 @@ const submit = (formEl)=>{
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// 点击播放/暂停按钮
|
|
|
-const audioPlay = (item,index)=>{
|
|
|
- if(item.audio_status.isPlay){
|
|
|
- pause(item,index)
|
|
|
- }else{
|
|
|
- if(question.currentClickId != item.audio_list[0].community_question_audio_id){
|
|
|
- question.currentClickId = item.audio_list[0].community_question_audio_id
|
|
|
- // 增加点击数
|
|
|
- apiCountAudioClick({
|
|
|
- community_question_audio_id:question.currentClickId
|
|
|
- }).then((res)=>{
|
|
|
- if(res.code===200){
|
|
|
- console.log('音频id为'+question.currentClickId+'点击次数+1')
|
|
|
- }
|
|
|
- })
|
|
|
+//播放音频
|
|
|
+const handlePlay=(item)=>{
|
|
|
+ if(store.state.audioData.questionId==item.community_question_id){
|
|
|
+ if(store.state.audioData.paused){
|
|
|
+ store.state.audioData.INS.play()
|
|
|
+ }else{
|
|
|
+ store.state.audioData.INS.pause()
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
- play(item,index)
|
|
|
- }
|
|
|
+ const audioItem=item.audio_list[0]
|
|
|
+ store.commit('addAudio',{
|
|
|
+ list:[{name:item.question_content,url:audioItem.audio_url,time:audioItem.audio_play_seconds}],
|
|
|
+ questionId:item.community_question_id,
|
|
|
+ index:0
|
|
|
+ })
|
|
|
+ apiCountAudioClick({
|
|
|
+ community_question_audio_id:audioItem.community_question_audio_id
|
|
|
+ }).then((res)=>{
|
|
|
+ if(res.code===200){
|
|
|
+ console.log('音频id为'+audioItem.community_question_audio_id+'点击次数+1')
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-// type: pause 暂停 end结束
|
|
|
-const pause=(item,index,type='pause')=>{
|
|
|
- audio.value[index].pause()
|
|
|
- clearInterval(timer)
|
|
|
- if(type == 'end'){
|
|
|
- audio.value[index].currentTime = 0
|
|
|
- item.audio_status.playedTime=0
|
|
|
- }
|
|
|
- item.audio_status.isPlay = false
|
|
|
- question.audioPlayingIndex=-1
|
|
|
- question.audioPlayingItem = null
|
|
|
- item.audio_status.loading = false
|
|
|
-}
|
|
|
-// 播放
|
|
|
-const play=(item,index)=>{
|
|
|
- if(audio.value[index].readyState!=4){
|
|
|
- item.audio_status.loading=true
|
|
|
- return
|
|
|
- }
|
|
|
- if( question.audioPlayingIndex!= -1 ){
|
|
|
- pause(question.audioPlayingItem,question.audioPlayingIndex,'end')
|
|
|
- }
|
|
|
- audio.value[index].play()
|
|
|
- question.audioPlayingIndex = index
|
|
|
- question.audioPlayingItem = item
|
|
|
- timer = setInterval(()=>{
|
|
|
- // 播放结束
|
|
|
- if(audio.value[index].ended){
|
|
|
- item.audio_status.playedTime = 0
|
|
|
- item.audio_status.isPlay = false
|
|
|
- question.audioPlayingIndex=-1
|
|
|
- question.audioPlayingItem = null
|
|
|
- question.currentClickId=0
|
|
|
- clearInterval(timer)
|
|
|
- return
|
|
|
- }
|
|
|
- item.audio_status.playedTime += 1000
|
|
|
- },1000)
|
|
|
- item.audio_status.isPlay = true
|
|
|
- item.audio_status.loading = false
|
|
|
-}
|
|
|
-// 等待 网络差时等待资源加载
|
|
|
-const audioWaiting = (item)=>{
|
|
|
- item.audio_status.loading = true
|
|
|
-}
|
|
|
-// 可以播放
|
|
|
-const audioCanPlay = (item,index)=>{
|
|
|
- console.log(item,index)
|
|
|
- item.audio_status.loading = false
|
|
|
- if(!audio.value[index].played){
|
|
|
- play(item,index)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-getOptionList()
|
|
|
-onBeforeRouteLeave(()=>{
|
|
|
- if( question.audioPlayingIndex!= -1 ){
|
|
|
- pause(question.audioPlayingItem,question.audioPlayingIndex,'end')
|
|
|
- }
|
|
|
-})
|
|
|
|
|
|
</script>
|
|
|
|
|
@@ -394,13 +341,14 @@ onBeforeRouteLeave(()=>{
|
|
|
</el-popover>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <!-- 无数据 -->
|
|
|
- <div class="question-noData" v-show="question.list.length==0 && !question.isLoading">
|
|
|
- <img :src="$store.state.globalImgUrls.activityNoAuth" alt="没有数据">
|
|
|
- <span>暂无数据</span>
|
|
|
- </div>
|
|
|
- <div class="question-list" v-show = "question.list.length>0 && question.isFinish">
|
|
|
- <div class="question-item" v-for="(item,index) in question.list" :key="item.community_question_id">
|
|
|
+ <SelfList
|
|
|
+ :finished="question.isTotalData"
|
|
|
+ :isEmpty="question.list.length===0&&question.isTotalData"
|
|
|
+ :loading="question.isLoading"
|
|
|
+ @listOnload="onLoad"
|
|
|
+ >
|
|
|
+ <div class="question-list">
|
|
|
+ <div class="question-item" v-for="item in question.list" :key="item.community_question_id">
|
|
|
<div class="question-info">
|
|
|
<div class="label">{{item.research_group_second_name}}</div>
|
|
|
{{item.question_content}}
|
|
@@ -408,37 +356,26 @@ onBeforeRouteLeave(()=>{
|
|
|
<div class="question-time">
|
|
|
提问时间:{{moment(item.create_time).format('YYYY.MM.DD')}}
|
|
|
</div>
|
|
|
- <div class="question-audio">
|
|
|
- <audio :autoplay="false" :loop="false" preload ref="audio"
|
|
|
- @waiting="audioWaiting(item,index)" @canplay="audioCanPlay(item,index)">
|
|
|
- <source :src="item.audio_list[0].audio_url" type="audio/mp3" />
|
|
|
- <p>你的浏览器不支持 HTML5 音频,请直接下载<a :href="item.audio_list[0].audio_url">音频文件</a>。</p>
|
|
|
- </audio>
|
|
|
- <div class="audio-icon" @click="audioPlay(item,index)" v-if="!item.audio_status.loading">
|
|
|
- <img src="@/assets/recordplay.png" alt="播放" v-show="!item.audio_status.isPlay" />
|
|
|
- <img src="@/assets/recordpause.png" alt="暂停" v-show="item.audio_status.isPlay" />
|
|
|
- </div>
|
|
|
- <div class="audio-icon loading-icon" @click="pause(item,index)" v-else>
|
|
|
- <img class="load-img" src="@/assets/loading.png" alt="加载中">
|
|
|
- </div>
|
|
|
+ <div class="question-audio" @click="handlePlay(item)">
|
|
|
+ <div :class="['audio-icon',($store.state.audioData.questionId==item.community_question_id)&&!$store.state.audioData.paused?'active':'']"></div>
|
|
|
<div class="audio-pic">
|
|
|
<img src="@/assets/audio-waveform1.png">
|
|
|
<img src="@/assets/audio-waveform2.png">
|
|
|
</div>
|
|
|
- <div class="audio-time">{{moment((item.audio_status.audioTime - item.audio_status.playedTime)).format('mm:ss')}}</div>
|
|
|
+ <div class="audio-time">{{moment(item.audio_status.audioTime).format('mm:ss')}}</div>
|
|
|
</div>
|
|
|
-
|
|
|
<!-- 点赞/评论 -->
|
|
|
<QuestionComment :item="item"/>
|
|
|
</div>
|
|
|
- <div class="bottom-tip-contain">
|
|
|
- <div class="bottom-tip-loadMore" v-show="!question.isTotalData && !question.isLoading" @click="loadingMore">加载更多</div>
|
|
|
- <div class="loading-text" v-show="question.isLoading">加载中······</div>
|
|
|
- <div class="bottom-tip-noMore" v-show="question.isTotalData && !question.isLoading">没有更多了~</div>
|
|
|
- </div>
|
|
|
</div>
|
|
|
- <el-dialog title="提问详情" v-model="question.showAskDia" :close-on-click-modal="false" draggable
|
|
|
- :width="600" >
|
|
|
+ </SelfList>
|
|
|
+ <el-dialog
|
|
|
+ title="提问详情"
|
|
|
+ v-model="question.showAskDia"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ draggable
|
|
|
+ :width="600"
|
|
|
+ >
|
|
|
<el-form :model="question.askForm" ref="askForm" class="ask-form">
|
|
|
<div class="ask-label">
|
|
|
问题描述
|
|
@@ -661,20 +598,12 @@ onBeforeRouteLeave(()=>{
|
|
|
padding: 0 54px 0 27px;
|
|
|
.audio-icon{
|
|
|
cursor: pointer;
|
|
|
- img{
|
|
|
- width: 16px;
|
|
|
- }
|
|
|
- .load-img{
|
|
|
- width: 20px;
|
|
|
- animation: circle 0.5s linear infinite;
|
|
|
- }
|
|
|
- @keyframes circle {
|
|
|
- 0%{
|
|
|
- transform: rotateZ(0);
|
|
|
- }
|
|
|
- 100%{
|
|
|
- transform: rotateZ(360deg);
|
|
|
- }
|
|
|
+ width: 16px;
|
|
|
+ height: 19.5px;
|
|
|
+ background-size: cover;
|
|
|
+ background-image: url('@/assets/recordplay.png');
|
|
|
+ &.active{
|
|
|
+ background-image: url('@/assets/recordpause.png');
|
|
|
}
|
|
|
}
|
|
|
.audio-pic{
|