123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import { Component } from '@angular/core';
- import { ActivatedRoute } from '@angular/router';
- import * as Parse from "parse"
- @Component({
- selector: 'app-page-lesson-detail',
- templateUrl: './page-lesson-detail.component.html',
- styleUrls: ['./page-lesson-detail.component.scss']
- })
- export class PageLessonDetailComponent {
- course: any = {}
- constructor(private route: ActivatedRoute) {
- this.route.queryParams.subscribe(params => {
- this.initPage(params["id"]);
- });
- }
- lessonPointer: any;
- async getCourseById(id: string) {
- let query = new Parse.Query("HrmGift")
- query.include('courseAuthor')
- this.course = await query.get(id);
- this.lessonPointer = {
- __type: 'Pointer',
- className: 'HrmGift',
- objectId: this.course.id
- };
- }
-
- currentUser = Parse.User.current()
- commentContent = ''
- async saveComment() {
- let CourseComment = Parse.Object.extend('CourseComment')
- let courseComment = new CourseComment()
- courseComment.set('user', { __type: 'Pointer', className: '_User', objectId: this.currentUser?.id })
- courseComment.set('commentContent', this.commentContent)
- courseComment.set('lesson', this.lessonPointer);
- this.commentContent = '';
- return courseComment.save().then((saveObject: any) => {
-
- console.log(saveObject);
-
- this.getCommentData().then((commentList: Array<Parse.Object>) => {
- this.commentList = commentList;
- this.commentCount = this.commentList.length;
- });
- },
- (error: string) => {
-
- console.log("失败:" + error);
- })
- }
-
- commentCount: number = 0
- commentList: Array<Parse.Object> = []
- async initPage(id: string) {
- await this.getCourseById(id);
- this.commentList = await this.getCommentData()
- this.commentCount = this.commentList.length;
- }
- async getCommentData() {
- let query = new Parse.Query("CourseComment");
- query.equalTo("lesson", this.lessonPointer);
- query.descending('createdAt')
- let list = await query.find();
- return list
- }
- }
|