链接登录退出
This commit is contained in:
parent
43e09e977d
commit
cb95d1ead1
6
App.vue
6
App.vue
@ -26,6 +26,12 @@
|
||||
plus.navigator.closeSplashscreen();
|
||||
},3000)
|
||||
// #endif
|
||||
},
|
||||
onShow(){
|
||||
|
||||
},
|
||||
onHide(){
|
||||
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['loginIn']),
|
||||
|
@ -184,12 +184,7 @@
|
||||
me.loginIn(res.data.token); //存储一个字符传值
|
||||
// 缓存用户的信息
|
||||
uni.setStorageSync('user_info',res.data);
|
||||
let im = this.imService
|
||||
im.status = false
|
||||
console.log(123)
|
||||
im.lianjie = false
|
||||
im = new IMService();
|
||||
console.log(im.lianjie)
|
||||
this.imService.disconnect()
|
||||
if (res.data.member.has_labels) {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
|
@ -91,10 +91,6 @@
|
||||
},
|
||||
async loginOut() {
|
||||
let im = this.imService
|
||||
await im.disconnect()
|
||||
im.lianjie = false
|
||||
im = new IMService();
|
||||
console.log(im.lianjie)
|
||||
this.logout();
|
||||
uni.redirectTo({
|
||||
url: "../../pageA/login/login",
|
||||
|
@ -267,43 +267,42 @@
|
||||
indexad,
|
||||
darenItem
|
||||
},
|
||||
async onShow() {
|
||||
onShow() {
|
||||
this.page = 1;
|
||||
if (this.page != 1) {
|
||||
}
|
||||
console.log(this.imService.lianjie,this.imService.status)
|
||||
if(!this.imService.status && this.$store.state.hasLogin && !this.imService.lianjie){
|
||||
this.isNewmembervoucher();
|
||||
console.log(this.imService.status)
|
||||
if(!this.imService.status && this.$store.state.hasLogin){
|
||||
const user = uni.getStorageSync('user_info');
|
||||
// console.log(user)
|
||||
this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar)
|
||||
await this.imService.connectIM()
|
||||
this.imService.connectIM()
|
||||
|
||||
}else if(!this.imService.status && !this.imService.lianjie){
|
||||
await this.$u.api.getDefaultAvatar().then((res)=>{
|
||||
}else if(!this.imService.status){
|
||||
this.$u.api.getDefaultAvatar().then((res)=>{
|
||||
console.log(res)
|
||||
uni.setStorageSync("morenimg",res.data.avatar)
|
||||
this.imService.login(new Date().getTime(),"123",res.data.avatar)
|
||||
this.imService.connectIM()
|
||||
console.log("用户信息")
|
||||
})
|
||||
console.log("链接")
|
||||
await this.imService.connectIM()
|
||||
|
||||
}
|
||||
if(!this.imService.status && !this.imService.lianjie){
|
||||
console.log("1212")
|
||||
this.imService.lianjie = true
|
||||
let that = this
|
||||
setTimeout(function(){
|
||||
that.imService.disconnect()
|
||||
console.log("guanbi")
|
||||
},1000)
|
||||
setTimeout(function(){
|
||||
console.log("lianjie")
|
||||
that.imService.connectIM()
|
||||
},2000)
|
||||
}
|
||||
|
||||
// if(!this.imService.status && !this.imService.lianjie){
|
||||
// console.log("1212")
|
||||
// this.imService.lianjie = true
|
||||
// let that = this
|
||||
// setTimeout(function(){
|
||||
// that.imService.disconnect()
|
||||
// console.log("guanbi")
|
||||
// },1000)
|
||||
// setTimeout(function(){
|
||||
// console.log("lianjie")
|
||||
// that.imService.connectIM()
|
||||
// },2000)
|
||||
// }
|
||||
|
||||
// if (this.hasLogin) {
|
||||
// this.isNewmembervoucher();
|
||||
// }
|
||||
@ -311,10 +310,11 @@
|
||||
async onLoad(){
|
||||
this.articleList = [];
|
||||
this.getArticlelist();
|
||||
this.getSwiper();
|
||||
this.getSwiper();
|
||||
this.isNewmembervoucher();
|
||||
|
||||
// 优惠券
|
||||
// if(this.$store.state.hasLogin){
|
||||
// this.isNewmembervoucher();
|
||||
// const user = uni.getStorageSync('user_info');
|
||||
// // console.log(user)
|
||||
// this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar)
|
||||
|
@ -417,32 +417,13 @@ export default {
|
||||
// that.list= res.data.data
|
||||
}
|
||||
})
|
||||
//当前用户
|
||||
var currentUser = {}
|
||||
if(this.$store.state.hasLogin){
|
||||
const user = uni.getStorageSync('user_info');
|
||||
currentUser = {
|
||||
id : user.member.member_id,
|
||||
nickname : user.member.member_nickname,
|
||||
avatar: user.member.member_avatar
|
||||
};
|
||||
}else{
|
||||
const user = uni.getStorageSync('morenimg');
|
||||
currentUser = {
|
||||
id : new Date().getTime(),
|
||||
nickname : "123",
|
||||
avatar: user
|
||||
};
|
||||
}
|
||||
|
||||
var room = {
|
||||
id : a.rid + "",
|
||||
name : a.rid + ""
|
||||
};
|
||||
that.chatRoomService = getApp().globalData.im
|
||||
console.log(room,currentUser)
|
||||
//构造chatRoomService
|
||||
that.chatRoomService.subscribeRoomMessage(room,currentUser)
|
||||
that.chatRoomService.subscribeRoomMessage(room)
|
||||
//获取当前聊天室数据
|
||||
that.room = that.chatRoomService.room;
|
||||
that.chatRoomService.initialWhenOnlineUserChange(that.newpeople)
|
||||
|
@ -5,8 +5,8 @@
|
||||
* @Last Modified time: 2020-4-21 15:01:41
|
||||
*/
|
||||
|
||||
// import GoEasyIM from './goeasy-im-1.0.9';
|
||||
import GoEasyIM from './goeasy-im-1.1.1';
|
||||
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) {
|
||||
@ -86,6 +86,7 @@ function IMService() {
|
||||
IMService.prototype.login = function (uuid, name, avatar) {
|
||||
//初始化当前用户
|
||||
this.currentUser = new CurrentUser(uuid, name, avatar);
|
||||
|
||||
//初始化联系人信息,包括群
|
||||
this.initialContacts();
|
||||
return true;
|
||||
@ -205,6 +206,7 @@ IMService.prototype.resetFriendUnReadMessage = function (friend) {
|
||||
//连接GoEasy
|
||||
IMService.prototype.connectIM = function () {
|
||||
//初始化IM相关的监听器
|
||||
|
||||
try {
|
||||
this.initialIMListeners();
|
||||
|
||||
@ -212,6 +214,7 @@ IMService.prototype.connectIM = function () {
|
||||
console.log(123)
|
||||
}
|
||||
try {
|
||||
console.log(this.currentUser)
|
||||
this.im.connect({
|
||||
id: this.currentUser.uuid,
|
||||
data: {
|
||||
@ -245,6 +248,7 @@ IMService.prototype.initialIMListeners = function () {
|
||||
this.im.on(GoEasyIM.EVENT.DISCONNECTED, () => {
|
||||
console.log('连接断开.')
|
||||
this.status = false
|
||||
this.lianjie = false
|
||||
});
|
||||
|
||||
//监听好友上下线
|
||||
@ -832,7 +836,7 @@ IMService.prototype.listenerGroupPresence = function () {
|
||||
//查询和初始化在线用户列表和在线用户数
|
||||
IMService.prototype.initialOnlineUsers = function (roomId) {
|
||||
let self = this;
|
||||
|
||||
console.log(roomId)
|
||||
//查询最新上线的用户列表
|
||||
this.im.groupHereNow(roomId)
|
||||
.then(result => {
|
||||
@ -851,7 +855,7 @@ IMService.prototype.initialOnlineUsers = function (roomId) {
|
||||
if (e.code == 401) {
|
||||
console.log("您还没有开通用户在线状态提醒,登录goeasy->我的应用->查看详情->高级功能,自助开通.");
|
||||
} else {
|
||||
console.log(e);
|
||||
console.log(e,1212);
|
||||
}
|
||||
});
|
||||
//获取聊天室在线用户数
|
||||
@ -874,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);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user