demingshangjia/pages/release/zhibo.nvue

389 lines
13 KiB
Plaintext
Raw Normal View History

2020-07-24 08:57:03 +08:00
<template>
2020-07-25 08:57:32 +08:00
<div>
2020-07-24 08:57:03 +08:00
<live-pusher id='livePusher' ref="livePusher" class="livePusher" :url="url"
2020-07-30 08:46:35 +08:00
mode="SD" :muted="false" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2"
2020-07-24 08:57:03 +08:00
aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error = "error"
:style="{'height':height + 'px'}"
></live-pusher>
2020-07-25 08:57:32 +08:00
<div class="bottom" :style="{'height':height + 'px'}" v-if="show" @click="show = false">
<div class="tanchuceng" @click="zuzhi">
<div class="head">
<div style="flex-direction: row;align-items:center">
<text class="title">全部商品</text>
<text class="num">2件</text>
</div>
<!-- <div class="add">
<text style="font-size:28rpx;color: #fff;text-align:center">添加/管理商品</text>
</div> -->
</div>
<list class="list">
<cell class="item" v-for="(i,j) in list" @click="xuanzhong(j)">
<image class="shopimg" :src="i.goods_image"></image>
<div class="info">
<div>
<text style="font-size:26rpx;colro:#333;margin-top:12rpx;lines:1;text-overflow:ellipsis">{{i.goods_name}}</text>
<text style="font-size:24rpx;color:#333;margin-top:14rpx;lines:1;text-overflow:ellipsis">{{i.goods_advword}}</text>
</div>
<div style="flex-direction: row; align-items: flex-end;">
<text style="font-size:28rpx;color:#FF3131">¥{{i.goods_price}}</text>
<text style="font-size:26rpx;color:#999">¥{{i.goods_marketprice}}</text>
</div>
</div>
<image :src="'../../static/image/release/' + (i.putaway == 1 ? 'on' : 'off') + '.png'" style="width:55rpx;height:35rpx;margin-top:120rpx;margin-left:150rpx"></image>
</cell>
</list>
</div>
</div>
2020-07-25 14:53:19 +08:00
<div class="user">
</div>
<div style="position: fixed;top: 60rpx;left: 30rpx;flex-direction: row;align-items:center">
<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>
</div>
</div>
2020-07-24 08:57:03 +08:00
<!-- <button class="btn" @click="start">开始推流1</button>
<button class="btn" @click="pause">暂停推流</button>
<button class="btn" @click="resume">resume</button>
<button class="btn" @click="stop">停止推流</button>
<button class="btn" @click="snapshot">快照</button>
2020-07-25 08:57:32 +08:00
<button class="btn" @click="startPrediv">开启摄像头预览</button>
<button class="btn" @click="stopPrediv">关闭摄像头预览</button>
2020-07-24 08:57:03 +08:00
rtmp://107268.livepush.myqcloud.com/live/26?txSecret=826e36f52669ebf9290644b82a1d8b33&txTime=5F1A84E4
<button class="btn" @click="switchCamera">切换摄像头</button> -->
2020-07-25 08:57:32 +08:00
</div>
2020-07-24 08:57:03 +08:00
</template>
<style lang="scss" scoped>
2020-07-25 14:53:19 +08:00
.username{
font-size: 24rpx;
color: #fff;
lines:1;
text-overflow:ellipsis
}
.userinfo{
height: 60rpx;
margin-left: 20rpx;
justify-content: space-between;
width: 200rpx;
}
.userhead{
width: 70rpx;
height: 70rpx;
// position: fixed;
// top: 60rpx;
// left: 30rpx;
border-radius: 35rpx;
}
.user{
width: 308rpx;
height: 70rpx;
border-radius: 35rpx;
background-color: #000;
opacity:0.2;
position: fixed;
top: 60rpx;
left: 30rpx;
}
2020-07-25 08:57:32 +08:00
.info{
height: 160rpx;
justify-content: space-between;
margin-left: 10rpx;
width: 304rpx;
}
.shopimg{
width: 160rpx;
height: 160rpx;
background-color: #0f0;
}
.item{
width: 690rpx;
height: 200rpx;
border-bottom-width: 2rpx;
border-style: solid;
border-color: #ECECEC;
display: flex;
flex-direction: row;
align-items: center;
}
.list{
width: 750rpx;
height: 694rpx;
padding-left: 30rpx;
padding-right: 30rpx;
}
.add{
width: 221rpx;
height: 40rpx;
background-color: #FF780F;
border-radius: 20rpx;
justify-content: center;
margin-right: 30rpx;
}
.num{
font-size: 26rpx;
color: #FF3131;
margin-left: 30rpx;
}
2020-07-24 08:57:03 +08:00
.bottom{
width: 750rpx;
position: fixed;
top:0;
z-index: 10;
}
2020-07-25 08:57:32 +08:00
.head{
width: 750rpx;
height: 88rpx;
border-bottom-width: 2rpx;
border-style: solid;
border-color: #ECECEC;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.title{
font-size: 30rpx;
color:#333;
margin-left: 30rpx;
}
2020-07-24 08:57:03 +08:00
.tanchuceng{
width: 750rpx;
height: 782rpx;
position: fixed;
bottom: 0;
border-top-left-radius:20rpx;
border-top-left-radius:20rpx;
background-color: #fff;
transition: bottom 0.5s;
z-index: 20;
2020-07-25 08:57:32 +08:00
2020-07-24 08:57:03 +08:00
}
</style>
<script>
2020-07-30 08:46:35 +08:00
const RongIMLib = require('../../static/rongyun.js');
2020-07-24 08:57:03 +08:00
export default {
data: {
fil: true,
url:'',
height:0,
2020-07-25 08:57:32 +08:00
show:true,
2020-07-25 14:53:19 +08:00
list:[],
info:{},
im:{}
2020-07-24 08:57:03 +08:00
},
onReady() {
// 注意需要在onReady中 或 onLoad 延时
this.context = uni.createLivePusherContext("livePusher", this);
this.startPreview()
let that = this
uni.getSystemInfo({
success(a){
console.log(a.windowHeight)
that.height = a.windowHeight
// that.start()
}
})
},
onLoad(a){
this.url = a.url.replace("*","&")
2020-07-25 08:57:32 +08:00
let that = this
const token = uni.getStorageSync('token');
2020-07-30 08:46:35 +08:00
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
// }
// })
2020-07-25 14:53:19 +08:00
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')
};
2020-07-30 08:46:35 +08:00
console.log(user,123)
2020-07-25 14:53:19 +08:00
im.connect(user).then(function(user) {
console.log('链接成功, 链接用户 id 为: ', user.id);
}).catch(function(error) {
2020-07-30 08:46:35 +08:00
console.log('链接失败: ', error.code, error);
2020-07-25 14:53:19 +08:00
});
var chatRoom = im.ChatRoom.get({
id: a.id
2020-07-30 08:46:35 +08:00
})
2020-07-25 14:53:19 +08:00
chatRoom.join({
count: 20 // 进入后, 自动拉取 20 条聊天室最新消息
}).then(function() {
console.log('加入聊天室成功');
2020-07-30 08:46:35 +08:00
}).catch((err)=>{
console.log(err,262)
})
2020-07-25 08:57:32 +08:00
},
2020-07-24 08:57:03 +08:00
methods: {
statechange(e) {
console.log("statechange:" + JSON.stringify(e));
},
netstatus(e) {
2020-07-25 08:57:32 +08:00
// console.log("netstatus:" + JSON.stringify(e));
2020-07-24 08:57:03 +08:00
},
error(e) {
console.log("error:" + JSON.stringify(e));
},
start: function() {
console.log(this.url)
this.context.start({
success: (a) => {
console.log("livePusher.start:" + JSON.stringify(a));
}
});
},
close: function() {
this.context.close({
success: (a) => {
console.log("livePusher.close:" + JSON.stringify(a));
}
});
},
snapshot: function() {
this.context.snapshot({
success: (e) => {
console.log(JSON.stringify(e));
}
});
},
resume: function() {
this.context.resume({
success: (a) => {
console.log(this.url + '12')
console.log("livePusher.resume:" + JSON.stringify(a));
}
});
},
pause: function() {
this.context.pause({
success: (a) => {
console.log("livePusher.pause:" + JSON.stringify(a));
}
});
},
stop: function() {
this.context.stop({
success: (a) => {
console.log(JSON.stringify(a));
}
});
},
switchCamera: function() {
this.context.switchCamera({
success: (a) => {
console.log("livePusher.switchCamera:" + JSON.stringify(a));
}
});
},
startPreview: function() {
let that = this
this.context.startPreview({
success: (a) => {
console.log("livePusher.startPreview:" + JSON.stringify(a));
that.start()
}
});
},
stopPreview: function() {
this.context.stopPreview({
success: (a) => {
console.log("livePusher.stopPreview:" + JSON.stringify(a));
}
});
},
guanbi(){
this.show = false
console.log(123)
},
zuzhi(event){
event.stopPropagation();
2020-07-25 08:57:32 +08:00
},
xuanzhong(i){
this.list[i].putaway = this.list[i].putaway == 0 ? 1 : 0
const token = uni.getStorageSync('token');
let arr = []
for(let i in this.list){
if(this.list[i].putaway == 1){
arr.push(this.list[i].goods_id)
}
}
let that = this
uni.request({
url:"https://dmmall.sdbairui.com/storeapi/Streaming/updateGoods",
method:"POST",
data:{
goods_id:arr.join(',')
},
headers:{
'Authorization' : 'Bearer' + " " + token
},
success(res){
console.log(res)
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
}
})
}
})
2020-07-24 08:57:03 +08:00
}
}
}
</script>