xbx #125
@ -8,14 +8,15 @@
|
||||
import GoEasyIM from './goeasy-im-1.0.9';
|
||||
import restApi from './restapi';
|
||||
|
||||
function Friend(uuid, name, avatar,time = "") {
|
||||
function Friend(uuid, name, avatar,time = "", text = "",date = "") {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.avatar = avatar;
|
||||
this.online = false;
|
||||
this.unReadMessage = 0;
|
||||
this.text = "";
|
||||
this.text = text;
|
||||
this.time = time;
|
||||
this.date = date
|
||||
}
|
||||
|
||||
function Group(uuid, name, avatar) {
|
||||
@ -90,6 +91,7 @@ IMService.prototype.initialContacts = function (friendList) {
|
||||
}
|
||||
value = JSON.parse(value)
|
||||
let that = this
|
||||
console.log(value)
|
||||
for(let i of value){
|
||||
const token = uni.getStorageSync('token');
|
||||
console.log(token)
|
||||
@ -104,9 +106,28 @@ IMService.prototype.initialContacts = function (friendList) {
|
||||
},
|
||||
success(res){
|
||||
console.log(res)
|
||||
that.friends[i[0]] = new Friend(res.data.data.member_id, res.data.data.member_nickname, res.data.data.member_avatar,i[1]);
|
||||
that.friends[i[0]] = new Friend(res.data.data.member_id, res.data.data.member_nickname, res.data.data.member_avatar,i[1],i[2]);
|
||||
console.log(that.friends)
|
||||
let sorts = function (friends){
|
||||
let paixu = function (a,b){
|
||||
if(a.date > b.date){
|
||||
return 0;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
friends.sort(paixu)
|
||||
|
||||
}
|
||||
that.friendsarr = []
|
||||
for(let i in that.friends){
|
||||
console.log(i)
|
||||
that.friendsarr.push(that.friends[i])
|
||||
}
|
||||
sorts(that.friendsarr)
|
||||
that.onFriendListChange(that.friends);
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -235,7 +256,7 @@ IMService.prototype.initialIMListeners = function () {
|
||||
// return ;
|
||||
let sorts = function (friends){
|
||||
let paixu = function (a,b){
|
||||
if(a.item > b.item){
|
||||
if(a.date > b.date){
|
||||
return 0;
|
||||
}else{
|
||||
return 1;
|
||||
@ -267,6 +288,7 @@ IMService.prototype.initialIMListeners = function () {
|
||||
friend.unReadMessage++;
|
||||
friend.text = message.type != "text" ? "其他消息" : message.payload.text
|
||||
let time = new Date(message.timestamp)
|
||||
friend.date = message.timestamp
|
||||
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||
console.log(that.friends)
|
||||
that.friendsarr = []
|
||||
@ -277,9 +299,11 @@ IMService.prototype.initialIMListeners = function () {
|
||||
sorts(that.friendsarr)
|
||||
let arr = []
|
||||
for(let i in that.friends){
|
||||
arr.push([that.friends[i].uuid,that.friends[i].time])
|
||||
uni.setStorageSync('imlist',JSON.stringify(arr))
|
||||
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date])
|
||||
}
|
||||
console.log(arr)
|
||||
uni.setStorageSync('imlist',JSON.stringify(arr))
|
||||
|
||||
that.onFriendListChange(that.friends);
|
||||
|
||||
}
|
||||
@ -289,6 +313,7 @@ IMService.prototype.initialIMListeners = function () {
|
||||
friend.unReadMessage++;
|
||||
friend.text = message.type != "text" ? "其他消息" : message.payload.text
|
||||
let time = new Date(message.timestamp)
|
||||
friend.date = message.timestamp
|
||||
friend.time = time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
|
||||
console.log(this.friends)
|
||||
that.friendsarr = []
|
||||
@ -296,6 +321,12 @@ IMService.prototype.initialIMListeners = function () {
|
||||
that.friendsarr.push(this.friends[i])
|
||||
}
|
||||
sorts(that.friendsarr)
|
||||
let arr = []
|
||||
for(let i in that.friends){
|
||||
arr.push([that.friends[i].uuid,that.friends[i].time,that.friends[i].text,that.friends[i].date])
|
||||
}
|
||||
console.log(arr)
|
||||
uni.setStorageSync('imlist',JSON.stringify(arr))
|
||||
this.onFriendListChange(this.friends);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user