123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import { Component, OnInit } from '@angular/core';
- import { IonicModule } from '@ionic/angular';
- import * as Parse from 'parse';
- import { InfiniteScrollCustomEvent } from '@ionic/angular';
- import { Router } from '@angular/router';
- import { AiChatService } from '../../../services/aichart.service';
- import { SharedModule } from '../../shared.module';
- // import { MessageService } from '../../../services/message.service';
- @Component({
- selector: 'app-notice',
- templateUrl: './notice.component.html',
- styleUrls: ['./notice.component.scss'],
- standalone: true,
- imports: [IonicModule, SharedModule],
- })
- export class NoticeComponent implements OnInit {
- active: string = 'notice';
- noticeList: Array<any> = [
- {
- avatar: '/img/notice.png',
- name: '系统消息',
- content: '',
- createdAt: new Date(),
- },
- ];
- alertButtons = [
- {
- text: '取消',
- role: 'cancel',
- handler: () => {
- console.log('Alert canceled');
- },
- },
- {
- text: '确认',
- role: 'confirm',
- handler: () => {
- console.log('Alert confirmed');
- },
- },
- ];
- friends: Array<any> = [];
- times: number = 0;
- timer: any;
- showModal: boolean = false; //是否长按弹窗
- currentObject: any; //当前选择对象
- constructor(
- private router: Router,
- private aiSer: AiChatService,
- // public msgServe: MessageService
- ) {}
- ngOnInit() {
- this.refresh();
- }
- async refresh() {
- let uid: any = Parse.User.current()?.id;
- let resultFriends = await this.aiSer.getFriends(uid);
- this.friends = resultFriends['data'];
- console.log(this.friends);
- let resChat = await this.aiSer.getLinkUsers(uid);
- resChat?.data && this.noticeList.push(...resChat.data);
- }
- segmentChanged(e: any) {
- let { value } = e.detail;
- this.active = value;
- }
- /* 手指按下 */
- startPress() {
- this.showModal = false;
- if (this.times >= 500) {
- console.log(this.times);
- this.times = 0;
- this.showModal = true;
- return;
- }
- this.timer = setTimeout(() => {
- this.times += 500;
- this.startPress();
- }, 500);
- }
- /* 触摸屏幕并移动,取消长按事件 */
- onMousemove(e: any) {
- clearTimeout(this.timer);
- // this.showModal = false;
- this.times = 0;
- }
- /* 手指抬起 */
- stopPress() {
- clearTimeout(this.timer);
- this.times = 0;
- }
- onIonInfinite(ev: any) {
- console.log(ev);
- setTimeout(() => {
- (ev as InfiniteScrollCustomEvent).target.complete();
- }, 500);
- }
- toUrl(url: string) {
- if (this.showModal) return;
- this.router.navigate([url]);
- }
- }
|