|
@@ -2,6 +2,7 @@ import { DatePipe } from '@angular/common';
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
+import { ActivatedRoute } from '@angular/router';
|
|
|
import {
|
|
|
IonicModule,
|
|
|
LoadingController,
|
|
@@ -23,10 +24,10 @@ import * as Parse from 'parse';
|
|
|
providers: [DatePipe],
|
|
|
})
|
|
|
export class ChatComponent implements OnInit {
|
|
|
- targetUser: any = {
|
|
|
- name: '紫霞仙子',
|
|
|
- avatar: '',
|
|
|
- };
|
|
|
+ uid: string = '';
|
|
|
+ profile?: Parse.Object;
|
|
|
+ targetUser?: Parse.Object;
|
|
|
+
|
|
|
text: string = '';
|
|
|
list: any = {
|
|
|
data: [
|
|
@@ -82,7 +83,6 @@ export class ChatComponent implements OnInit {
|
|
|
viewImg: string = '';
|
|
|
height: number = 0;
|
|
|
showEmoji: boolean = false;
|
|
|
- showMore: boolean = false;
|
|
|
emojis: Array<any> = [];
|
|
|
isOpen: boolean = false;
|
|
|
currentScroll: number = 0;
|
|
@@ -91,11 +91,45 @@ export class ChatComponent implements OnInit {
|
|
|
public datePipe: DatePipe,
|
|
|
private modalController: ModalController,
|
|
|
public toastController: ToastController,
|
|
|
- private loadingCtrl: LoadingController
|
|
|
+ private loadingCtrl: LoadingController,
|
|
|
+ private activateRoute: ActivatedRoute,
|
|
|
) {}
|
|
|
|
|
|
ngOnInit() {
|
|
|
+ this.activateRoute.paramMap.subscribe(async (params) => {
|
|
|
+ let id: any = params.get('id');
|
|
|
+ this.uid = id;
|
|
|
+ if(!this.uid){
|
|
|
+ history.back();
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.refresh();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ async refresh() {
|
|
|
+ const loading = await this.loadingCtrl.create({
|
|
|
+ message: '加载中',
|
|
|
+ });
|
|
|
+ loading.present();
|
|
|
+ await this.getProfile()
|
|
|
this.initEmoji();
|
|
|
+ loading.dismiss();
|
|
|
+ }
|
|
|
+
|
|
|
+ async getProfile(){
|
|
|
+ let queryProfile = new Parse.Query('Profile');
|
|
|
+ queryProfile.equalTo('user', this.uid);
|
|
|
+ queryProfile.notEqualTo('isDeleted', true);
|
|
|
+ queryProfile.include('user');
|
|
|
+ let p = await queryProfile.first();
|
|
|
+ this.profile = p;
|
|
|
+ if (this.profile?.id) {
|
|
|
+ this.targetUser = this.profile?.get('user');
|
|
|
+ } else {
|
|
|
+ let queryUser = new Parse.Query('_User');
|
|
|
+ queryUser.equalTo('objectId', this.uid);
|
|
|
+ this.targetUser = await queryUser.first();
|
|
|
+ }
|
|
|
}
|
|
|
initEmoji() {
|
|
|
let emojiChar =
|
|
@@ -212,10 +246,9 @@ export class ChatComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- changeShowEmoji() {
|
|
|
- this.showEmoji = !this.showEmoji;
|
|
|
+ changeShowEmoji(isClose?:boolean) {
|
|
|
+ this.showEmoji = isClose ? false : !this.showEmoji;
|
|
|
this.height = 0;
|
|
|
- this.showMore = false;
|
|
|
}
|
|
|
|
|
|
emojiChoose(value: any) {
|