Commit 1f5770ae by 程智春

直播优化

parent c3309530
...@@ -78,12 +78,17 @@ export default { ...@@ -78,12 +78,17 @@ export default {
overflow: hidden; overflow: hidden;
bottom: 0; bottom: 0;
padding-left: 10px; padding-left: 10px;
background-color: rgba(0,0,0,0.3);
.item { .item {
width: 50vw; width: 50vw;
padding: 4px 0; padding: 4px 0;
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
line-height: 18px;
border-radius: 9px;
background-color: rgba(0,0,0,0.3);
margin-bottom: 4px;
padding-left: 8px;
box-sizing: border-box;
.user { .user {
.name { .name {
color: #f9a93c; color: #f9a93c;
......
...@@ -63,15 +63,21 @@ export default { ...@@ -63,15 +63,21 @@ export default {
position: relative; position: relative;
width: 60vw; width: 60vw;
.list { .list {
width: 60vw; width: 50vw;
max-height: 24vh;
overflow: hidden; overflow: hidden;
bottom: 0; bottom: 0;
padding-left: 10px;
.item { .item {
width: 60vw; width: 50vw;
padding: 4px 0; padding: 4px 0;
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
line-height: 18px;
border-radius: 9px;
background-color: rgba(0,0,0,0.3);
margin-bottom: 4px;
padding-left: 8px;
box-sizing: border-box;
.user { .user {
.name { .name {
color: #f9a93c; color: #f9a93c;
......
...@@ -75,6 +75,8 @@ export default { ...@@ -75,6 +75,8 @@ export default {
} }
}); });
} }
}else{
console.log('开播失败')
} }
} catch (err) { } catch (err) {
console.error("subscribeMessage-err", err); console.error("subscribeMessage-err", err);
......
...@@ -442,46 +442,70 @@ export default { ...@@ -442,46 +442,70 @@ export default {
if(res.data.code == '200'){ if(res.data.code == '200'){
let result = res.data.data let result = res.data.data
result.coverUrl = DFSImg(result.coverUrl)
result.logoUrl = DFSImg(result.logoUrl)
this.liveInfo = result;
this.tuiStream = result.tuiStream
if(result.liveBroadcastState == 0){
this.isLive = false
this.isBgImg = true;
this.noStartLive = true;
}else if(result.liveBroadcastState == 1){
this.enableCamera = true
this.isLive = true
this.isBgImg = false;
}else if(result.liveBroadcastState == 3){
console.log('llll')
this.recoverLive = true;
this.isUsual = true;
this.isBgImg = true;
}
if(result.realStartTime){ if(result){
this.realStartTime = Math.floor((new Date().getTime() - new Date(result.realStartTime.replace(/-/g, '/').replace(/-/g, '/')).getTime())/1000)
result.coverUrl = DFSImg(result.coverUrl)
result.logoUrl = DFSImg(result.logoUrl)
this.liveInfo = result;
this.tuiStream = result.tuiStream
if(result.liveBroadcastState == 0){
this.isLive = false
this.isBgImg = true;
this.noStartLive = true;
}else if(result.liveBroadcastState == 1){
this.enableCamera = true
this.isLive = true
this.isBgImg = false;
}else if(result.liveBroadcastState == 3){
console.log('llll')
this.recoverLive = true;
this.isUsual = true;
this.isBgImg = true;
}
}else{ if(result.realStartTime){
this.realStartTime = 0 this.realStartTime = Math.floor((new Date().getTime() - new Date(result.realStartTime.replace(/-/g, '/').replace(/-/g, '/')).getTime())/1000)
}
}else{
this.realStartTime = 0
}
// this.getLiveTimeHandler(result.startTime)
// clearInterval(this.openLiveTimer)
// this.openLiveTimer = setInterval(() => {
this.getLiveTimeHandler(result.startTime) this.getLiveTimeHandler(result.startTime)
// },5000)
// this.getProductList(); //获取商品列表
// this.getProductTimer = setInterval(() => {
this.getProductList(); //获取商品列表 this.getProductList(); //获取商品列表
// },30000)
}else{
wx.showModal({
title: '提示',
content: '直播已关闭',
success (res3) {
if (res3.confirm) {
wx.reLaunch({url:`../liveList/main`})
} else if (res3.cancel) {
console.log('用户点击取消')
}
}
})
}
}else if(res.data.code == '-1'){
wx.showModal({
title: '提示',
content: '直播已关闭',
success (res3) {
if (res3.confirm) {
wx.reLaunch({url:`../liveList/main`})
} else if (res3.cancel) {
console.log('用户点击取消')
}
}
})
} }
}) })
} }
...@@ -504,13 +528,13 @@ export default { ...@@ -504,13 +528,13 @@ export default {
day = Math.floor(getTimeAbs / (3600*1000*24)) day = Math.floor(getTimeAbs / (3600*1000*24))
hours = Math.floor((getTimeAbs%(24*3600*1000))/(3600*1000)); hours = Math.floor((getTimeAbs%(24*3600*1000))/(3600*1000));
minute = Math.ceil((getTimeAbs%(24*3600*1000)%(3600*1000) )/(60*1000)) minute = Math.floor((getTimeAbs%(24*3600*1000)%(3600*1000) )/(60*1000))
if(getTime > 0){ if(getTime > 0){
if(day > 0){ if(day > 0){
this.liveTime = `${day >= 10 ? day : '0' + day}${hours >= 10 ? hours : '0' + hours}小时${minute >= 10 ? minute : '0' + minute}分` this.liveTime = `${day >= 10 ? day : '0' + day}${hours >= 10 ? hours : '0' + hours}小时${minute >= 10 ? minute : '0' + minute}分`
}else if(day <= 0 && hours > 0){ }else if(day <= 0 && hours > 0){
this.liveTime = `${hours >= 10 ? hours : '0' + hours}小时${minute >= 10 ? minute : '0' + minute}分` this.liveTime = `${hours >= 10 ? hours : '0' + hours}小时${minute >= 10 ? minute : '0' + minute}分`
}else if(day <= 0 && hours <= 0 && minute > 0){ }else if(day <= 0 && hours <= 0 && minute >= 0){
this.liveTime = `${minute >= 10 ? minute : '0' + minute}分` this.liveTime = `${minute >= 10 ? minute : '0' + minute}分`
} }
...@@ -547,7 +571,7 @@ export default { ...@@ -547,7 +571,7 @@ export default {
if(res2.data.data.liveBroadcastState == 4 || res2.data.data.liveBroadcastState == 2){ if(res2.data.data.liveBroadcastState == 4 || res2.data.data.liveBroadcastState == 2){
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: '直播超时已关闭', content: '直播已关闭',
success (res3) { success (res3) {
if (res3.confirm) { if (res3.confirm) {
wx.reLaunch({url:`../liveList/main`}) wx.reLaunch({url:`../liveList/main`})
......
...@@ -81,6 +81,7 @@ import { getNavbarInfo,DFSImg } from '../../utils/common.js' ...@@ -81,6 +81,7 @@ import { getNavbarInfo,DFSImg } from '../../utils/common.js'
import { wx_decode } from "@/utils/wxIndex.js"; import { wx_decode } from "@/utils/wxIndex.js";
import login from "@/api/login"; import login from "@/api/login";
import indexApi from '@/api/liveing' import indexApi from '@/api/liveing'
import liveApi from '@/api/liveing'
export default { export default {
data(){ data(){
return{ return{
...@@ -171,22 +172,56 @@ export default { ...@@ -171,22 +172,56 @@ export default {
}, },
//去直播间 //去直播间
toLive(id){ toLive(id){
let openId = '';
this.liveList.forEach(item => { liveApi.queryLiveDetail({id}).then(res => {
if(item.liveBroadcastState == 3 || item.liveBroadcastState == 1){ console.log(res.data)
openId = item.id if(res.data.code == '200'){
} if(res.data.data){
}) let openId = '';
if(openId){ this.liveList.forEach(item => {
if(openId == id){ if(item.liveBroadcastState == 3 || item.liveBroadcastState == 1){
wx.navigateTo({url:'../live/main?id=' + id}) openId = item.id
}
})
if(openId){
if(openId == id){
wx.navigateTo({url:'../live/main?id=' + id})
}else{
wx.showToast({ title: '同时只能开播一个直播间', icon: "none" });
}
}else{
wx.navigateTo({url:'../live/main?id=' + id})
}
}else{
wx.showModal({
title: '提示',
content: '直播已关闭',
success : (res3) => {
if (res3.confirm) {
this.getLiveList()
} else if (res3.cancel) {
console.log('用户点击取消')
}
}
})
}
}else{ }else{
wx.showToast({ title: '同时只能开播一个直播间', icon: "none" }); wx.showModal({
title: '提示',
content: '直播已关闭',
success : (res3) => {
if (res3.confirm) {
this.getLiveList()
} else if (res3.cancel) {
console.log('用户点击取消')
}
}
})
} }
})
}else{
wx.navigateTo({url:'../live/main?id=' + id})
}
}, },
getUserInfo(e){ getUserInfo(e){
......
...@@ -415,8 +415,8 @@ export default { ...@@ -415,8 +415,8 @@ export default {
if(resData.guestBookList && resData.guestBookList.length){ if(resData.guestBookList && resData.guestBookList.length){
this.newCommentsTime = resData.guestBookList[resData.guestBookList.length - 1].createTimeStamp this.newCommentsTime = resData.guestBookList[resData.guestBookList.length - 1].createTimeStamp
} }
if(result.entryNoticeList && result.entryNoticeList.length){ if(resData.entryNoticeList && resData.entryNoticeList.length){
this.userActivebeginTime = result.entryNoticeList[result.entryNoticeList.length - 1].createTimeStamp this.userActivebeginTime = resData.entryNoticeList[resData.entryNoticeList.length - 1].createTimeStamp
} }
this.likeInfo = resData.likeInfo; //点赞信息 this.likeInfo = resData.likeInfo; //点赞信息
// 直播中且接口直播中---主要操作 // 直播中且接口直播中---主要操作
...@@ -432,7 +432,8 @@ export default { ...@@ -432,7 +432,8 @@ export default {
}人`; //用户进入 }人`; //用户进入
} }
} }
this.updateVal = Math.random(); //监听使用数据
this.updateVal = new Date().getTime(); //监听使用数据
} else { } else {
// if (this.infoTiming) { // if (this.infoTiming) {
// clearInterval(this.infoTiming); // clearInterval(this.infoTiming);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment