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

Reviewed-on: http://git.luyuan.tk/luyuan/deming/pulls/237
This commit was merged in pull request #237.
This commit is contained in:
2020-08-18 15:11:24 +08:00
13 changed files with 109 additions and 69 deletions

File diff suppressed because one or more lines are too long

View File

@@ -6,6 +6,7 @@
*/
import GoEasyIM from './goeasy-im-1.0.9';
// import GoEasyIM from './goeasy-im-1.1.1';
import restApi from './restapi';
function Friend(uuid, name, avatar,time = "", text = "",date = "",unReadMessage = 0) {
@@ -38,6 +39,7 @@ function IMService() {
appkey:'BC-453aa755c4ea48148abefc55a86df283'
});
this.status = false
this.lianjie = false
//当前“我”
this.currentUser = null;
//我的好友
@@ -84,6 +86,7 @@ function IMService() {
IMService.prototype.login = function (uuid, name, avatar) {
//初始化当前用户
this.currentUser = new CurrentUser(uuid, name, avatar);
//初始化联系人信息,包括群
this.initialContacts();
return true;
@@ -105,7 +108,7 @@ IMService.prototype.initialContacts = function (friendList) {
const token = uni.getStorageSync('token');
console.log(token)
uni.request({
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
url:"http://mall.dmygkeji.com/api/Specialci/getAtwillUserInfo",
data:{
userId:i[0],
markup:1
@@ -203,6 +206,7 @@ IMService.prototype.resetFriendUnReadMessage = function (friend) {
//连接GoEasy
IMService.prototype.connectIM = function () {
//初始化IM相关的监听器
try {
this.initialIMListeners();
@@ -210,6 +214,7 @@ IMService.prototype.connectIM = function () {
console.log(123)
}
try {
console.log(this.currentUser)
this.im.connect({
id: this.currentUser.uuid,
data: {
@@ -226,7 +231,6 @@ IMService.prototype.connectIM = function () {
this.subscribeFriendsPresence();
}).catch(error => {
console.log('连接失败,请确保网络正常appkey和host正确code:' + error.code + " content:" + error.content);
this.connectIM()
});
} catch (error) {
console.log(12323)
@@ -244,6 +248,7 @@ IMService.prototype.initialIMListeners = function () {
this.im.on(GoEasyIM.EVENT.DISCONNECTED, () => {
console.log('连接断开.')
this.status = false
this.lianjie = false
});
//监听好友上下线
@@ -284,7 +289,7 @@ IMService.prototype.initialIMListeners = function () {
const token = uni.getStorageSync('token');
console.log(token)
uni.request({
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
url:"http://mall.dmygkeji.com/api/Specialci/getAtwillUserInfo",
data:{
userId:message.senderId,
markup:1
@@ -527,7 +532,7 @@ IMService.prototype.sendMessagesSetStorage = function (friendId,message){
const token = uni.getStorageSync('token');
console.log(token)
uni.request({
url:"https://dmmall.sdbairui.com/api/Specialci/getAtwillUserInfo",
url:"http://mall.dmygkeji.com/api/Specialci/getAtwillUserInfo",
data:{
userId:friendId,
markup:1
@@ -831,7 +836,7 @@ IMService.prototype.listenerGroupPresence = function () {
//查询和初始化在线用户列表和在线用户数
IMService.prototype.initialOnlineUsers = function (roomId) {
let self = this;
console.log(roomId)
//查询最新上线的用户列表
this.im.groupHereNow(roomId)
.then(result => {
@@ -850,7 +855,7 @@ IMService.prototype.initialOnlineUsers = function (roomId) {
if (e.code == 401) {
console.log("您还没有开通用户在线状态提醒登录goeasy->我的应用->查看详情->高级功能,自助开通.");
} else {
console.log(e);
console.log(e,1212);
}
});
//获取聊天室在线用户数
@@ -873,7 +878,12 @@ IMService.prototype.subscribePresence = function (roomId) {
}
//订阅聊天室消息
IMService.prototype.subscribeRoomMessage = function (room, user) {
IMService.prototype.subscribeRoomMessage = function (room) {
let user = {
id:this.currentUser.uuid,
nickname:this.currentUser.name,
avatar:this.currentUser.avatar
}
this.room = new Room(room.id, room.name, user);