|
@@ -8,16 +8,17 @@ import { ImagePreviewComponent } from '../../../app/components/image-preview/ima
|
|
|
import { AiChatService } from '../../../services/aichart.service';
|
|
|
import { UploadComponent } from '../../../app/components/upload/upload.component';
|
|
|
import { GiftModalComponent } from '../../../app/components/gift-modal/gift-modal.component';
|
|
|
-import { MessageService } from '../../../services/message.service';
|
|
|
+// import { MessageService } from '../../../services/message.service';
|
|
|
import { ConnectTaskService } from '../../../services/connectTask.service';
|
|
|
import { getBirthdatByIdNo,getConstellation } from '../../../services/utils';
|
|
|
import {
|
|
|
ionicStandaloneModules,
|
|
|
- AlertController,
|
|
|
+ // AlertController,
|
|
|
LoadingController,
|
|
|
ToastController,
|
|
|
} from '../../ionic-standalone.modules';
|
|
|
import { AccountService } from '../../../services/account.service';
|
|
|
+import { CallModalComponent } from '../../../app/components/call-modal/call-modal.component';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-profile',
|
|
@@ -33,11 +34,14 @@ import { AccountService } from '../../../services/account.service';
|
|
|
ImagePreviewComponent,
|
|
|
UploadComponent,
|
|
|
GiftModalComponent,
|
|
|
+ CallModalComponent
|
|
|
],
|
|
|
providers: [DatePipe],
|
|
|
})
|
|
|
export class ProfileComponent implements OnInit {
|
|
|
// @ViewChild('upload') upload!: UploadComponent;
|
|
|
+ @ViewChild('call') call!: CallModalComponent;
|
|
|
+
|
|
|
uid: string = '';
|
|
|
currentUser?: Parse.Object = Parse.User.current(); //当前登录用户
|
|
|
user?: Parse.Object; // 查看用户
|
|
@@ -54,25 +58,22 @@ export class ProfileComponent implements OnInit {
|
|
|
isFollow: boolean = false;
|
|
|
giftList: any[] = []; //礼物
|
|
|
isOpen: boolean = false; //打开弹窗
|
|
|
- room?: Parse.Object;
|
|
|
+ // room?: Parse.Object;
|
|
|
@ViewChild('gift') gift!: GiftModalComponent;
|
|
|
- iscall: boolean = false;
|
|
|
- isLiveing: boolean = false; // 是否在直播通话中
|
|
|
+ // iscall: boolean = false;
|
|
|
+ // isLiveing: boolean = false; // 是否在直播通话中
|
|
|
userStatus: string = 'OFFLINE';
|
|
|
constructor(
|
|
|
private activateRoute: ActivatedRoute,
|
|
|
private router: Router,
|
|
|
- public toastController: ToastController,
|
|
|
- public loadingCtrl: LoadingController,
|
|
|
+ private toastController: ToastController,
|
|
|
+ private loadingCtrl: LoadingController,
|
|
|
private aiChatServ: AiChatService,
|
|
|
- private alertController: AlertController,
|
|
|
+ // private alertController: AlertController,
|
|
|
+ // private msgSer: MessageService,
|
|
|
private connectTask: ConnectTaskService,
|
|
|
- private msgSer: MessageService,
|
|
|
public accServ: AccountService,
|
|
|
) {
|
|
|
- this.msgSer.event$.subscribe((data) => {
|
|
|
- this.inviteCallback(data);
|
|
|
- });
|
|
|
}
|
|
|
get state() {
|
|
|
let map: any = {
|
|
@@ -118,12 +119,10 @@ export class ProfileComponent implements OnInit {
|
|
|
});
|
|
|
}
|
|
|
ngOnDestroy(): void {
|
|
|
- //Called once, before the instance is destroyed.
|
|
|
- //Add 'implements OnDestroy' to the class.
|
|
|
- if (!this.isLiveing && this.uid !== this.currentUser?.id) {
|
|
|
- console.log('断开连接');
|
|
|
- this.msgSer?.unsubscribeMessage(this.uid);
|
|
|
- }
|
|
|
+ // if (!this.isLiveing && this.uid !== this.currentUser?.id) {
|
|
|
+ // console.log('断开连接');
|
|
|
+ // this.msgSer?.unsubscribeMessage(this.uid);
|
|
|
+ // }
|
|
|
}
|
|
|
async refresh() {
|
|
|
const loading = await this.loadingCtrl.create({
|
|
@@ -139,7 +138,7 @@ 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();
|
|
|
+ // this.getRoom();
|
|
|
loading.dismiss();
|
|
|
}
|
|
|
async getFriends() {
|
|
@@ -181,16 +180,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 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');
|
|
@@ -298,96 +297,6 @@ export class ProfileComponent implements OnInit {
|
|
|
toMsg() {
|
|
|
this.router.navigate(['live/chat/' + this.friends?.get('channel')]);
|
|
|
}
|
|
|
- async toLiveContact() {
|
|
|
- if(this.userStatus == 'REFUSE'){
|
|
|
- const toast = await this.toastController.create({
|
|
|
- message: '对方已设置免打扰状态',
|
|
|
- color: 'warning',
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- toast.present();
|
|
|
- return
|
|
|
- }
|
|
|
- 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;
|
|
|
- }
|
|
|
- const alert = await this.alertController.create({
|
|
|
- cssClass: 'my-custom-class',
|
|
|
- header: '邀请通话',
|
|
|
- backdropDismiss: false,
|
|
|
- message: '你将与对方发起私聊通话',
|
|
|
- buttons: [
|
|
|
- {
|
|
|
- text: '取消',
|
|
|
- role: 'cancel',
|
|
|
- handler: (blah) => {},
|
|
|
- },
|
|
|
- {
|
|
|
- text: '确定',
|
|
|
- cssClass: 'secondary',
|
|
|
- handler: () => {
|
|
|
- this.sendVideoCallInvite();
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- });
|
|
|
- await alert.present();
|
|
|
- }
|
|
|
- async inviteCallback(event: boolean) {
|
|
|
- console.log(event);
|
|
|
- if (event == undefined) return;
|
|
|
- this.iscall = false;
|
|
|
- const toast = await this.toastController.create({
|
|
|
- message: `对方${event ? '已接受' : '拒绝'}通话邀请`,
|
|
|
- color: event ? 'success' : 'warning',
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- toast.present();
|
|
|
- if (event) {
|
|
|
- this.isLiveing = true;
|
|
|
- // this.userStatus = await this.connectTask.getState(this.uid, this.uid);
|
|
|
- this.router.navigate(['live/link-room/' + this.room?.id]);
|
|
|
- }
|
|
|
- }
|
|
|
- async sendVideoCallInvite() {
|
|
|
- let second = await this.aiChatServ.get_duration(
|
|
|
- this.room?.id!,
|
|
|
- this.currentUser?.id!
|
|
|
- );
|
|
|
- if (second < 120) {
|
|
|
- const toast = await this.toastController.create({
|
|
|
- message: '通话时长不足2分钟,请充值后再试通',
|
|
|
- color: 'warning',
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- toast.present();
|
|
|
- return;
|
|
|
- }
|
|
|
- this.iscall = true;
|
|
|
- // this.router.navigate(['live/link-room/' + this.room?.id]);
|
|
|
- await this.msgSer.subscribeMessage(this.uid, {
|
|
|
- message: true,
|
|
|
- presence: true,
|
|
|
- }); //进入对方主播频道发送聊天邀请
|
|
|
- this.msgSer.publishMessage('USERCALLINVITATION', this.uid);
|
|
|
- }
|
|
|
- async onCloseCall() {
|
|
|
- this.iscall = false;
|
|
|
- const toast = await this.toastController.create({
|
|
|
- message: '已取消视频通话邀请',
|
|
|
- color: 'warning',
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- toast.present();
|
|
|
- this.msgSer.publishMessage('CLOASEINVITATION', this.uid);
|
|
|
- }
|
|
|
onSendGift() {
|
|
|
console.log('点击送出礼物');
|
|
|
// this.liveService.get_duration()
|