|
@@ -13,12 +13,19 @@ import { ActivatedRoute } from '@angular/router';
|
|
|
import { LiveComponent } from '../../../app/components/live/live.component';
|
|
|
import { LiveService } from '../../../services/live.service';
|
|
|
import { SharedModule } from '../../shared.module';
|
|
|
+import { AiChatService } from '../../../services/aichart.service';
|
|
|
@Component({
|
|
|
selector: 'app-link-page',
|
|
|
templateUrl: './link-page.component.html',
|
|
|
styleUrls: ['./link-page.component.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [IonicModule, FormsModule, LiveComponent, CommonModule,SharedModule],
|
|
|
+ imports: [
|
|
|
+ IonicModule,
|
|
|
+ FormsModule,
|
|
|
+ LiveComponent,
|
|
|
+ CommonModule,
|
|
|
+ SharedModule,
|
|
|
+ ],
|
|
|
})
|
|
|
export class LinkPageComponent implements OnInit {
|
|
|
@ViewChild('live') live!: LiveComponent;
|
|
@@ -27,11 +34,33 @@ export class LinkPageComponent implements OnInit {
|
|
|
room?: Parse.Object;
|
|
|
isFollow: boolean = false;
|
|
|
showTool: boolean = true; // 是否显示工具栏
|
|
|
+ showGiftModal: boolean = false; // 是否显示礼物弹窗
|
|
|
+ giftList: Array<any> = [];
|
|
|
+ tabs: Array<any> = [
|
|
|
+ {
|
|
|
+ name: '礼物',
|
|
|
+ val: 'all',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '专属礼物',
|
|
|
+ val: 'vip',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: '守护',
|
|
|
+ val: 'guard',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ activeTab: string = 'all';
|
|
|
+ currentGift: any; //当前礼物
|
|
|
+ giftCount: number = 1;
|
|
|
+ wallet: any = { balance: 0 };
|
|
|
+ isShowGiftModal: boolean = false; // 是否显示礼物动效弹窗
|
|
|
constructor(
|
|
|
public toastController: ToastController,
|
|
|
private loadingCtrl: LoadingController,
|
|
|
private alertController: AlertController,
|
|
|
private activateRoute: ActivatedRoute,
|
|
|
+ private aiServ: AiChatService,
|
|
|
public liveService: LiveService
|
|
|
) {}
|
|
|
|
|
@@ -51,6 +80,8 @@ export class LinkPageComponent implements OnInit {
|
|
|
message: '加载中',
|
|
|
});
|
|
|
this.getRoom();
|
|
|
+ this.giftList = await this.aiServ.getGift();
|
|
|
+ console.log(this.giftList);
|
|
|
loading.present();
|
|
|
loading.dismiss();
|
|
|
}
|
|
@@ -72,6 +103,12 @@ export class LinkPageComponent implements OnInit {
|
|
|
let r = await query.first();
|
|
|
this.isFollow = r?.id ? true : false;
|
|
|
}
|
|
|
+ async selectTab(val: string) {
|
|
|
+ if (this.activeTab === val) return;
|
|
|
+ this.giftList = await this.aiServ.getGift(val == 'all' ? '' : val);
|
|
|
+ this.activeTab = val;
|
|
|
+ this.currentGift = null;
|
|
|
+ }
|
|
|
/* 关注 */
|
|
|
async onCollection() {
|
|
|
let query = new Parse.Query('ProfileRadar');
|
|
@@ -101,7 +138,7 @@ export class LinkPageComponent implements OnInit {
|
|
|
this.isFollow = !this.isFollow;
|
|
|
}
|
|
|
/* 直播状态 */
|
|
|
- onChangeLiveStatus(e: any, type: string) {
|
|
|
+ async onChangeLiveStatus(e: any, type: string) {
|
|
|
e.cancelBubble = true;
|
|
|
switch (type) {
|
|
|
case 'audio':
|
|
@@ -113,10 +150,43 @@ export class LinkPageComponent implements OnInit {
|
|
|
case 'mute':
|
|
|
this.liveService.muteAudio();
|
|
|
break;
|
|
|
+ case 'gift':
|
|
|
+ let uid: any = Parse.User.current()?.id;
|
|
|
+ this.wallet = await this.aiServ.getWallet(uid);
|
|
|
+ this.showGiftModal = true;
|
|
|
+ break;
|
|
|
}
|
|
|
- // if (type == 'audio' || type == 'camera' || type == 'mute') {
|
|
|
- // this.liveService.tools[type] = !this.liveService.tools[type];
|
|
|
- // }
|
|
|
+ }
|
|
|
+ async sendGift() {
|
|
|
+ if (!this.currentGift?.id || this.giftCount < 1) return;
|
|
|
+ const alert = await this.alertController.create({
|
|
|
+ cssClass: 'my-custom-class',
|
|
|
+ header: '送出礼物',
|
|
|
+ message: `确定送出${this.giftCount}件${this.currentGift.name}吗`,
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: '取消',
|
|
|
+ role: 'cancel',
|
|
|
+ cssClass: 'secondary',
|
|
|
+ handler: (blah) => {},
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '确定',
|
|
|
+ handler: () => {
|
|
|
+ this.showGiftModal = false;
|
|
|
+ this.isShowGiftModal = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isShowGiftModal = false;
|
|
|
+ }, 5000);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ await alert.present();
|
|
|
+ }
|
|
|
+ onChange() {
|
|
|
+ this.giftCount = this.giftCount < 1 ? 1 : Math.floor(this.giftCount);
|
|
|
+ console.log(this.giftCount);
|
|
|
}
|
|
|
/* 结束直播 */
|
|
|
async endCall(e: any) {
|