直播完成

This commit is contained in:
luyuan 2020-07-30 15:54:32 +08:00
parent b605f68e72
commit 1d9edefd7f
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
5 changed files with 240 additions and 69 deletions

View File

@ -112,7 +112,8 @@
url:"/pages/release/zhibo",
params:{
url:res.data.url.replace("&","*"),
id:res.data.chat_id
id:res.data.chat_id,
live_id: res.data.live_id
}
})
})

View File

@ -1,7 +1,7 @@
<template>
<div>
<live-pusher id='livePusher' ref="livePusher" class="livePusher" :url="url"
mode="SD" :muted="false" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2"
mode="SD" :muted="false" :enable-camera="true" :auto-focus="true" :beauty="meiyan + 1" whiteness="2"
aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error = "error"
:style="{'height':height + 'px'}"
></live-pusher>
@ -41,9 +41,33 @@
<image class="userhead" :src="info.member_avatar"></image>
<div class="userinfo">
<text class="username">{{info.member_name}}</text>
<text class="username" style="font-size:20rpx">asdasdsa | sadasdas</text>
<text class="username" style="font-size:20rpx">{{time}} | sadasdas</text>
</div>
</div>
<image class="closeimg" src="../../static/image/close.png" @click="closes"></image>
<image class="menuimg" src="../../static/image/menu.png" @click="tool = true"></image>
<image class="shoptapimg" @click="xianshi" src="../../static/image/shop.png"></image>
<text style="font-size:26rpx;color:#fff;width:512rpx;position:fixed;left:30rpx;top:793rpx">德铭阳光在线绿色直播请遵循相关法律法规警察叔叔24小时巡查哦。为了保障直播系统稳定现将全局开放防主播沉迷功能。主播积累直播16小时将自动下播休息2小时后方可继续开播。请大家注意休息/避免空播。
</text>
<div class="bottom" :style="{'height':height + 'px'}" v-if="tool" @click="tool = false">
<view class="menu" @click="zuzhi">
<view class="menuback"></view>
<text class="menutitle">直播工具</text>
<view class="menutool">
<view class="menutoolitem" @click="switchCamera">
<image class="menutoolitemimg"></image>
<text class="menutoolitemtitle">翻转</text>
</view>
<picker @change="bindPickerChange" :value="meiyan" :range="[1,2,3,4,5,6,7,8,9]">
<view class="menutoolitem">
<image class="menutoolitemimg"></image>
<text class="menutoolitemtitle">美颜</text>
</view>
</picker>
</view>
</view>
</div>
<!-- <button class="btn" @click="start">开始推流1</button>
<button class="btn" @click="pause">暂停推流</button>
<button class="btn" @click="resume">resume</button>
@ -56,6 +80,27 @@
</div>
</template>
<style lang="scss" scoped>
.shoptapimg{
width: 65rpx;
height: 65rpx;
position: fixed;
right: 26rpx;
bottom: 24rpx;
}
.menuimg{
width: 60rpx;
height: 55rpx;
position: fixed;
left: 26rpx;
bottom: 24rpx;
}
.closeimg{
position: fixed;
top: 70rpx;
right: 31rpx;
width: 31rpx;
height: 31rpx;
}
.username{
font-size: 24rpx;
color: #fff;
@ -97,7 +142,6 @@
.shopimg{
width: 160rpx;
height: 160rpx;
background-color: #0f0;
}
@ -164,6 +208,50 @@
z-index: 20;
}
.menu{
width: 750rpx;
height: 335rpx;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
overflow: hidden;
position: fixed;
bottom: 0;
left: 0;
}
.menuback{
background-color: #000;
opacity: 0.8;
position: absolute;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
overflow: hidden;
top: 0;
left: 0;
}
.menutitle{
font-size: 30rpx;
color: #fff;
margin-left: 30rpx;
margin-top: 30rpx;
}
.menutool{
flex-direction: row;
margin-top: 59rpx;
margin-left: 30rpx;
}
.menutoolitem{
align-items: center;
margin-right: 60rpx;
}
.menutoolitemtitle{
margin-top: 30rpx;
font-size: 28rpx;
color: #fff;
}
.menutoolitemimg{
width: 100rpx;
height: 100rpx;
}
</style>
<script>
const RongIMLib = require('../../static/rongyun.js');
@ -172,10 +260,15 @@
fil: true,
url:'',
height:0,
show:true,
show:false,
list:[],
info:{},
im:{}
im:{},
chatroom_id:0,
live_id:0,
tool:false,
meiyan:0,
time:'00:00:00'
},
onReady() {
// 注意需要在onReady中 或 onLoad 延时
@ -196,73 +289,146 @@
let that = this
const token = uni.getStorageSync('token');
console.log('Bearer' + " " + token)
// uni.request({
// url:"https://dmmall.sdbairui.com/storeapi/Streaming/liveStreamList",
// method:"POST",
// headers:{
// 'Authorization' : 'Bearer' + " " + token
// },
// success(res){
// console.log(res)
// that.list= res.data.data
// }
// })
// uni.request({
// url:"https://dmmall.sdbairui.com/storeapi/member/memberInfo",
// method:"POST",
// headers:{
// 'Authorization' : 'Bearer' + " " + token
// },
// success(res){
// console.log(res.data.data.memberInfo)
// that.info = res.data.data.memberInfo
// }
// })
var config = {
appkey: 'mgb7ka1',
debug:true
};
var im = RongIMLib.init(config);
var conversationList = []; // 当前已存在的会话列表
im.watch({
conversation: function(event){
var updatedConversationList = event.updatedConversationList; // 更新的会话列表
console.log('更新会话汇总:', updatedConversationList);
console.log('最新会话列表:', im.Conversation.merge({
conversationList,
updatedConversationList
}));
this.chatroom_id = a.id
this.live_id = a.live_id
uni.request({
url:"https://dmmall.sdbairui.com/storeapi/Streaming/liveStreamList",
method:"POST",
header:{
'Authorization' : 'Bearer' + " " + token
},
message: function(event){
var message = event.message;
console.log('收到新消息:', message);
},
status: function(event){
var status = event.status;
console.log('连接状态码:', status);
success(res){
console.log(res)
that.list= res.data.data
}
});
var user = {
token: uni.getStorageSync('rongyun')
};
console.log(user,123)
im.connect(user).then(function(user) {
console.log('链接成功, 链接用户 id 为: ', user.id);
}).catch(function(error) {
console.log('链接失败: ', error.code, error);
});
var chatRoom = im.ChatRoom.get({
id: a.id
})
chatRoom.join({
count: 20 // 进入后, 自动拉取 20 条聊天室最新消息
}).then(function() {
console.log('加入聊天室成功');
}).catch((err)=>{
console.log(err,262)
uni.request({
url:"https://dmmall.sdbairui.com/storeapi/member/memberInfo",
method:"POST",
header:{
'Authorization' : 'Bearer' + " " + token
},
success(res){
console.log(res.data)
that.info = res.data.data.memberInfo
}
})
let shi = 0;
let fen = 0;
let miao = 0;
setInterval(() => {
shi = parseInt(shi)
fen = parseInt(fen)
miao = parseInt(miao)
miao = miao + 1
console.log(miao)
if(miao == 60){
miao = 0;
fen +=1
}
if(fen == 60){
shi += 1
fen = 0
}
if(shi < 10){
shi = '0' + shi
}
if(fen < 10){
fen = '0' + fen
}
if(miao < 10){
miao = '0' + miao
}
that.time = shi + ":" + fen + ":" + miao
}, 1000);
// var config = {
// appkey: 'mgb7ka1',
// debug:true
// };
// var im = RongIMLib.init(config);
// var conversationList = []; // 当前已存在的会话列表
// im.watch({
// conversation: function(event){
// var updatedConversationList = event.updatedConversationList; // 更新的会话列表
// console.log('更新会话汇总:', updatedConversationList);
// console.log('最新会话列表:', im.Conversation.merge({
// conversationList,
// updatedConversationList
// }));
// },
// message: function(event){
// var message = event.message;
// console.log('收到新消息:', message);
// },
// status: function(event){
// var status = event.status;
// console.log('连接状态码:', status);
// }
// });
// var user = {
// token: uni.getStorageSync('rongyun')
// };
// console.log(user,123)
// im.connect(user).then(function(user) {
// console.log('链接成功, 链接用户 id 为: ', user.id);
// }).catch(function(error) {
// console.log('链接失败: ', error.code, error);
// });
// var chatRoom = im.ChatRoom.get({
// id: a.id
// })
// chatRoom.join({
// count: 20 // 进入后, 自动拉取 20 条聊天室最新消息
// }).then(function() {
// console.log('加入聊天室成功');
// }).catch((err)=>{
// console.log(err,262)
// })
},
methods: {
bindPickerChange(a){
console.log(a.detail.value)
this.meiyan = a.detail.value
uni.showToast({
title: '切换成功',
duration: 2000
});
},
closes(){
const token = uni.getStorageSync('token');
let that = this
console.log(that.url)
uni.showModal({
title: '提示',
content: '是否关闭直播',
success: function (res) {
if (res.confirm) {
uni.request({
url:"https://dmmall.sdbairui.com/storeapi/Streaming/destroyChatRoom",
data:{
chatroom_id:that.chatroom_id,
live_id:that.live_id,
url: that.url
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(res){
console.log(res)
uni.navigateBack({
delta: 1
});
// that.list= res.data.data
}
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
},
statechange(e) {
console.log("statechange:" + JSON.stringify(e));
},
@ -342,6 +508,10 @@
}
});
},
xianshi(){
this.show = true;
console.log(111)
},
guanbi(){
this.show = false
console.log(123)
@ -365,7 +535,7 @@
data:{
goods_id:arr.join(',')
},
headers:{
header:{
'Authorization' : 'Bearer' + " " + token
},
success(res){
@ -373,7 +543,7 @@
uni.request({
url:"https://dmmall.sdbairui.com//storeapi/Streaming/liveStreamList",
method:"POST",
headers:{
header:{
'Authorization' : 'Bearer' + " " + token
},
success(res){

BIN
static/image/close.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/image/menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/image/shop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB