Merge pull request 'xbx' (#14) from xbx into master

Reviewed-on: http://git.luyuan.tk/luyuan/demingshangjia/pulls/14
This commit is contained in:
luyuan 2020-07-30 15:56:03 +08:00
commit b9e15c1b02
6 changed files with 247 additions and 61 deletions

View File

@ -4,17 +4,18 @@ const install = (Vue, vm) => {
baseUrl: 'https://dmmall.sdbairui.com/storeapi',
loadingText: '努力加载中~',
loadingTime: 800,
// 设置自定义头部content-type
// header: {
// "Authorization" : "122"
// }
// ......
originalData: true,
});
Vue.prototype.$u.http.interceptor.request = (config) => {
const token = uni.getStorageSync('token');
config.header.Authorization = 'Bearer' + " " + token;
return config;
}
Vue.prototype.$u.http.interceptor.response = (res) => {
// todo 判断状态码
return res.data;
}
}
export default {

View File

@ -28,7 +28,7 @@
<!-- 标签的引入 -->
<tap_tosign :fileListes="fileListes" @chuangjian="chuangjian" @qiehuan="qiehuan"></tap_tosign>
<view class="titles">直播封面图</view>
<u-upload :form-data="{'name':'article_cover'}" action='https://dmmall.sdbairui.com/storeapi/Upload/uploadFile' name="article_cover" :max-count="1" :show-progress="false" @on-change="tupian" del-color="#ececec" upload-text="上传" del-bg-color="#fff"></u-upload>
<u-upload :form-data="{'name':'article_cover'}" action='https://dmmall.sdbairui.com/storeapi/Upload/uploadFile' name="article_cover" :header="{'Authorization' : 'Bearer' + ' ' + token}" :max-count="1" :show-progress="true" @on-change="tupian" del-color="#ececec" upload-text="上传" del-bg-color="#fff"></u-upload>
</view>
<view class="button-uview">
<u-button @click="kaibo">{{relerest}}</u-button>
@ -60,7 +60,8 @@
relerest: '开始直播',
fileListes:[],
rSelect:[],
image:""
image:"",
token:""
};
},
methods: {
@ -90,7 +91,7 @@
this.init()
},
tupian(a){
console.log(JSON.parse(a.data).data)
console.log(JSON.parse(a.data))
this.image = JSON.parse(a.data).data.file_name
},
navto(url){
@ -111,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
}
})
})
@ -137,6 +139,14 @@
onLoad(){
this.init()
uni.removeStorageSync('gouwudai')
//
this.token = uni.getStorageSync('token');
var config = {
appkey: 'mgb7ka1',
debug:true
};
}
};
</script>
@ -472,5 +482,6 @@
left: 0;
right: 0;
margin: auto;
z-index: 10;
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<div>
<live-pusher id='livePusher' ref="livePusher" class="livePusher" :url="url"
mode="SD" :muted="true" :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 @@ const RongIMLib = require('../../static/rongyun.js');
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 延时
@ -195,10 +288,13 @@ const RongIMLib = require('../../static/rongyun.js');
this.url = a.url.replace("*","&")
let that = this
const token = uni.getStorageSync('token');
console.log('Bearer' + " " + token)
this.chatroom_id = a.id
this.live_id = a.live_id
uni.request({
url:"https://dmmall.sdbairui.com//storeapi/Streaming/liveStreamList",
url:"https://dmmall.sdbairui.com/storeapi/Streaming/liveStreamList",
method:"POST",
headers:{
header:{
'Authorization' : 'Bearer' + " " + token
},
success(res){
@ -209,56 +305,130 @@ const RongIMLib = require('../../static/rongyun.js');
uni.request({
url:"https://dmmall.sdbairui.com/storeapi/member/memberInfo",
method:"POST",
headers:{
header:{
'Authorization' : 'Bearer' + " " + token
},
success(res){
console.log(res.data.data.memberInfo)
console.log(res.data)
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
}));
},
message: function(event){
var message = event.message;
console.log('收到新消息:', message);
},
status: function(event){
var status = event.status;
console.log('连接状态码:', status);
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
}
});
var user = {
token: uni.getStorageSync('rongyun')
};
im.connect(user).then(function(user) {
console.log('链接成功, 链接用户 id 为: ', user.id);
}).catch(function(error) {
console.log('链接失败: ', error.code, error.msg);
});
var chatRoom = im.ChatRoom.get({
id: a.id
});
chatRoom.join({
count: 20 // 进入后, 自动拉取 20 条聊天室最新消息
}).then(function() {
console.log('加入聊天室成功');
});
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));
},
@ -338,6 +508,10 @@ const RongIMLib = require('../../static/rongyun.js');
}
});
},
xianshi(){
this.show = true;
console.log(111)
},
guanbi(){
this.show = false
console.log(123)
@ -361,7 +535,7 @@ const RongIMLib = require('../../static/rongyun.js');
data:{
goods_id:arr.join(',')
},
headers:{
header:{
'Authorization' : 'Bearer' + " " + token
},
success(res){
@ -369,7 +543,7 @@ const RongIMLib = require('../../static/rongyun.js');
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