Commit c84d6adf by 程智春

直播

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