|
@@ -1,8 +1,11 @@
|
|
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
|
|
import * as Parse from 'parse';
|
|
|
-import { IonicModule } from '@ionic/angular';
|
|
|
+import {
|
|
|
+ AlertController,
|
|
|
+ IonicModule,
|
|
|
+ LoadingController,
|
|
|
+} from '@ionic/angular';
|
|
|
import { Router } from '@angular/router';
|
|
|
-import { AuthService } from '../../../services/auth.service';
|
|
|
import { Swiper } from 'swiper';
|
|
|
import { AiChatService } from '../../../services/aichart.service';
|
|
|
|
|
@@ -59,10 +62,39 @@ export class HomeComponent implements OnInit {
|
|
|
banner: Array<Parse.Object> = [];
|
|
|
roomList: Array<any> = [];
|
|
|
pageSwiper: Swiper | undefined | any;
|
|
|
-
|
|
|
+ notices: Array<any> = [
|
|
|
+ {
|
|
|
+ title: '【公告】',
|
|
|
+ content:
|
|
|
+ '欢迎来到直播间,请遵守直播规则,禁止一切违法直播行为,否则封号处理。',
|
|
|
+ time: '2022-06-01',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '【公告】',
|
|
|
+ content:
|
|
|
+ '欢迎来到直播间,请遵守直播规则,禁止一切违法直播行为,否则封号处理。',
|
|
|
+ time: '2022-06-01',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '【公告】',
|
|
|
+ content:
|
|
|
+ '欢迎来到直播间,请遵守直播规则,禁止一切违法直播行为,否则封号处理。',
|
|
|
+ time: '2022-06-01',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ viewAnchor: string = localStorage.getItem('viewSex') || '女';
|
|
|
+ get sex(): string {
|
|
|
+ const map: any = {
|
|
|
+ all: '全部',
|
|
|
+ 男: '男主播',
|
|
|
+ 女: '女主播',
|
|
|
+ };
|
|
|
+ return map[this.viewAnchor];
|
|
|
+ }
|
|
|
constructor(
|
|
|
+ private loadingCtrl: LoadingController,
|
|
|
+ private alertController: AlertController,
|
|
|
private router: Router,
|
|
|
- public authServ: AuthService,
|
|
|
private aiServ: AiChatService
|
|
|
) {}
|
|
|
|
|
@@ -78,7 +110,7 @@ export class HomeComponent implements OnInit {
|
|
|
}
|
|
|
async getBanner() {
|
|
|
let query = new Parse.Query('Banner');
|
|
|
- query.equalTo('company', this.authServ.company);
|
|
|
+ query.equalTo('company', this.aiServ.company);
|
|
|
query.descending('index');
|
|
|
query.equalTo('isEnabled', true);
|
|
|
query.notEqualTo('isDeleted', true);
|
|
@@ -92,7 +124,7 @@ export class HomeComponent implements OnInit {
|
|
|
observer: false, //修改swiper自己或子元素时,自动初始化swiper
|
|
|
observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
|
|
autoplay: {
|
|
|
- delay: 1500,
|
|
|
+ delay: 3000,
|
|
|
},
|
|
|
pagination: {
|
|
|
el: '.swiper-pagination',
|
|
@@ -101,42 +133,60 @@ export class HomeComponent implements OnInit {
|
|
|
swiper.on('slideChange', function (event: any) {
|
|
|
// console.log(event);
|
|
|
});
|
|
|
+
|
|
|
+ let swiperNot = new Swiper('.swiper-notice', {
|
|
|
+ loop: true, // 循环模式选项
|
|
|
+ observer: false, //修改swiper自己或子元素时,自动初始化swiper
|
|
|
+ observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
|
|
+ autoplay: {
|
|
|
+ delay: 5000,
|
|
|
+ },
|
|
|
+ direction: 'vertical',
|
|
|
+ });
|
|
|
}
|
|
|
async getRoom(type?: string) {
|
|
|
+ const loading = await this.loadingCtrl.create({
|
|
|
+ message: '正在加载',
|
|
|
+ });
|
|
|
+ loading.present();
|
|
|
let data: Array<any> = [];
|
|
|
if (!type) type = this.currentValue;
|
|
|
- console.log(type);
|
|
|
let uid = Parse.User.current()?.id;
|
|
|
+ let sex = this.viewAnchor == 'all' ? null : this.viewAnchor;
|
|
|
switch (type) {
|
|
|
case 'follow':
|
|
|
- data = await this.aiServ.getRooms({ uid: uid, follow: true });
|
|
|
+ data = await this.aiServ.getRooms({ uid: uid, follow: true, sex });
|
|
|
break;
|
|
|
case 'recommend':
|
|
|
- data = await this.aiServ.getRooms({ uid: uid, recommend: true });
|
|
|
+ data = await this.aiServ.getRooms({ uid: uid, recommend: true, sex });
|
|
|
break;
|
|
|
case 'news':
|
|
|
- data = await this.aiServ.getRooms({ uid: uid });
|
|
|
+ data = await this.aiServ.getRooms({ uid: uid, sex });
|
|
|
break;
|
|
|
case '三星':
|
|
|
- data = await this.aiServ.getRooms({ uid: uid, star: '三星' });
|
|
|
+ data = await this.aiServ.getRooms({ uid: uid, star: '三星', sex });
|
|
|
break;
|
|
|
case '四星':
|
|
|
- data = await this.aiServ.getRooms({ uid: uid, star: '四星' });
|
|
|
+ data = await this.aiServ.getRooms({ uid: uid, star: '四星', sex });
|
|
|
break;
|
|
|
case '五星':
|
|
|
- data = await this.aiServ.getRooms({ uid: uid, star: '五星' });
|
|
|
+ data = await this.aiServ.getRooms({ uid: uid, star: '五星', sex });
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
this.roomList = data;
|
|
|
console.log(data);
|
|
|
- // let query = new Parse.Query('Room');
|
|
|
- // query.equalTo('company', this.authServ.company);
|
|
|
- // query.equalTo('state', true);
|
|
|
- // query.notEqualTo('isDeleted', true);
|
|
|
- // let r = await query.find();
|
|
|
- // this.roomList = r;
|
|
|
+ loading.dismiss();
|
|
|
+ }
|
|
|
+ async presentAlert(item: any) {
|
|
|
+ const alert = await this.alertController.create({
|
|
|
+ header: item.title || '消息通知',
|
|
|
+ message:
|
|
|
+ item.content || 'A message should be a short, complete sentence.',
|
|
|
+ buttons: ['关闭'],
|
|
|
+ });
|
|
|
+ await alert.present();
|
|
|
}
|
|
|
segmentChanged(e: any) {
|
|
|
let { value } = e.detail;
|
|
@@ -148,10 +198,10 @@ export class HomeComponent implements OnInit {
|
|
|
/* 关闭弹窗回调 */
|
|
|
onDidDismiss(event: CustomEvent) {
|
|
|
this.isOpen = false;
|
|
|
- console.log(this.currentValue);
|
|
|
+ // console.log(this.currentValue);
|
|
|
}
|
|
|
cancel(type: string, value?: string) {
|
|
|
- console.log(type, value);
|
|
|
+ // console.log(type, value);
|
|
|
if (type == 'cancel') {
|
|
|
this.currentValue = this.oldCurrentValue;
|
|
|
} else {
|
|
@@ -159,7 +209,13 @@ export class HomeComponent implements OnInit {
|
|
|
}
|
|
|
this.isOpen = false;
|
|
|
this.modal.dismiss();
|
|
|
- this.getRoom()
|
|
|
+ this.getRoom();
|
|
|
+ }
|
|
|
+ onChangeSex(e: any) {
|
|
|
+ // console.log(e.detail.value);
|
|
|
+ localStorage.setItem('viewSex', e.detail.value);
|
|
|
+ this.viewAnchor = e.detail.value;
|
|
|
+ this.getRoom();
|
|
|
}
|
|
|
search() {
|
|
|
this.router.navigate(['live/search']);
|