Commit 594b40f9 by 李嘉林

接口对接

parent 558c43e1
...@@ -33,4 +33,8 @@ export default { ...@@ -33,4 +33,8 @@ export default {
userEntryOrExitsLiveRoom(options) { userEntryOrExitsLiveRoom(options) {
return requestPOST(`${process.env.OLSHOP_URL}/liveBroadcastInfo/userEntryOrExitsLiveRoom`, options); return requestPOST(`${process.env.OLSHOP_URL}/liveBroadcastInfo/userEntryOrExitsLiveRoom`, options);
}, },
// 提交直播评论
addGuestbook(options) {
return requestPOST(`${process.env.OLSHOP_URL}/liveBroadcastInfo/addGuestbook`, options);
},
}; };
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<span>来了</span> <span>来了</span>
</div> </div>
<!-- 评论层 --> <!-- 评论层 -->
<livedIsMsg v-if="info.liveBroadcastState==1"></livedIsMsg> <livedIsMsg v-if="info.liveBroadcastState==1&&guestBookList" :guestBookList="guestBookList" :updateVal="updateVal"></livedIsMsg>
<!-- 带货商品层 --> <!-- 带货商品层 -->
<livedExplainingCommodities v-if="info.liveBroadcastState==1"></livedExplainingCommodities> <livedExplainingCommodities v-if="info.liveBroadcastState==1"></livedExplainingCommodities>
<!-- 商品列表弹层 --> <!-- 商品列表弹层 -->
...@@ -61,8 +61,9 @@ import livedAnnouncement from "@/components/livedModel/livedAnnouncement"; ...@@ -61,8 +61,9 @@ import livedAnnouncement from "@/components/livedModel/livedAnnouncement";
import livedIsMsg from "@/components/livedModel/livedIsMsg"; import livedIsMsg from "@/components/livedModel/livedIsMsg";
import livedExplainingCommodities from "@/components/livedModel/livedExplainingCommodities"; import livedExplainingCommodities from "@/components/livedModel/livedExplainingCommodities";
import livedGoodsDia from "@/components/livedModel/livedGoodsDia"; import livedGoodsDia from "@/components/livedModel/livedGoodsDia";
import live from "@/api/live";
export default { export default {
props: ["info","entryNoticeText","updateVal"], props: ["info","entryNoticeText","updateVal","guestBookList"],
name: "", name: "",
data() { data() {
return { return {
...@@ -125,7 +126,7 @@ export default { ...@@ -125,7 +126,7 @@ export default {
return; return;
} }
if (val == 1) { if (val == 1) {
this.likeNum++; this.watchNum++;
} }
setTimeout(() => { setTimeout(() => {
this.num++; this.num++;
...@@ -206,7 +207,7 @@ export default { ...@@ -206,7 +207,7 @@ export default {
setTimeout(() => { setTimeout(() => {
this.isSend = false; this.isSend = false;
this.sendVal = ""; this.sendVal = "";
}, 10); }, 220);
}, },
// 点击发送留言 // 点击发送留言
toSend() { toSend() {
...@@ -214,6 +215,12 @@ export default { ...@@ -214,6 +215,12 @@ export default {
if (this.sendVal == "") { if (this.sendVal == "") {
this.getFocus = true; this.getFocus = true;
} else { } else {
let query={
guestbookType:'1',
guestbookContent:this.sendVal,
liveBroadcastId:Number(this.liveId),
}
this.$emit("toSendMsg",query);
} }
} }
} }
......
...@@ -35,19 +35,19 @@ export default { ...@@ -35,19 +35,19 @@ export default {
isEC: true, isEC: true,
id: 1, id: 1,
img: img:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg" "//img3.imgtn.bdimg.com/it/u=1870796683,3322238076&fm=11&gp=0.jpg"
}, },
{ {
isEC: true, isEC: true,
id: 2, id: 2,
img: img:
"//img0.imgtn.bdimg.com/it/u=216605226,3652567530&fm=11&gp=0.jpg" "//img0.imgtn.bdimg.com/it/u=3318255953,3983626805&fm=26&gp=0.jpg"
}, },
{ {
isEC: false, isEC: false,
id: 3, id: 3,
img: img:
"//img0.imgtn.bdimg.com/it/u=216605226,3652567530&fm=11&gp=0.jpg" "//img3.imgtn.bdimg.com/it/u=4241660740,3615994401&fm=26&gp=0.jpg"
}, },
{ {
isEC: false, isEC: false,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<div class="user"> <div class="user">
<p class="live"></p> <p class="live"></p>
<div class="name"> <div class="name">
<span class="user">用户{{index}}</span><span class="test">{{item.val}}</span> <span class="user">{{item.customerName}}</span><span class="test">{{item.guestbookContent}}</span>
</div> </div>
</div> </div>
</div> </div>
...@@ -18,17 +18,20 @@ ...@@ -18,17 +18,20 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
export default { export default {
props:["guestBookList","updateVal"],
name: "", name: "",
data() { data() {
return { return {
list: [ list: [],
{
val: "测试测试测试测"
},
],
scrollTop:0, scrollTop:0,
}; };
}, },
watch:{
updateVal(){
this.list=[...this.list,...this.guestBookList];
this.scrollTop=this.list.length*1000;
}
},
components: {}, components: {},
computed: {}, computed: {},
created() {}, created() {},
......
...@@ -34,7 +34,9 @@ ...@@ -34,7 +34,9 @@
v-if="liveNoticeInfo&&liveNoticeInfo.liveBroadcastState<2" v-if="liveNoticeInfo&&liveNoticeInfo.liveBroadcastState<2"
:info="liveNoticeInfo" :info="liveNoticeInfo"
:entryNoticeText="entryNoticeText" :entryNoticeText="entryNoticeText"
:guestBookList="guestBookList"
:updateVal="updateVal" :updateVal="updateVal"
@toSendMsg="toSendMsg"
></livedControls> ></livedControls>
</div> </div>
<!-- 直播 --> <!-- 直播 -->
...@@ -69,14 +71,14 @@ export default { ...@@ -69,14 +71,14 @@ export default {
status: 0, // 0:未开始 1:直播中 2:已结束 status: 0, // 0:未开始 1:直播中 2:已结束
// 总数据 // 总数据
liveNoticeInfo: {}, //详情 liveNoticeInfo: {}, //详情
entryNoticeText:'',//用户通知 entryNoticeText: "", //用户通知
guestBookList:[],// 定时查评论 guestBookList: [], // 定时查评论
updateVal:0,//子组件监听此数据进行数据赋值 updateVal: 0, //子组件监听此数据进行数据赋值
likeInfo:{},//点赞 likeInfo: {}, //点赞
isVideo: false, //是否有直播或回放链接 isVideo: false, //是否有直播或回放链接
liveTime: null, //定时器 liveTime: null, //定时器
isWifi: true, //提示网络环境 isWifi: true, //提示网络环境
infoTiming:null,//定时器 infoTiming: null //定时器
}; };
}, },
components: { components: {
...@@ -89,10 +91,10 @@ export default { ...@@ -89,10 +91,10 @@ export default {
onLoad(options) { onLoad(options) {
wx.getNetworkType({ wx.getNetworkType({
success: function(res) { success: function(res) {
if(res.networkType!='wifi'){ if (res.networkType != "wifi") {
wx.showModal({ wx.showModal({
content: "您当前处于非wifi网络环境下", content: "您当前处于非wifi网络环境下",
confirmColor: '#ff877d', confirmColor: "#ff877d",
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
} else if (res.cancel) { } else if (res.cancel) {
...@@ -108,16 +110,18 @@ export default { ...@@ -108,16 +110,18 @@ 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();
this.infoTiming=setInterval(() => { setTimeout(() => {
this.infoTiming = setInterval(() => {
this.timingGetInfo(); this.timingGetInfo();
}, 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 = {};
if(this.infoTiming){ if (this.infoTiming) {
clearInterval(this.infoTiming); clearInterval(this.infoTiming);
} }
}, },
...@@ -133,9 +137,9 @@ export default { ...@@ -133,9 +137,9 @@ 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>2&&this.infoTiming){ if (this.liveNoticeInfo.liveBroadcastState > 2 && this.infoTiming) {
clearInterval(this.infoTiming); clearInterval(this.infoTiming);
}else{ } else {
// 调用定时接口 // 调用定时接口
this.timingGetInfo(); this.timingGetInfo();
} }
...@@ -160,75 +164,79 @@ export default { ...@@ -160,75 +164,79 @@ export default {
url: `../index/main?from=livedToIndex&backpath=${this.backPath}` url: `../index/main?from=livedToIndex&backpath=${this.backPath}`
}); });
}, },
// 是否登录
isLogin(){
wx.getStorage({
key: "sessionid",
success(res) {
console.log("登录----------147")
},
fail(res) {
console.log("未登录------150")
// 跳转登录页
let backUrl='/lived/main';
let query={
liveId:this.liveId,
}
let url = `/pages/login/main?backpath=${backUrl}&params=${JSON.stringify(query)}`;
wx.reLaunch({
url: url
});
}
});
},
// 定时查询直播数据 // 定时查询直播数据
timingGetInfo(){ timingGetInfo() {
// 前五秒 // 前五秒
let query={ let query = {
id:Number(this.liveId), id: Number(this.liveId),
beginTime:new Date().getTime()-5000 beginTime: new Date().getTime() - 5000
} };
live.getLiveStateById(query).then(res=>{ live.getLiveStateById(query).then(res => {
if(res.data.code==200){ if (res.data.code == 200) {
let resData=res.data.data; let resData = res.data.data;
// 1、判断状态如果发生改变才init(); // 1、判断状态如果发生改变才init();
// 2、直播中给用户进入通知、评论、点赞数赋值 // 2、直播中给用户进入通知、评论、点赞数赋值
if(this.liveNoticeInfo.liveBroadcastState==0&&resData.liveState=="NO_LIVE"){ if (
this.liveNoticeInfo.liveBroadcastState == 0 &&
resData.liveState == "NO_LIVE"
) {
// 未开始且接口也未开始不作操作 // 未开始且接口也未开始不作操作
}else if(this.liveNoticeInfo.liveBroadcastState==0&&resData.liveState=="IN_LIVE"){ } else if (
this.liveNoticeInfo.liveBroadcastState == 0 &&
resData.liveState == "IN_LIVE"
) {
// 未开始且接口直播中 // 未开始且接口直播中
this.init(); this.init();
}else if(this.liveNoticeInfo.liveBroadcastState==1&&resData.liveState=="IN_LIVE"){ } else if (
this.liveNoticeInfo.liveBroadcastState == 1 &&
resData.liveState == "IN_LIVE"
) {
// 直播中且接口直播中---主要操作 // 直播中且接口直播中---主要操作
// 数据初始化 // 数据初始化
this.entryNoticeText=""; this.entryNoticeText = "";
this.liveNoticeInfo.watchNum=resData.watchNum; this.liveNoticeInfo.watchNum = resData.watchNum;//观看人数
// this.liveNoticeInfo.watchNum=Math.floor(Math.random()*(100-1+1)+1); 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.length}人`; resData.entryNoticeList[0].userName
}${resData.entryNoticeList.length}人`;//用户进入
} }
} }
}else if(this.liveNoticeInfo.liveBroadcastState==1&&resData.liveState=="END_LIVE"){ this.guestBookList=resData.guestBookList;//评论列表
} else if (
this.liveNoticeInfo.liveBroadcastState == 1 &&
resData.liveState == "END_LIVE"
) {
// 直播中且接口已结束 // 直播中且接口已结束
this.init(); this.init();
} }
this.updateVal=Math.random(); this.updateVal = Math.random();
}else{ } else {
if(this.infoTiming){ if (this.infoTiming) {
clearInterval(this.infoTiming); clearInterval(this.infoTiming);
} }
} }
}) });
},
userEntry(type) {
let query = {
liveBroadcastId: Number(this.liveId),
activityType: type
};
live.userEntryOrExitsLiveRoom(query).then(res => {});
}, },
userEntry(type){ toSendMsg(val) {
let query={ live.addGuestbook(val).then(res => {
liveBroadcastId:Number(this.liveId), if (res.data.code == 200) {
activityType:type } else {
wx.showToast({
title: res.data.msg,
icon: "none"
});
} }
live.userEntryOrExitsLiveRoom(query).then(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