引入融云

This commit is contained in:
luyuan 2020-07-25 14:53:19 +08:00
parent 7b8ddc734c
commit 49e80c48c0
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
4 changed files with 10670 additions and 3 deletions

View File

@ -69,6 +69,7 @@
}else{
uni.setStorageSync("token",res.data.token)
uni.setStorageSync("userinfo",res.data)
uni.setStorageSync('rongyun',res.data.rongcloud_token)
this.$u.route({
url:"/pages/index/index",
type:"switchTab"

View File

@ -110,7 +110,8 @@
this.$u.route({
url:"/pages/release/zhibo",
params:{
url:res.data.url.replace("&","*")
url:res.data.url.replace("&","*"),
id:res.data.chat_id
}
})
})

View File

@ -35,7 +35,15 @@
</div>
</div>
<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>
<!-- <button class="btn" @click="start">开始推流1</button>
<button class="btn" @click="pause">暂停推流</button>
<button class="btn" @click="resume">resume</button>
@ -48,6 +56,38 @@
</div>
</template>
<style lang="scss" scoped>
.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;
}
.info{
height: 160rpx;
justify-content: space-between;
@ -126,13 +166,16 @@
}
</style>
<script>
const RongIMLib = require('../../static/rongyun.js');
export default {
data: {
fil: true,
url:'',
height:0,
show:true,
list:[]
list:[],
info:{},
im:{}
},
onReady() {
// 注意需要在onReady中 或 onLoad 延时
@ -163,6 +206,57 @@
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
}));
},
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')
};
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('加入聊天室成功');
});
},
methods: {
statechange(e) {

10571
static/rongyun.js Normal file

File diff suppressed because one or more lines are too long