import { Component } from '@angular/core';
// 引用服务
import { Router } from '@angular/router';

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


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

  theyList: Array<Parse.Object> = []

  // 依赖注入
  constructor(private router: Router) {
    this.initPage();
  }
  // 首次进入页面，默认加载首批数据
  async initPage() {
    this.theyList = await this.getTheyData()
  }

  // 数据加载相关函数
  async getTheyData() {
    let query = new Parse.Query("SqzPerson");
    query.addAscending("createdAt")
    let list = await query.find();
    return list
  }
  // 跳转函数
  goTheyDetail(they: Parse.Object) {
    this.router.navigate(["/lesson/they/detail"], {
      queryParams: they
    })
  }
}







