|
@@ -1,5 +1,10 @@
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
import { Router } from '@angular/router';
|
|
|
+import {AlertController } from '@ionic/angular';
|
|
|
+import {SharedService} from 'src/modules/user/service-user/Share.service'
|
|
|
+import * as Parse from "parse"
|
|
|
+(Parse as any).serverURL = "https://web2023.fmode.cn/parse"
|
|
|
+Parse.initialize("dev")
|
|
|
|
|
|
interface Contact {
|
|
|
name: string;
|
|
@@ -14,6 +19,9 @@ interface Contact {
|
|
|
export class FriendsPage implements OnInit {
|
|
|
|
|
|
|
|
|
+ userId :any = '';
|
|
|
+ cares :any = [];
|
|
|
+
|
|
|
contacts: Contact[] = [
|
|
|
{ name: '张三', avatar: 'https://via.placeholder.com/150' },
|
|
|
{ name: '李四', avatar: 'https://via.placeholder.com/150' },
|
|
@@ -22,11 +30,57 @@ export class FriendsPage implements OnInit {
|
|
|
];
|
|
|
|
|
|
ngOnInit() {
|
|
|
+ this.userId=this.sharedService.getUserId()
|
|
|
+ this.findMyCare()
|
|
|
}
|
|
|
- constructor(private router:Router) {
|
|
|
+ constructor(private sharedService: SharedService,private router:Router,private alertCtrl:AlertController){
|
|
|
|
|
|
+ this.userId=this.sharedService.getUserId()
|
|
|
+ console.log(this.userId)
|
|
|
+ // findMyCare(this.userId,this.cares)
|
|
|
+ // console.log(this.cares)
|
|
|
+ }
|
|
|
+
|
|
|
+ async findMyCare() {
|
|
|
+ console.log(this.userId)
|
|
|
+ const GzpCare = Parse.Object.extend('GzpCare')
|
|
|
+ const query = new Parse.Query(GzpCare);
|
|
|
+ query.equalTo("userId", this.userId);
|
|
|
+ try {
|
|
|
+ const Cares = await query.find();
|
|
|
+ for (const care of Cares) {
|
|
|
+ this.cares.push({
|
|
|
+ careUserId:care.get("careUserId"),
|
|
|
+ careUsername:care.get('careUsername'),
|
|
|
+ careUserImg:"http://q1.qlogo.cn/g?b=qq&nk="+care.get("careUserId")+"&s=100"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("查询消息时出错:", error);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ async noCareThis(care: any) {
|
|
|
+ if (this.userId != null) {
|
|
|
+ const GzpCare = Parse.Object.extend('GzpCare');
|
|
|
+ const query = new Parse.Query(GzpCare);
|
|
|
+ query.equalTo("userId", this.userId);
|
|
|
+ query.equalTo("careUserId", care.careUserId);
|
|
|
+ query.equalTo("careUsername", care.careUsername);
|
|
|
+ const noCare = await query.find();
|
|
|
+ for (const obj of noCare) {
|
|
|
+ await obj.destroy();
|
|
|
+ }
|
|
|
+ const alert = await this.alertCtrl.create({
|
|
|
+ header: '取关成功',
|
|
|
+ subHeader: '该用户已不是你的关注用户',
|
|
|
+ buttons: ['好的'],
|
|
|
+ });
|
|
|
+ await alert.present();
|
|
|
+ this.cares=[]
|
|
|
+ this.findMyCare()
|
|
|
+ }
|
|
|
+ }
|
|
|
goChatPage(){
|
|
|
this.router.navigate(["..//chat-page"],{
|
|
|
})
|