|
@@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { FormsModule } from '@angular/forms';
|
|
import * as Parse from 'parse';
|
|
import * as Parse from 'parse';
|
|
|
|
+import { Swiper } from 'swiper';
|
|
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { LiveComponent } from '../../../app/components/live/live.component';
|
|
import { LiveComponent } from '../../../app/components/live/live.component';
|
|
@@ -15,6 +16,7 @@ import {
|
|
LoadingController,
|
|
LoadingController,
|
|
ToastController,
|
|
ToastController,
|
|
} from '../../ionic-standalone.modules';
|
|
} from '../../ionic-standalone.modules';
|
|
|
|
+import { MessageService } from '../../../services/message.service';
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-link-page',
|
|
selector: 'app-link-page',
|
|
templateUrl: './link-page.component.html',
|
|
templateUrl: './link-page.component.html',
|
|
@@ -38,12 +40,17 @@ export class LinkPageComponent implements OnInit {
|
|
showTool: boolean = true; // 是否显示工具栏
|
|
showTool: boolean = true; // 是否显示工具栏
|
|
@ViewChild('gift') gift!: GiftModalComponent;
|
|
@ViewChild('gift') gift!: GiftModalComponent;
|
|
|
|
|
|
|
|
+ text: string = '';
|
|
|
|
+ disabled: boolean = false;
|
|
|
|
+ showEmoji: boolean = false;
|
|
|
|
+
|
|
constructor(
|
|
constructor(
|
|
public toastController: ToastController,
|
|
public toastController: ToastController,
|
|
private loadingCtrl: LoadingController,
|
|
private loadingCtrl: LoadingController,
|
|
private alertController: AlertController,
|
|
private alertController: AlertController,
|
|
private activateRoute: ActivatedRoute,
|
|
private activateRoute: ActivatedRoute,
|
|
- private aiServ: AiChatService,
|
|
|
|
|
|
+ public aiServ: AiChatService,
|
|
|
|
+ public msgServe: MessageService,
|
|
public liveService: LiveService
|
|
public liveService: LiveService
|
|
) {}
|
|
) {}
|
|
|
|
|
|
@@ -64,6 +71,7 @@ export class LinkPageComponent implements OnInit {
|
|
});
|
|
});
|
|
loading.present();
|
|
loading.present();
|
|
await this.getRoom();
|
|
await this.getRoom();
|
|
|
|
+ this.initSwiperTimeEvent();
|
|
loading.dismiss();
|
|
loading.dismiss();
|
|
}
|
|
}
|
|
async getRoom() {
|
|
async getRoom() {
|
|
@@ -75,6 +83,17 @@ export class LinkPageComponent implements OnInit {
|
|
this.room = await query.first();
|
|
this.room = await query.first();
|
|
this.getFollwState(this.room?.get('user').id);
|
|
this.getFollwState(this.room?.get('user').id);
|
|
}
|
|
}
|
|
|
|
+ initSwiperTimeEvent() {
|
|
|
|
+ // 初始化轮播图
|
|
|
|
+ let swiper = new Swiper('.chartSwiper', {
|
|
|
|
+ loop: false, // 循环模式选项
|
|
|
|
+ observer: false, //修改swiper自己或子元素时,自动初始化swiper
|
|
|
|
+ observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
|
|
|
+ });
|
|
|
|
+ swiper.on('slideChange', function (event: any) {
|
|
|
|
+ // console.log(event);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
/* 关注状态 */
|
|
/* 关注状态 */
|
|
async getFollwState(uid: string) {
|
|
async getFollwState(uid: string) {
|
|
let query = new Parse.Query('ProfileRadar');
|
|
let query = new Parse.Query('ProfileRadar');
|
|
@@ -116,6 +135,10 @@ export class LinkPageComponent implements OnInit {
|
|
/* 直播状态 */
|
|
/* 直播状态 */
|
|
async onChangeLiveStatus(e: any, type: string) {
|
|
async onChangeLiveStatus(e: any, type: string) {
|
|
e.cancelBubble = true;
|
|
e.cancelBubble = true;
|
|
|
|
+ if (this.liveService.connection_state !== 'CONNECTED') {
|
|
|
|
+ this.presentToast('需连接成功后操作');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
switch (type) {
|
|
switch (type) {
|
|
case 'audio':
|
|
case 'audio':
|
|
this.liveService.updatePublishedAudioTrack();
|
|
this.liveService.updatePublishedAudioTrack();
|
|
@@ -129,19 +152,28 @@ export class LinkPageComponent implements OnInit {
|
|
case 'gift':
|
|
case 'gift':
|
|
this.gift.openModal();
|
|
this.gift.openModal();
|
|
break;
|
|
break;
|
|
|
|
+ case 'chat':
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
onSendGift() {
|
|
onSendGift() {
|
|
console.log('点击送出礼物');
|
|
console.log('点击送出礼物');
|
|
this.liveService.get_duration();
|
|
this.liveService.get_duration();
|
|
}
|
|
}
|
|
|
|
+ onPage() {
|
|
|
|
+ if (!this.showEmoji) {
|
|
|
|
+ this.showTool = !this.showTool;
|
|
|
|
+ } else {
|
|
|
|
+ this.showEmoji = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
/* 结束直播 */
|
|
/* 结束直播 */
|
|
async endCall(e: any) {
|
|
async endCall(e: any) {
|
|
e.cancelBubble = true;
|
|
e.cancelBubble = true;
|
|
const alert = await this.alertController.create({
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
cssClass: 'my-custom-class',
|
|
header: '退出提示',
|
|
header: '退出提示',
|
|
- message: '你确定退出登录吗?',
|
|
|
|
|
|
+ message: '你确定退出吗?',
|
|
buttons: [
|
|
buttons: [
|
|
{
|
|
{
|
|
text: '取消',
|
|
text: '取消',
|
|
@@ -165,7 +197,7 @@ export class LinkPageComponent implements OnInit {
|
|
const alert = await this.alertController.create({
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
cssClass: 'my-custom-class',
|
|
header: '举报',
|
|
header: '举报',
|
|
- message: '请填写您需要举报的内容',
|
|
|
|
|
|
+ message: '请填写你需要举报的内容',
|
|
inputs: [
|
|
inputs: [
|
|
{
|
|
{
|
|
name: 'report',
|
|
name: 'report',
|
|
@@ -191,6 +223,44 @@ export class LinkPageComponent implements OnInit {
|
|
});
|
|
});
|
|
await alert.present();
|
|
await alert.present();
|
|
}
|
|
}
|
|
|
|
+ //添加表情
|
|
|
|
+ emojiChoose(value: any) {
|
|
|
|
+ console.log(value);
|
|
|
|
+ this.text = this.text + value;
|
|
|
|
+ }
|
|
|
|
+ //发送文字
|
|
|
|
+ comfirmText(e?: any) {
|
|
|
|
+ if (e && e.keyCode != 13) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.disabled = true;
|
|
|
|
+ if (this.text == '' && this.text.trim() == '') {
|
|
|
|
+ this.presentToast('聊天内容不能为空');
|
|
|
|
+ this.disabled = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.send({
|
|
|
|
+ msg_type: 'text',
|
|
|
|
+ content: this.text,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ async send(param: { msg_type: string; content: string }) {
|
|
|
|
+ await this.msgServe.publishMessage(
|
|
|
|
+ param.content,
|
|
|
|
+ this.room?.get('user')?.id
|
|
|
|
+ );
|
|
|
|
+ this.text = '';
|
|
|
|
+ this.disabled = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async presentToast(title: string, time?: number, color?: string) {
|
|
|
|
+ const toast = await this.toastController.create({
|
|
|
|
+ message: title,
|
|
|
|
+ duration: time || 1500,
|
|
|
|
+ color: color || 'danger',
|
|
|
|
+ });
|
|
|
|
+ toast.present();
|
|
|
|
+ }
|
|
onExit() {
|
|
onExit() {
|
|
this.liveService.client.leave();
|
|
this.liveService.client.leave();
|
|
history.back();
|
|
history.back();
|