import { Component } from '@angular/core';

// 引入服务
import { ActivatedRoute } from '@angular/router';

// 引入Parse第三方库
import * as Parse from "parse"
(Parse as any).serverURL = "http://metapunk.cn:9999/parse"
Parse.initialize("dev")


@Component({
  selector: 'app-recommend-detail',
  templateUrl: './recommend-detail.component.html',
  styleUrls: ['./recommend-detail.component.scss']
})
export class RecommendDetailComponent {

  comments: string[] = []
  comment: string = ''
  currentDate = new Date()
  addComment() {
    console.log(this.comment)
    if (this.comment.trim() !== '') {
      this.comments.push(this.comment);
      this.comment = '';
    }
  }

  //预设值变量
  recommend: Parse.Object | undefined;
  // 依赖注入
  constructor(private route: ActivatedRoute) {
    // 查询参数获取并赋值给this.recommend
    this.route.queryParams.subscribe(params => {
      this.getViewInfoById(params["id"])
    })
  }
  async getViewInfoById(id: string) {
    let query = new Parse.Query("PetRecommend")
    this.recommend = await query.get(id)
  }


}
