|
@@ -41,6 +41,7 @@ export class ProfileComponent implements OnInit {
|
|
|
profiel?: Parse.Object; // 用户信息
|
|
|
user?: Parse.Object; // 查看用户
|
|
|
@ViewChild('preview') preview!: ImagePreviewComponent;
|
|
|
+ friends?: Parse.Object; // 好友
|
|
|
profile?: Parse.Object;
|
|
|
active: number = 0;
|
|
|
currenImg: string = '';
|
|
@@ -56,7 +57,7 @@ export class ProfileComponent implements OnInit {
|
|
|
@ViewChild('gift') gift!: GiftModalComponent;
|
|
|
iscall: boolean = false;
|
|
|
isLiveing: boolean = false; // 是否在直播通话中
|
|
|
- userStatus:string = 'OFFLINE';
|
|
|
+ userStatus: string = 'OFFLINE';
|
|
|
constructor(
|
|
|
private activateRoute: ActivatedRoute,
|
|
|
private router: Router,
|
|
@@ -71,25 +72,25 @@ export class ProfileComponent implements OnInit {
|
|
|
this.inviteCallback(data);
|
|
|
});
|
|
|
}
|
|
|
- get state(){
|
|
|
- let map:any = {
|
|
|
- "ONLINE":{
|
|
|
- val:'在线',
|
|
|
- color:'#28bb50',
|
|
|
+ get state() {
|
|
|
+ let map: any = {
|
|
|
+ ONLINE: {
|
|
|
+ val: '在线',
|
|
|
+ color: '#28bb50',
|
|
|
},
|
|
|
- "OFFLINE":{
|
|
|
- val:'离线',
|
|
|
- color:'#a1a1a1',
|
|
|
+ OFFLINE: {
|
|
|
+ val: '离线',
|
|
|
+ color: '#a1a1a1',
|
|
|
},
|
|
|
- "CONNECTING":{
|
|
|
- val:'忙线',
|
|
|
- color:'#cf1b24',
|
|
|
+ CONNECTING: {
|
|
|
+ val: '忙线',
|
|
|
+ color: '#cf1b24',
|
|
|
},
|
|
|
- "":{
|
|
|
- val:'离线',
|
|
|
- color:'#a1a1a1',
|
|
|
+ '': {
|
|
|
+ val: '离线',
|
|
|
+ color: '#a1a1a1',
|
|
|
},
|
|
|
- }
|
|
|
+ };
|
|
|
return map?.[this.userStatus] || map['OFFLINE'];
|
|
|
}
|
|
|
ngOnInit() {
|
|
@@ -97,14 +98,13 @@ export class ProfileComponent implements OnInit {
|
|
|
let id: any = params.get('id');
|
|
|
this.uid = id;
|
|
|
await this.refresh();
|
|
|
- this.userStatus = await this.connectTask.getState(this.uid,this.uid)
|
|
|
- this.getRoom();
|
|
|
+ this.userStatus = await this.connectTask.getState(this.uid, this.uid);
|
|
|
});
|
|
|
}
|
|
|
ngOnDestroy(): void {
|
|
|
//Called once, before the instance is destroyed.
|
|
|
//Add 'implements OnDestroy' to the class.
|
|
|
- if (this.isLiveing && this.uid !== this.currentUser?.id){
|
|
|
+ if (this.isLiveing && this.uid !== this.currentUser?.id) {
|
|
|
console.log('断开连接');
|
|
|
this.msgSer.unsubscribeMessage(this.uid);
|
|
|
}
|
|
@@ -114,6 +114,7 @@ export class ProfileComponent implements OnInit {
|
|
|
message: '加载中',
|
|
|
});
|
|
|
loading.present();
|
|
|
+ await this.getFriends();
|
|
|
await this.getProfile();
|
|
|
await this.getFollwState();
|
|
|
let res = await this.aiChatServ.getFansAndFollow(this.uid);
|
|
@@ -122,17 +123,20 @@ export class ProfileComponent implements OnInit {
|
|
|
let res1 = await this.aiChatServ.getGiftLogCount(this.uid);
|
|
|
this.numsObject.gift = res1.data[0].gift ?? 0;
|
|
|
this.giftList = await this.aiChatServ.getGiftList(this.uid, 16);
|
|
|
+ this.getRoom();
|
|
|
loading.dismiss();
|
|
|
}
|
|
|
- async getRoom() {
|
|
|
- let query = new Parse.Query('Room');
|
|
|
- query.equalTo('company', this.aiChatServ.company);
|
|
|
- query.equalTo('profile', this.profile?.id);
|
|
|
- // query.equalTo('state', true);
|
|
|
+ async getFriends() {
|
|
|
+ let query1 = new Parse.Query('Friends');
|
|
|
+ query1.equalTo('user', this.currentUser?.id);
|
|
|
+ query1.equalTo('friend', this.uid);
|
|
|
+ let query2 = new Parse.Query('Friends');
|
|
|
+ query2.equalTo('user', this.uid);
|
|
|
+ query2.equalTo('friend', this.currentUser?.id);
|
|
|
+ let query = Parse.Query.or(query1,query2);
|
|
|
query.notEqualTo('isDeleted', true);
|
|
|
- // query.select('objectId')
|
|
|
- let r = await query.first();
|
|
|
- this.room = r;
|
|
|
+ query.select('objectId','isPass');
|
|
|
+ this.friends = await query.first();
|
|
|
}
|
|
|
async getProfile() {
|
|
|
let queryProfile = new Parse.Query('Profile');
|
|
@@ -160,6 +164,16 @@ export class ProfileComponent implements OnInit {
|
|
|
let r = await query.first();
|
|
|
this.isFollow = r?.id ? true : false;
|
|
|
}
|
|
|
+ async getRoom() {
|
|
|
+ let query = new Parse.Query('Room');
|
|
|
+ query.equalTo('company', this.aiChatServ.company);
|
|
|
+ query.equalTo('profile', this.profile?.id);
|
|
|
+ // query.equalTo('state', true);
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
+ query.select('objectId');
|
|
|
+ let r = await query.first();
|
|
|
+ this.room = r;
|
|
|
+ }
|
|
|
/* 关注 */
|
|
|
async onCollection() {
|
|
|
let query = new Parse.Query('ProfileRadar');
|
|
@@ -196,6 +210,26 @@ export class ProfileComponent implements OnInit {
|
|
|
onShow() {
|
|
|
if (this.uid == this.currentUser?.id) this.isOpen = true;
|
|
|
}
|
|
|
+ async onFriend() {
|
|
|
+ if (this.friends?.id && !this.friends?.get('isPass')) {
|
|
|
+ const toast = await this.toastController.create({
|
|
|
+ message: '已申请,等待对方同意',
|
|
|
+ color: 'warning',
|
|
|
+ duration: 1500,
|
|
|
+ });
|
|
|
+ toast.present();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.friends?.id) {
|
|
|
+ let obj = Parse.Object.extend('Friends');
|
|
|
+ this.friends = new obj();
|
|
|
+ this.friends?.set('user', this.currentUser?.toPointer());
|
|
|
+ this.friends?.set('friend', this.user?.toPointer());
|
|
|
+ this.friends?.set('company', this.aiChatServ.company);
|
|
|
+ this.friends?.set('channel', this.user?.id + '-' + this.currentUser?.id);
|
|
|
+ await this.friends?.save();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/* 更换背景 */
|
|
|
async onSaveBackGround(e: any) {
|
|
@@ -239,18 +273,18 @@ export class ProfileComponent implements OnInit {
|
|
|
});
|
|
|
}
|
|
|
toMsg() {
|
|
|
- this.router.navigate(['live/chat/' + this.uid]);
|
|
|
+ this.router.navigate(['live/chat/' + this.friends?.get('channel')]);
|
|
|
}
|
|
|
async toLiveContact() {
|
|
|
- this.userStatus = await this.connectTask.getState(this.uid,this.uid)
|
|
|
- if(this.userStatus !== 'ONLINE'){
|
|
|
+ this.userStatus = await this.connectTask.getState(this.uid, this.uid);
|
|
|
+ if (this.userStatus !== 'ONLINE') {
|
|
|
const toast = await this.toastController.create({
|
|
|
message: '对方不在线或忙线中',
|
|
|
color: 'warning',
|
|
|
duration: 1500,
|
|
|
});
|
|
|
toast.present();
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
console.log(this.userStatus);
|
|
|
const alert = await this.alertController.create({
|
|
@@ -287,7 +321,7 @@ export class ProfileComponent implements OnInit {
|
|
|
toast.present();
|
|
|
if (event) {
|
|
|
this.isLiveing = true;
|
|
|
- this.userStatus = await this.connectTask.getState(this.uid,this.uid)
|
|
|
+ this.userStatus = await this.connectTask.getState(this.uid, this.uid);
|
|
|
this.router.navigate(['live/link-room/' + this.room?.id]);
|
|
|
}
|
|
|
}
|