Commit b30110e8 by 李嘉林

直播结束

parent 74719c90
...@@ -39,10 +39,14 @@ export default { ...@@ -39,10 +39,14 @@ export default {
}, },
// 直播间点赞接口 // 直播间点赞接口
addLiveLikeByUser(options) { addLiveLikeByUser(options) {
return requestPOST(`${process.env.OLSHOP_URL}liveBroadcastInfo/addLiveLikeByUser`, options); return requestPOST(`${process.env.OLSHOP_URL}/liveBroadcastInfo/addLiveLikeByUser`, options);
}, },
// 直播中商品列表 // 直播中商品列表
getListByLiveBroadcastId(options) { getListByLiveBroadcastId(options) {
return requestGET(`${process.env.OLSHOP_URL}liveBroadcastGoods/getListByLiveBroadcastId?id=${Number(options)}`); return requestGET(`${process.env.OLSHOP_URL}/liveBroadcastGoods/getListByLiveBroadcastId?id=${Number(options)}`);
},
// 单次直播数据统计接口
getLiveStatisticsById(options) {
return requestPOST(`${process.env.OLSHOP_URL}/liveBroadcastInfo/getLiveStatisticsById`,options);
}, },
}; };
\ No newline at end of file
...@@ -183,10 +183,10 @@ export default { ...@@ -183,10 +183,10 @@ export default {
fromLived: 1, fromLived: 1,
liveId: this.liveId liveId: this.liveId
}; };
this.backPath = `/goods/${val.productId}`; let backPath = `/goods/${val.productId}`;
wx.reLaunch({ wx.reLaunch({
url: `../index/main?from=livedToGoodsInfo&backpath=${ url: `../index/main?from=livedToGoodsInfo&backpath=${
this.backPath backPath
}&params=${JSON.stringify(query)}` }&params=${JSON.stringify(query)}`
}); });
} }
......
...@@ -9,15 +9,15 @@ ...@@ -9,15 +9,15 @@
</p> </p>
<div class="data"> <div class="data">
<div> <div>
<p>333</p> <p>{{endInfo.watchNum}}</p>
<p>观看</p> <p>观看</p>
</div> </div>
<div> <div>
<p>333</p> <p>{{endInfo.guestBookNum}}</p>
<p>评论</p> <p>评论</p>
</div> </div>
<div> <div>
<p>333</p> <p>{{endInfo.likeNum}}</p>
<p></p> <p></p>
</div> </div>
</div> </div>
...@@ -29,15 +29,15 @@ ...@@ -29,15 +29,15 @@
</div> </div>
<div class="list"> <div class="list">
<div class="item" v-for="(item,index) in list" :key="index"> <div class="item" v-for="(item,index) in list" :key="index">
<div class="img"> <div class="img" @click="toGoodsInfo(item)">
<img :src="item.img" alt /> <img :src="item.productImgUrl" alt />
</div> </div>
<div class="info"> <div class="info">
<p class="name line-clamp2">{{item.name}}</p> <p class="name line-clamp2">{{item.productName}}</p>
<div class="price"> <div class="price">
<p> <p>
<span></span> <span></span>
<span>{{item.price}}</span> <span>{{item.minPrice}}</span>
</p> </p>
<div class="icon"> <div class="icon">
<van-icon name="shopping-cart" /> <van-icon name="shopping-cart" />
...@@ -53,48 +53,42 @@ ...@@ -53,48 +53,42 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
export default { export default {
props:["updateGoods","goodsList"], props: ["updateGoods", "goodsList", "endInfo"],
name: "", name: "",
data() { data() {
return { return {
list: [ list: [],
{ liveId: 0
name: "产品名称产品名称产品名称产品名称产品名称",
img:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg",
price: 123
},
{
name: "产品名称产品名称产品名称产品名称产品名称",
img:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg",
price: 123
},
{
name: "产品名称产品名称产品名称产品名称产品名称",
img:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg",
price: 123
},
{
name: "产品名称产品名称产品名称产品名称产品名称",
img:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg",
price: 123
}
]
}; };
}, },
watch:{ watch: {
updateGoods(){ updateGoods() {
this.list=this.goodsList; this.list = this.goodsList;
} }
}, },
components: {}, components: {},
computed: {}, computed: {},
onLoad(options) {
let params = JSON.parse(options.params);
this.liveId = params.liveId;
},
created() {}, created() {},
mounted() {}, mounted() {},
methods: {} methods: {
// 到商品详情
toGoodsInfo(val) {
let query = {
fromLived: 1,
liveId: this.liveId
};
let backPath = `/goods/${val.productId}`;
wx.reLaunch({
url: `../index/main?from=livedToGoodsInfo&backpath=${backPath}&params=${JSON.stringify(
query
)}`
});
}
}
}; };
</script> </script>
...@@ -159,7 +153,7 @@ export default { ...@@ -159,7 +153,7 @@ export default {
} }
.tit { .tit {
font-size: 16px; font-size: 16px;
padding: 0 4px; padding: 0 4px 6px 0;
} }
.list { .list {
max-height: 50vh; max-height: 50vh;
...@@ -188,20 +182,20 @@ export default { ...@@ -188,20 +182,20 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
.name{ .name {
text-align: left; text-align: left;
} }
.price{ .price {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
font-size: 18px; font-size: 18px;
span{ span {
color: #FF0000; color: #ff0000;
} }
.icon{ .icon {
font-size: 22px; font-size: 22px;
color: #FF8181; color: #ff8181;
} }
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<div>{{product_goods_info.discountPrice}}</div> <div>{{product_goods_info.discountPrice}}</div>
<div v-if="product_goods_info.singleItemActivityId"> <div v-if="product_goods_info.singleItemActivityId">
<p class="delPrice">{{product_goods_info.originalPrice}}</p> <p class="delPrice">{{product_goods_info.originalPrice}}</p>
<!-- <del style="color:#666;">{{product_goods_info.originalPrice}}</!--> --> <!-- <del style="color:#666;">{{product_goods_info.originalPrice}}</!-->
</div> </div>
<div <div
v-else-if="product_goods_info.discountPrice-0<product_goods_info.goodsSuggestedRetailPrice-0" v-else-if="product_goods_info.discountPrice-0<product_goods_info.goodsSuggestedRetailPrice-0"
......
...@@ -28,7 +28,12 @@ ...@@ -28,7 +28,12 @@
<!-- 未开始展示 --> <!-- 未开始展示 -->
<notStarted v-if="liveNoticeInfo.liveBroadcastState==0" :info="liveNoticeInfo"></notStarted> <notStarted v-if="liveNoticeInfo.liveBroadcastState==0" :info="liveNoticeInfo"></notStarted>
<!-- 结束展示 --> <!-- 结束展示 -->
<livedIsEnded v-if="liveNoticeInfo.liveBroadcastState==2" :updateGoods="updateGoods" :goodsList="goodsList"></livedIsEnded> <livedIsEnded
v-if="liveNoticeInfo.liveBroadcastState==2&&endInfo"
:updateGoods="updateGoods"
:endInfo="endInfo"
:goodsList="goodsList"
></livedIsEnded>
<!-- 控件层 --> <!-- 控件层 -->
<livedControls <livedControls
v-if="liveNoticeInfo&&liveNoticeInfo.liveBroadcastState<2" v-if="liveNoticeInfo&&liveNoticeInfo.liveBroadcastState<2"
...@@ -46,7 +51,7 @@ ...@@ -46,7 +51,7 @@
<live-player <live-player
v-if="liveNoticeInfo.liveBroadcastState==1&&liveNoticeInfo.boStreamRTMP" v-if="liveNoticeInfo.liveBroadcastState==1&&liveNoticeInfo.boStreamRTMP"
class="livePlayer" class="livePlayer"
:src="'rtmp://live.mayi888.com/xgy/127?auth_key=1584633600000-0-0-ac39474385b37a7adac070d15b0bb5de'" :src="liveNoticeInfo.boStreamRTMP"
mode="RTC" mode="RTC"
autoplay autoplay
@error="error" @error="error"
...@@ -76,14 +81,17 @@ export default { ...@@ -76,14 +81,17 @@ export default {
liveNoticeInfo: {}, //详情 liveNoticeInfo: {}, //详情
entryNoticeText: "", //用户通知 entryNoticeText: "", //用户通知
guestBookList: [], // 定时查评论 guestBookList: [], // 定时查评论
goodsList:[],//商品列表 goodsList: [], //商品列表
updateVal: 0, //子组件监听此数据进行数据赋值 updateVal: 0, //子组件监听此数据进行数据赋值
updateGoods:0,//商品相关组件监听 updateGoods: 0, //商品相关组件监听
likeInfo: {}, //点赞 likeInfo: {}, //点赞
isVideo: false, //是否有直播或回放链接 isVideo: false, //是否有直播或回放链接
liveTime: null, //定时器 liveTime: null, //定时器
isWifi: true, //提示网络环境 isWifi: true, //提示网络环境
infoTiming: null //定时器 infoTiming: null, //全局定时器
goodTiming: null, //商品定时器
endInfo: {}, //直播结束详情
firstComing: true // 首次进入
}; };
}, },
components: { components: {
...@@ -115,21 +123,22 @@ export default { ...@@ -115,21 +123,22 @@ export default {
this.shopName = params.shopName; this.shopName = params.shopName;
this.shopLogo = DFSImg(params.shopLogo, 40, 40); this.shopLogo = DFSImg(params.shopLogo, 40, 40);
this.init(); this.init();
setTimeout(() => {
this.infoTiming = setInterval(() => { this.infoTiming = setInterval(() => {
this.timingGetInfo(); this.timingGetInfo();
this.getGoodsList();
}, 5000); }, 5000);
}, 2000);
this.userEntry("IN"); this.userEntry("IN");
}, },
onUnload() { onUnload() {
this.userEntry("OUT"); this.userEntry("OUT");
this.liveNoticeInfo.liveBroadcastState = -1; this.liveNoticeInfo.liveBroadcastState = -1;
this.liveNoticeInfo = {}; this.liveNoticeInfo = {};
this.firstComing=true;
if (this.infoTiming) { if (this.infoTiming) {
clearInterval(this.infoTiming); clearInterval(this.infoTiming);
} }
if (this.goodTiming) {
clearInterval(this.goodTiming);
}
}, },
mounted() {}, mounted() {},
methods: { methods: {
...@@ -143,16 +152,22 @@ export default { ...@@ -143,16 +152,22 @@ export default {
this.liveNoticeInfo.coverUrl = this.liveNoticeInfo.coverUrl this.liveNoticeInfo.coverUrl = this.liveNoticeInfo.coverUrl
? DFSImg(this.liveNoticeInfo.coverUrl) ? DFSImg(this.liveNoticeInfo.coverUrl)
: ""; : "";
if(this.liveNoticeInfo.liveBroadcastState > 1 && this.infoTiming) { this.getGoodsList();
clearInterval(this.infoTiming); if (this.liveNoticeInfo.liveBroadcastState == 2) {
// 调直播结束
this.endLived();
} else { } else {
// 调用定时接口
this.timingGetInfo(); this.timingGetInfo();
} }
if (this.liveNoticeInfo.liveBroadcastState != 2 && !this.goodTiming) {
this.goodTiming = setInterval(() => {
this.getGoodsList(); this.getGoodsList();
if(this.liveNoticeInfo.liveBroadcastState >=2){ }, 5000);
// 调直播结束 } else if (
this.endLived(); this.liveNoticeInfo.liveBroadcastState == 2 &&
this.goodTiming
) {
clearInterval(this.goodTiming);
} }
} }
}); });
...@@ -187,38 +202,45 @@ export default { ...@@ -187,38 +202,45 @@ export default {
) { ) {
// 未开始且接口也未开始不作操作 // 未开始且接口也未开始不作操作
} else if ( } else if (
this.liveNoticeInfo.liveBroadcastState == 0 &&
resData.liveState == "IN_LIVE"
) {
// 未开始且接口直播中
this.init();
} else if (
this.liveNoticeInfo.liveBroadcastState == 1 && this.liveNoticeInfo.liveBroadcastState == 1 &&
resData.liveState == "IN_LIVE" resData.liveState == "IN_LIVE"
) { ) {
// 直播中且接口直播中---主要操作 // 直播中且接口直播中---主要操作
// 数据初始化 // 数据初始化
this.entryNoticeText = ""; this.entryNoticeText = "";
this.liveNoticeInfo.watchNum = resData.watchNum;//观看人数 this.liveNoticeInfo.watchNum = resData.watchNum; //观看人数
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}`; //用户进入
} else { } else {
this.entryNoticeText = `${ this.entryNoticeText = `${
resData.entryNoticeList[0].userName resData.entryNoticeList[0].userName
}${resData.entryNoticeList.length}人`;//用户进入 }${resData.entryNoticeList.length}人`; //用户进入
} }
} }
} else if ( } else if (
this.liveNoticeInfo.liveBroadcastState == 1 && this.liveNoticeInfo.liveBroadcastState == 0 &&
resData.liveState == "END_LIVE" resData.liveState == "IN_LIVE"
) { ) {
// 直播中且接口已结束 console.log("未开始----直播中")
// 未开始且接口直播中/直播中且接口已结束
this.init();
} else if (
(this.liveNoticeInfo.liveBroadcastState == 2 &&
resData.liveState == "END_LIVE") ||
(this.liveNoticeInfo.liveBroadcastState == 1 &&
resData.liveState == "END_LIVE")
) {
console.log(this.liveNoticeInfo.liveBroadcastState,resData.liveState,this.firstComing,"直播中----结束","结束----结束")
//直播结束且接口已结束
if (this.firstComing) {
this.firstComing = false;
this.init(); this.init();
} }
this.guestBookList=resData.guestBookList;//评论列表 }
this.likeInfo=resData.likeInfo;//点赞信息 this.guestBookList = resData.guestBookList; //评论列表
this.updateVal = Math.random();//监听使用数据 this.likeInfo = resData.likeInfo; //点赞信息
this.updateVal = Math.random(); //监听使用数据
} else { } else {
if (this.infoTiming) { if (this.infoTiming) {
clearInterval(this.infoTiming); clearInterval(this.infoTiming);
...@@ -227,28 +249,36 @@ export default { ...@@ -227,28 +249,36 @@ export default {
}); });
}, },
// 获取商品列表 // 获取商品列表
getGoodsList(){ getGoodsList() {
let id=this.liveId; let id = this.liveId;
live.getListByLiveBroadcastId(id).then(res=>{ live.getListByLiveBroadcastId(id).then(res => {
if(res.data.code==200){ if (res.data.code == 200) {
this.goodsList=[]; this.goodsList = [];
let arr=[]; let arr = [];
if(res.data.data.length>0){ if (res.data.data.length > 0) {
this.goodsList=res.data.data.forEach((item,index)=>{ this.goodsList = res.data.data.forEach((item, index) => {
if(item.productImgUrl){ if (item.productImgUrl) {
item.productImgUrl=DFSImg(item.productImgUrl); item.productImgUrl = DFSImg(item.productImgUrl);
item.minPrice = Number(item.minPrice);
} }
arr.push(item); arr.push(item);
}) });
this.goodsList=arr; this.goodsList = arr;
this.updateGoods = Math.random(); this.updateGoods = Math.random();
} }
} }
}) });
}, },
// 直播结束数据 // 直播结束数据
endLived(){ endLived() {
let query = {
id: Number(this.liveId)
};
live.getLiveStatisticsById(query).then(res => {
if (res.data.code == 200) {
this.endInfo = res.data.data;
}
});
}, },
userEntry(type) { userEntry(type) {
let query = { let query = {
...@@ -268,11 +298,11 @@ export default { ...@@ -268,11 +298,11 @@ export default {
} }
}); });
}, },
error(res){ error(res) {
console.log(res,'------------------237') console.log(res, "------------------237");
}, },
changes(res){ changes(res) {
console.log(res,'---------------241') console.log(res, "---------------241");
} }
} }
}; };
......
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