|
@@ -18,15 +18,13 @@ addIcons({ personAddOutline, cardOutline, flameOutline, chevronForwardOutline })
|
|
|
})
|
|
|
export class Tab3Page {
|
|
|
currentUser: CloudUser | undefined;
|
|
|
- attentionList: CloudObject[] = [];
|
|
|
- fanList: CloudObject[] = [];
|
|
|
- postList: CloudObject[] = [];
|
|
|
constructor(private modalCtrl: ModalController, private router: Router) { }
|
|
|
async ngOnInit() {
|
|
|
+ this.currentUser = new CloudUser();
|
|
|
await this.loadAttentionList();
|
|
|
await this.loadFanList();
|
|
|
await this.loadPostList();
|
|
|
- this.getBackgroundImageStyle();
|
|
|
+ await this.getHistoryCount();
|
|
|
}
|
|
|
async ionViewWillEnter() {
|
|
|
console.warn("-------------------------\n" + "进入tab3界面,执行ionViewWillEnter\n" + "验证用户是否登录")
|
|
@@ -88,39 +86,52 @@ export class Tab3Page {
|
|
|
console.log(this.posts);
|
|
|
this.posts = this.posts.reverse();
|
|
|
}
|
|
|
- //加载关注列表
|
|
|
+ /**
|
|
|
+ * @读取个人信息卡片数据
|
|
|
+ */
|
|
|
+ /*加载关注列表*/
|
|
|
+ attentionList: CloudObject[] = [];
|
|
|
async loadAttentionList() {
|
|
|
const query = new CloudQuery('attention');
|
|
|
- const user = new CloudUser().toPointer();
|
|
|
- query.equalTo('UserID', user);
|
|
|
+ query.equalTo('UserID', this.currentUser?.toPointer());
|
|
|
this.attentionList = await query.find();
|
|
|
console.log(this.attentionList);
|
|
|
}
|
|
|
- //加载粉丝列表
|
|
|
+ /*加载粉丝列表*/
|
|
|
+ fanList: CloudObject[] = [];
|
|
|
async loadFanList() {
|
|
|
const query = new CloudQuery('attention');
|
|
|
- const user = new CloudUser().toPointer();
|
|
|
- query.equalTo('attentionID', user);
|
|
|
+ query.equalTo('attentionID', this.currentUser?.toPointer());
|
|
|
this.fanList = await query.find();
|
|
|
//console.log(this.fanList);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * @读取统计卡片数据
|
|
|
+ */
|
|
|
/*加载点赞帖子列表*/
|
|
|
+ likedPostsNumber: number = 0;
|
|
|
+ likedPostsImage: string = "";
|
|
|
async loadPostList() {
|
|
|
const query = new CloudQuery('postLikesRecord');
|
|
|
- const user = new CloudUser().toPointer();
|
|
|
- query.equalTo('UserID', user);
|
|
|
+ query.equalTo('UserID', this.currentUser?.toPointer());
|
|
|
query.include('postID');
|
|
|
- this.postList = await query.find();
|
|
|
- this.postList = this.postList.reverse();
|
|
|
- console.log(this.postList);
|
|
|
+ let postList = await query.find();
|
|
|
+ postList = postList.reverse();
|
|
|
+ this.likedPostsNumber = postList.length;
|
|
|
+ this.likedPostsImage = postList[0]?.get('postID')?.image[0];
|
|
|
+ console.log("获取到点赞帖子个数:" + this.likedPostsNumber + "\n" + "获取到点赞帖子图像:" + this.likedPostsImage);
|
|
|
}
|
|
|
- /*返回赞过图片*/
|
|
|
- getBackgroundImageStyle() {
|
|
|
- const imageUrl = this.postList[0]?.get('postID')?.image[0];
|
|
|
- console.log("检测背景url:" + imageUrl);
|
|
|
- let element = document.getElementById('liked');
|
|
|
- if(element)
|
|
|
- element.style.background = `url(${imageUrl})`
|
|
|
+ /*返回生成历史个数和图像*/
|
|
|
+ generateHistoryCount: number = 0;
|
|
|
+ generateHistoryImage: string = "";
|
|
|
+ async getHistoryCount() {
|
|
|
+ let query = new CloudQuery('GenerateResult');
|
|
|
+ query.equalTo('UserID', this.currentUser?.toPointer());
|
|
|
+ let result = await query.find();
|
|
|
+ result = result.reverse();
|
|
|
+ this.generateHistoryImage = result[0]?.get('image');
|
|
|
+ this.generateHistoryCount = result.length;
|
|
|
+ console.log("获取到生成历史个数:" + this.generateHistoryCount + "\n" + "获取到生成历史图像:" + this.generateHistoryImage);
|
|
|
}
|
|
|
}
|
|
|
|