提交 a673bdf9 编写于 作者: haochangdi's avatar haochangdi

优化视频音频逻辑

上级 6211a27e
...@@ -44,6 +44,13 @@ export const laseTime = (endtime) => { ...@@ -44,6 +44,13 @@ export const laseTime = (endtime) => {
} }
} }
export const lastm = (startTime,endTime) => {
let time = endTime - startTime; //距离结束时间的毫秒数
let lefth = Math.floor(time / (1000 * 60 * 60) % 24); //计算小时数
let leftm = Math.floor(time / (1000 * 60) % 60); //计算分钟数
return lefth * 60 + leftm
}
function listCompare(property, way) { function listCompare(property, way) {
return function (obj1, obj2) { return function (obj1, obj2) {
var value1 = obj1[property]; var value1 = obj1[property];
......
...@@ -162,6 +162,7 @@ class RtcClient { ...@@ -162,6 +162,7 @@ class RtcClient {
await this.client_.leave(); await this.client_.leave();
if (this.localStream_) { if (this.localStream_) {
this.muteLocalAudio()
this.localStream_.stop(); this.localStream_.stop();
this.localStream_.close(); this.localStream_.close();
this.localStream_ = null; this.localStream_ = null;
...@@ -306,7 +307,12 @@ class RtcClient { ...@@ -306,7 +307,12 @@ class RtcClient {
setTimeout(() => { setTimeout(() => {
// 避免其他乱入视频 // 避免其他乱入视频
let index = this.viewslist.findIndex((item => { let index = this.viewslist.findIndex((item => {
return item.userId == uid if (item && item.userId) {
return item.userId == uid
} else {
return -1
}
})) }))
if (index < 0) { if (index < 0) {
return return
......
...@@ -344,6 +344,7 @@ export default { ...@@ -344,6 +344,7 @@ export default {
}, },
// 加入问诊 // 加入问诊
jionCommunicate(row) { jionCommunicate(row) {
this.clearSession()
this.$router.push({path: '/diagnosis-live', query: {tid: row.imTeamId, diagnoseLogId: row.diagnoseLogId}}) this.$router.push({path: '/diagnosis-live', query: {tid: row.imTeamId, diagnoseLogId: row.diagnoseLogId}})
}, },
// 发送消息 // 发送消息
...@@ -378,6 +379,13 @@ export default { ...@@ -378,6 +379,13 @@ export default {
handleCurrentChange(value) { handleCurrentChange(value) {
this.searchParam.pageNo = value this.searchParam.pageNo = value
this.search() this.search()
},
// 清除直播时间相关的seession
clearSession() {
sessionStorage.removeItem('TIME_askTime')
sessionStorage.removeItem('TIME_answerTime')
sessionStorage.removeItem('TIME_useTime')
sessionStorage.removeItem('TIME_loseTime')
} }
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="top-left"> <div class="top-left">
<h1 class="title">{{title}}</h1> <h1 class="title">{{title}}</h1>
<div class="time-message"> <div class="time-message">
<p>设定时长: 30分钟</p> <p>设定时长: {{time}}分钟</p>
<p v-if="startTime && endTime">总时长: {{useTime}}</p> <p v-if="startTime && endTime">总时长: {{useTime}}</p>
<p v-if="startTime && endTime">剩余时长: {{loseTime}}</p> <p v-if="startTime && endTime">剩余时长: {{loseTime}}</p>
</div> </div>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</template> </template>
<script> <script>
import RtcClient from '@/utils/live/rtc-client.js' import RtcClient from '@/utils/live/rtc-client.js'
import { getLiveTimeText, countDown, getBroswer, laseTime } from '@/utils/live' import { getLiveTimeText, countDown, getBroswer, laseTime, lastm } from '@/utils/live'
import { openLoading, closeLoading } from "@/utils/utils"; import { openLoading, closeLoading } from "@/utils/utils";
import alert from '@/components/common/alert.vue' import alert from '@/components/common/alert.vue'
export default { export default {
...@@ -80,6 +80,7 @@ export default { ...@@ -80,6 +80,7 @@ export default {
type: 2, // 1: 语音 2: 视频 type: 2, // 1: 语音 2: 视频
startTime: 0, startTime: 0,
endTime: 0, endTime: 0,
time: 30, //总时长
memberList: [], memberList: [],
tid: '', // 群id tid: '', // 群id
diagnoseLogId: '' //问诊id diagnoseLogId: '' //问诊id
...@@ -127,6 +128,7 @@ export default { ...@@ -127,6 +128,7 @@ export default {
if (liveInfo) { if (liveInfo) {
this.startTime = liveInfo.startTimestamp this.startTime = liveInfo.startTimestamp
this.endTime = liveInfo.endTimestamp this.endTime = liveInfo.endTimestamp
this.time = lastm(this.startTime,this.endTime)
this.roomId = Number(liveInfo.roomId) this.roomId = Number(liveInfo.roomId)
this.type = liveInfo.liveType this.type = liveInfo.liveType
} }
...@@ -140,7 +142,7 @@ export default { ...@@ -140,7 +142,7 @@ export default {
if (item.role == 2) { if (item.role == 2) {
this.memberList[1] = Object.assign(item,{status: 1}) this.memberList[1] = Object.assign(item,{status: 1})
} }
if (item.role == 2) { if (item.role == 4) {
this.userId = item.accId this.userId = item.accId
} }
}) })
...@@ -330,7 +332,8 @@ export default { ...@@ -330,7 +332,8 @@ export default {
} }
let t = 0 let t = 0
let liveTime = Number(sessionStorage.getItem(`TIME_${text}`) || t) let liveTime = Number(sessionStorage.getItem(`TIME_${text}`) || t)
this[`${text}fn`] = setInterval(() => {
this[`${text}Fn`] = setInterval(() => {
liveTime += 1000 liveTime += 1000
this[text] = getLiveTimeText(liveTime,text) this[text] = getLiveTimeText(liveTime,text)
}, 1000); }, 1000);
...@@ -375,9 +378,8 @@ export default { ...@@ -375,9 +378,8 @@ export default {
}, },
// 结束会话 // 结束会话
overFn() { overFn() {
let url = `/diagnose/admin/diagnose/endCall`; let url = `/diagnose/admin/diagnose/endCall/${this.diagnoseLogId}`;
let params = { let params = {
diagnoseLogId: this.diagnoseLogId
}; };
this.POST(url,params).then(res => { this.POST(url,params).then(res => {
if (res.code == "000000") { if (res.code == "000000") {
...@@ -432,9 +434,18 @@ export default { ...@@ -432,9 +434,18 @@ export default {
location.reload(); location.reload();
}) })
}) })
},
clearTime() {
clearInterval(this.askTimeFn)
clearInterval(this.answerTimeFn)
clearInterval(this.useTimeFn)
clearInterval(this.loseTimeFn)
} }
}, },
destroyed() { beforeDestroy() {
console.log('===========this.askTimeFn=========================');
console.log(this.askTimeFn);
console.log('====================================');
clearInterval(this.askTimeFn) clearInterval(this.askTimeFn)
clearInterval(this.answerTimeFn) clearInterval(this.answerTimeFn)
clearInterval(this.useTimeFn) clearInterval(this.useTimeFn)
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册