|
@@ -1,4 +1,9 @@
|
|
-import { Component, CUSTOM_ELEMENTS_SCHEMA, OnInit } from '@angular/core';
|
|
|
|
|
|
+import {
|
|
|
|
+ Component,
|
|
|
|
+ CUSTOM_ELEMENTS_SCHEMA,
|
|
|
|
+ OnInit,
|
|
|
|
+ ViewChild,
|
|
|
|
+} from '@angular/core';
|
|
import * as Parse from 'parse';
|
|
import * as Parse from 'parse';
|
|
import { IonicModule } from '@ionic/angular';
|
|
import { IonicModule } from '@ionic/angular';
|
|
import { Router } from '@angular/router';
|
|
import { Router } from '@angular/router';
|
|
@@ -14,9 +19,49 @@ import { Swiper } from 'swiper';
|
|
// schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
// schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
})
|
|
})
|
|
export class HomeComponent implements OnInit {
|
|
export class HomeComponent implements OnInit {
|
|
- active: string = 'recommend';
|
|
|
|
|
|
+ @ViewChild('modal') modal!: any;
|
|
|
|
+ options: Array<any> = [
|
|
|
|
+ {
|
|
|
|
+ label: '关注',
|
|
|
|
+ value: 'follow',
|
|
|
|
+ icon: 'home-outline',
|
|
|
|
+ color: 'primary',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '推荐',
|
|
|
|
+ value: 'recommend',
|
|
|
|
+ icon: 'home-outline',
|
|
|
|
+ color: 'primary',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '新人',
|
|
|
|
+ value: 'news',
|
|
|
|
+ icon: 'videocam-outline',
|
|
|
|
+ color: 'danger',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '三星',
|
|
|
|
+ value: 'star3',
|
|
|
|
+ icon: 'videocam-outline',
|
|
|
|
+ color: 'danger',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '四星',
|
|
|
|
+ value: 'star4',
|
|
|
|
+ icon: 'videocam-outline',
|
|
|
|
+ color: 'danger',
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ label: '五星',
|
|
|
|
+ value: 'star5',
|
|
|
|
+ icon: 'people-outline',
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
+ currentValue: string = 'recommend';
|
|
|
|
+ oldCurrentValue:string = 'recommend';
|
|
|
|
+ isOpen: boolean = false; //显示选择弹窗
|
|
banner: Array<Parse.Object> = [];
|
|
banner: Array<Parse.Object> = [];
|
|
- roomList:Array<Parse.Object> = []
|
|
|
|
|
|
+ roomList: Array<Parse.Object> = [];
|
|
pageSwiper: Swiper | undefined | any;
|
|
pageSwiper: Swiper | undefined | any;
|
|
|
|
|
|
constructor(private router: Router, public authServ: AuthService) {}
|
|
constructor(private router: Router, public authServ: AuthService) {}
|
|
@@ -25,13 +70,13 @@ export class HomeComponent implements OnInit {
|
|
this.refresh();
|
|
this.refresh();
|
|
}
|
|
}
|
|
async refresh() {
|
|
async refresh() {
|
|
- await this.getBanner()
|
|
|
|
- await this.getRoom()
|
|
|
|
|
|
+ await this.getBanner();
|
|
|
|
+ await this.getRoom();
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
- this.initSwiperTimeEvent()
|
|
|
|
|
|
+ this.initSwiperTimeEvent();
|
|
}, 0);
|
|
}, 0);
|
|
}
|
|
}
|
|
- async getBanner(){
|
|
|
|
|
|
+ async getBanner() {
|
|
let query = new Parse.Query('Banner');
|
|
let query = new Parse.Query('Banner');
|
|
query.equalTo('company', this.authServ.company);
|
|
query.equalTo('company', this.authServ.company);
|
|
query.descending('index');
|
|
query.descending('index');
|
|
@@ -39,41 +84,55 @@ export class HomeComponent implements OnInit {
|
|
query.notEqualTo('isDeleted', true);
|
|
query.notEqualTo('isDeleted', true);
|
|
let banner = await query.find();
|
|
let banner = await query.find();
|
|
this.banner = banner;
|
|
this.banner = banner;
|
|
-
|
|
|
|
}
|
|
}
|
|
initSwiperTimeEvent() {
|
|
initSwiperTimeEvent() {
|
|
// 初始化轮播图
|
|
// 初始化轮播图
|
|
- let swiper = new Swiper(".mySwiper", {
|
|
|
|
|
|
+ let swiper = new Swiper('.mySwiper', {
|
|
loop: true, // 循环模式选项
|
|
loop: true, // 循环模式选项
|
|
- observer: false,//修改swiper自己或子元素时,自动初始化swiper
|
|
|
|
- observeParents: true,//修改swiper的父元素时,自动初始化swiper
|
|
|
|
- autoplay:{
|
|
|
|
- delay:1500,
|
|
|
|
- },
|
|
|
|
|
|
+ observer: false, //修改swiper自己或子元素时,自动初始化swiper
|
|
|
|
+ observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
|
|
|
+ autoplay: {
|
|
|
|
+ delay: 1500,
|
|
|
|
+ },
|
|
pagination: {
|
|
pagination: {
|
|
- el: ".swiper-pagination",
|
|
|
|
|
|
+ el: '.swiper-pagination',
|
|
},
|
|
},
|
|
});
|
|
});
|
|
- swiper.on('slideChange', function (event:any) {
|
|
|
|
|
|
+ swiper.on('slideChange', function (event: any) {
|
|
// console.log(event);
|
|
// console.log(event);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- async getRoom(){
|
|
|
|
|
|
+ async getRoom() {
|
|
let query = new Parse.Query('Room');
|
|
let query = new Parse.Query('Room');
|
|
query.equalTo('company', this.authServ.company);
|
|
query.equalTo('company', this.authServ.company);
|
|
- query.equalTo('state',true);
|
|
|
|
|
|
+ query.equalTo('state', true);
|
|
query.notEqualTo('isDeleted', true);
|
|
query.notEqualTo('isDeleted', true);
|
|
- let r = await query.find()
|
|
|
|
- this.roomList = r
|
|
|
|
|
|
+ let r = await query.find();
|
|
|
|
+ this.roomList = r;
|
|
}
|
|
}
|
|
segmentChanged(e: any) {
|
|
segmentChanged(e: any) {
|
|
let { value } = e.detail;
|
|
let { value } = e.detail;
|
|
- this.active = value;
|
|
|
|
|
|
+ this.currentValue = value;
|
|
|
|
+ }
|
|
|
|
+ onIonChange(event: CustomEvent) {
|
|
|
|
+ this.currentValue = event.detail.value;
|
|
|
|
+ }
|
|
|
|
+ /* 关闭弹窗回调 */
|
|
|
|
+ onDidDismiss(event: CustomEvent) {
|
|
|
|
+ this.isOpen = false;
|
|
|
|
+ console.log(this.currentValue);
|
|
}
|
|
}
|
|
- toSearchb() {
|
|
|
|
- this.router.navigate(['metapunk/searchbar']);
|
|
|
|
|
|
+ cancel(type: string, value?: string) {
|
|
|
|
+ console.log(type, value);
|
|
|
|
+ if(type == 'cancel'){
|
|
|
|
+ this.currentValue = this.oldCurrentValue;
|
|
|
|
+ }else{
|
|
|
|
+ this.oldCurrentValue = this.currentValue;
|
|
|
|
+ }
|
|
|
|
+ this.isOpen = false;
|
|
|
|
+ this.modal.dismiss();
|
|
}
|
|
}
|
|
- search(){
|
|
|
|
|
|
+ search() {
|
|
this.router.navigate(['live/search']);
|
|
this.router.navigate(['live/search']);
|
|
}
|
|
}
|
|
}
|
|
}
|