|
@@ -13,13 +13,15 @@ import {
|
|
|
AlertController,
|
|
|
LoadingController,
|
|
|
} from '../../ionic-standalone.modules';
|
|
|
+import { CommonModule, DatePipe } from '@angular/common';
|
|
|
@Component({
|
|
|
selector: 'app-home',
|
|
|
templateUrl: './home.component.html',
|
|
|
styleUrls: ['./home.component.scss'],
|
|
|
standalone: true,
|
|
|
- imports: [...ionicStandaloneModules],
|
|
|
+ imports: [...ionicStandaloneModules, CommonModule],
|
|
|
// schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
|
+ providers: [DatePipe],
|
|
|
})
|
|
|
export class HomeComponent implements OnInit {
|
|
|
options: Array<any> = [
|
|
@@ -65,20 +67,7 @@ export class HomeComponent implements OnInit {
|
|
|
banner: Array<Parse.Object> = [];
|
|
|
roomList: Array<any> = [];
|
|
|
pageSwiper: Swiper | undefined | any;
|
|
|
- notices: Array<any> = [
|
|
|
- {
|
|
|
- title: '【公告】',
|
|
|
- content:
|
|
|
- '欢迎来到直播间,请遵守直播规则,禁止一切违法直播行为,否则封号处理。',
|
|
|
- time: '2024-12-01',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '【公告】',
|
|
|
- content:
|
|
|
- '欢迎使用爱聊',
|
|
|
- time: '2024-12-10',
|
|
|
- },
|
|
|
- ];
|
|
|
+ notices: Array<any> = [];
|
|
|
viewAnchor: string = localStorage.getItem('viewSex') || '女';
|
|
|
get sex(): string {
|
|
|
const map: any = {
|
|
@@ -94,7 +83,8 @@ export class HomeComponent implements OnInit {
|
|
|
private activateRoute: ActivatedRoute,
|
|
|
private connectTask: ConnectTaskService,
|
|
|
private router: Router,
|
|
|
- private aiServ: AiChatService
|
|
|
+ private aiServ: AiChatService,
|
|
|
+ private datePipe: DatePipe,
|
|
|
) {}
|
|
|
|
|
|
ngOnInit() {
|
|
@@ -109,6 +99,7 @@ export class HomeComponent implements OnInit {
|
|
|
loading.present();
|
|
|
await this.connectTask.init();
|
|
|
await this.getBanner();
|
|
|
+ await this.getNotice();
|
|
|
await this.getRoom();
|
|
|
setTimeout(() => {
|
|
|
this.initSwiperTimeEvent();
|
|
@@ -124,6 +115,15 @@ export class HomeComponent implements OnInit {
|
|
|
let banner = await query.find();
|
|
|
this.banner = banner;
|
|
|
}
|
|
|
+ async getNotice() {
|
|
|
+ let query = new Parse.Query('Notice');
|
|
|
+ query.equalTo('company', this.aiServ.company);
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
+ query.equalTo('type', 'application');
|
|
|
+ query.select('title', 'content');
|
|
|
+ query.descending('createdAt');
|
|
|
+ this.notices = await query.find();
|
|
|
+ }
|
|
|
initSwiperTimeEvent() {
|
|
|
// 初始化轮播图
|
|
|
let swiper = new Swiper('.mySwiper', {
|
|
@@ -224,11 +224,20 @@ export class HomeComponent implements OnInit {
|
|
|
}
|
|
|
async presentAlert(item: any) {
|
|
|
const alert = await this.alertController.create({
|
|
|
- header: item.title || '消息通知',
|
|
|
- subHeader:item.time,
|
|
|
- message:
|
|
|
- item.content || 'A message should be a short, complete sentence.',
|
|
|
- buttons: ['关闭'],
|
|
|
+ header: item?.get('title') || '消息通知',
|
|
|
+ subHeader: this.datePipe.transform(item?.createdAt, 'yyyy-MM-dd HH:mm')!,
|
|
|
+ message: item?.get('content') || '',
|
|
|
+ buttons: item?.get('url')
|
|
|
+ ? [
|
|
|
+ { text: '关闭' },
|
|
|
+ {
|
|
|
+ text: '确定',
|
|
|
+ handler: () => {
|
|
|
+ this.router.navigate([item?.get('url')]);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ : [{ text: '关闭' }],
|
|
|
});
|
|
|
await alert.present();
|
|
|
}
|
|
@@ -269,6 +278,6 @@ export class HomeComponent implements OnInit {
|
|
|
this.router.navigate(['live/search']);
|
|
|
}
|
|
|
toUrl(url: string) {
|
|
|
- this.router.navigate([url]);
|
|
|
+ url && this.router.navigate([url]);
|
|
|
}
|
|
|
}
|