Commit c84d6adf by 程智春

直播

parent 11ac6472
......@@ -209,9 +209,13 @@ export default {
isTimeFirstReq : true, //第一次数据请求
isDetailLock : true, //查看详情锁
updateVal : 0,
overOrStop : 1, //是暂停还是结束
isDetailControlLock : true,
}
},
watch:{
......@@ -268,6 +272,7 @@ export default {
this.isTimeLock = true;
this.isTimeFirstReq = true;
this.overOrStop = 1;
this.isDetailLock = true;
this.online = 0 //在线
this.look = 0 //观看
......@@ -277,7 +282,10 @@ export default {
this.liveTime = '';
this.liveId = options.id;
this.getLiveDetail(options.id); //传入直播间id
this.getLiveDetail(options.id);
this.openLiveTimer = setInterval(() => {
this.getLiveDetail(options.id); //传入直播间id
},5000)
this.getServerTimeNow(); //获取服务器时间戳
......@@ -321,11 +329,6 @@ export default {
this.isSetBeauty = false;
}
}
// this.isSetBeauty = false;
},
onUnload(){
......@@ -396,6 +399,7 @@ export default {
this.recoverLive = false
this.isBgImg = false;
this.isSetBeauty = true;
this.isDetailControlLock = false;
this.pusher.startPreview()
},
showPopup(){
......@@ -427,50 +431,60 @@ export default {
},
//获取直播间详情
getLiveDetail(id){
liveApi.queryLiveDetail({id}).then(res => {
if(res.data.code == '200'){
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){
this.recoverLive = true;
this.isUsual = true;
this.isBgImg = true;
}
if(result.realStartTime){
this.realStartTime = Math.floor((new Date().getTime() - new Date(result.realStartTime.replace(/-/g, '/').replace(/-/g, '/')).getTime())/1000)
}else{
this.realStartTime = 0
}
console.log('获取',this.recoverLive)
if(this.isDetailLock && this.isDetailControlLock){
this.isDetailLock = false;
liveApi.queryLiveDetail({id}).then(res => {
this.isDetailLock = true;
if(res.data.code == '200'){
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){
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)
},5000)
this.getProductList(); //获取商品列表
this.getProductTimer = setInterval(() => {
this.getProductList(); //获取商品列表
},30000)
}
})
// this.getLiveTimeHandler(result.startTime)
// clearInterval(this.openLiveTimer)
// this.openLiveTimer = setInterval(() => {
this.getLiveTimeHandler(result.startTime)
// },5000)
// this.getProductList(); //获取商品列表
// this.getProductTimer = setInterval(() => {
this.getProductList(); //获取商品列表
// },30000)
}
})
}
},
//获取开播时间
getLiveTimeHandler(time){
......@@ -561,6 +575,7 @@ export default {
},
//开始直播
startLive(type){
this.isDetailControlLock = false;
if(type == 'recover'){
this.recoverLive = false;
this.isUsual = false;
......@@ -577,6 +592,7 @@ export default {
console.log('开始直播')
this.pusher.start(); //开始推流
this.isCountDown = false;
this.isDetailControlLock = true;
this.isSetBeauty = false;
clearInterval(timer)
this.changeLiveStatus(1);
......@@ -597,6 +613,7 @@ export default {
this.pusher.resume();
}else if(val == 3){
this.isLive = false;
console.log('222222')
this.recoverLive = true;
this.isBgImg = true;
this.enableCamera = false;
......@@ -613,6 +630,7 @@ export default {
this.isSetBeauty = val;
this.isBgImg = true;
this.enableCamera = false;
this.isDetailControlLock = true;
if(this.liveInfo.liveBroadcastState == 0){
this.noStartLive = true;
}else if(this.liveInfo.liveBroadcastState == 1){
......@@ -627,6 +645,7 @@ export default {
//定时查询数据
timeGetInfo(serverTime){
let newCommentsTime = serverTime
let userActivebeginTime = serverTime
clearInterval(this.liveDetailTimer)
this.liveDetailTimer = setInterval(() => {
......@@ -635,9 +654,11 @@ export default {
//第一次请求用服务器的时间减去2秒
this.isTimeLock = false;
let dataTime = this.isTimeFirstReq ? serverTime - 2000 : newCommentsTime
let userTime = this.isTimeFirstReq ? serverTime - 2000 : userActivebeginTime
liveApi.queryLiveComments({
id: Number(this.liveId),
beginTime: dataTime
beginTime: dataTime, //评论时间
userActivebeginTime : userTime, //用户进入时间
}).then(res => {
if(res.data.code == '200'){
this.isTimeFirstReq = false;
......@@ -655,9 +676,9 @@ export default {
}${result.entryNoticeList.length}人`;//用户进入
}
}
//在线
this.look = result.historyWatchNum;
//观看
this.look = result.historyWatchNum;
//在线
this.online = result.watchNum
//点赞
this.praise = result.likeInfo.likeNum
......@@ -669,6 +690,10 @@ export default {
newCommentsTime = result.guestBookList[result.guestBookList.length - 1].createTimeStamp
}
if(result.entryNoticeList && result.entryNoticeList.length){
userActivebeginTime = result.entryNoticeList[result.entryNoticeList.length - 1].createTimeStamp
}
this.updateVal = new Date().getTime(); //监听使用数据
}
}
......
<template>
<!-- <div class="container1" :style="{'padding-top':navHeight +'px'}"> -->
<div class="container1">
<!-- <div class="navbar" :style="{'height' : navHeight + 'px','padding-top':navTop+'px'}"> -->
<!-- <div @click="toHistory" class="history-btn" v-show="isLogin">
<img class="btn-img" src="../../../static/images/history.png" alt="">
</div> -->
<!-- <div @click="toHistory" class="history-btn">
<img class="btn-img" src="../../../static/images/history.png" alt="">
<div class="container1" :style="{'padding-top':navHeight +'px'}">
<div class="navbar" :style="{'height' : navHeight + 'px','padding-top':navTop+'px'}">
<div @click="toIndex" class="history-btn">
<span class="iconfont iconzuo"></span>
</div>
<div class="navbar-title">直播计划</div>
</div> -->
</div>
<div class="history-wrap">
<div class="history-box" @click="toHistory">
......
{
"enablePullDownRefresh":true,
"navigationStyle":"custom",
"navigationBarTitleText":"直播计划",
"usingComponents": {
"van-divider": "/static/vant/divider/index"
......
......@@ -69,7 +69,7 @@ export default {
},
onShow(){
this.overInfo = {}
// this.overInfo = {}
},
onLoad(options){
......
......@@ -22,8 +22,8 @@
</div>
<div class="info">
<p class="name line-clamp1" v-if="shopName">{{shopName}}</p>
<p class="num" v-if="liveNoticeInfo.watchNum>0">
<span>{{liveNoticeInfo.watchNum}}</span>
<p class="num" v-if="liveNoticeInfo.historyWatchNum>0">
<span>{{liveNoticeInfo.historyWatchNum}}</span>
<span style="margin-left:6px;">观看</span>
</p>
</div>
......@@ -126,6 +126,7 @@ export default {
isTimeFirstReq : true, //第一次数据请求
newCommentsTime : 0,
userActivebeginTime : 0,
};
},
components: {
......@@ -136,6 +137,7 @@ export default {
},
computed: {},
onLoad(options) {
console.log('onLoad')
this.isTimeLock = true;
this.isTimeFirstReq = true;
this.newCommentsTime = 0;
......@@ -179,7 +181,7 @@ export default {
}
this.init();
this.userEntry("IN");
// this.userEntry("IN");
// 通过分享进入直播间重新查询订阅消息配置
this.getMsgConfig();
......@@ -223,6 +225,13 @@ export default {
console.log(shareObj, "----------------168");
return shareObj;
},
onHide(){
this.userEntry("OUT");
},
onShow(){
console.log('onShow')
this.userEntry("IN");
},
onUnload() {
this.liveNoticeInfo.liveBroadcastState = -1;
this.liveNoticeInfo = {};
......@@ -341,10 +350,12 @@ export default {
if(this.isTimeLock){
this.isTimeLock = false;
let dataTime = this.isTimeFirstReq ? serverTime - 2000 : this.newCommentsTime
let userTime = this.isTimeFirstReq ? serverTime - 2000 : this.userActivebeginTime
// 前五秒
let query = {
id: Number(this.liveId),
beginTime: dataTime
beginTime: dataTime,
userActivebeginTime : userTime, //用户进入时间
};
live.getLiveStateById(query).then(res => {
this.isTimeFirstReq = false;
......@@ -404,11 +415,14 @@ export default {
if(resData.guestBookList && resData.guestBookList.length){
this.newCommentsTime = resData.guestBookList[resData.guestBookList.length - 1].createTimeStamp
}
if(result.entryNoticeList && result.entryNoticeList.length){
this.userActivebeginTime = result.entryNoticeList[result.entryNoticeList.length - 1].createTimeStamp
}
this.likeInfo = resData.likeInfo; //点赞信息
// 直播中且接口直播中---主要操作
// 数据初始化
this.entryNoticeText = "";
this.liveNoticeInfo.watchNum = resData.watchNum; //观看人数
this.liveNoticeInfo.historyWatchNum = resData.historyWatchNum; //观看人数
if (resData.entryNoticeList.length > 0) {
if (resData.entryNoticeList.length == 1) {
this.entryNoticeText = `${resData.entryNoticeList[0].userName}`; //用户进入
......@@ -487,6 +501,7 @@ export default {
// this.timingGetInfo(res.data.data);
this.newCommentsTime = res.data.data
this.userActivebeginTime = res.data.data
console.log('newCommentsTime',this.newCommentsTime)
// setTimeout(() => {
this.infoTiming = setInterval(() => {
......
......@@ -11,7 +11,8 @@ export async function requestGET(url, options) {
header: {
"Shop-Mixid": shopMixid,
"Offline-Shop-Code": store.state.offlineShopCode,
"Authorization": wx.getStorageSync('sessionid') || ""
"Authorization": wx.getStorageSync('sessionid') || "",
"dubbo-tag": "ljx"
},
success: function (res) {
resolve(res)
......@@ -33,6 +34,7 @@ export async function requestPOST(url, options) {
"Shop-Mixid": shopMixid,
"Authorization": wx.getStorageSync('sessionid') || "",
"Offline-Shop-Code": store.state.offlineShopCode,
"dubbo-tag": "ljx"
},
success: function (res) {
resolve(res)
......@@ -55,6 +57,7 @@ export function requestPOST1(url, options) {
"Shop-Mixid": shopMixid,
Authorization: wx.getStorageSync('sessionid') || "",
"Offline-Shop-Code": store.state.offlineShopCode,
"dubbo-tag": "ljx"
},
success: function (res) {
resolve(res)
......
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