|
@@ -0,0 +1,60 @@
|
|
|
+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-page-test', // 组件的选择器,用于在模板中引用组件
|
|
|
+ templateUrl: './page-test.component.html', // 组件的模板文件路径
|
|
|
+ styleUrls: ['./page-test.component.scss'] // 组件的样式文件路径
|
|
|
+})
|
|
|
+ export class PageTestComponent {
|
|
|
+ currentUser = Parse.User.current() // 当前用户对象
|
|
|
+ currentTab: string = 'all'; // 当前选项卡的标识符
|
|
|
+ changeTab(tab: string) {
|
|
|
+ this.currentTab = tab;}
|
|
|
+
|
|
|
+ constructor(private router: Router) { this.initPage(); }
|
|
|
+ courseList: Array<Parse.Object> = []
|
|
|
+ // 首次进入页面,默认加载首批数据
|
|
|
+ async initPage() {
|
|
|
+ this.courseList = await this.getMenuData()
|
|
|
+ }
|
|
|
+ // 数据加载相关函数
|
|
|
+ async getMenuData() {
|
|
|
+ let query = new Parse.Query("PetTest");
|
|
|
+ query.limit(this.pageSize);
|
|
|
+ query.include('courseAuthor')
|
|
|
+
|
|
|
+ if (this.skip) {
|
|
|
+ query.skip(this.skip)
|
|
|
+ }
|
|
|
+ query.addAscending("no")
|
|
|
+ let list = await query.find();
|
|
|
+ console.log(list);
|
|
|
+ return list
|
|
|
+ }
|
|
|
+
|
|
|
+ planOptions: any = {
|
|
|
+ gender: "未知",
|
|
|
+ targets: []
|
|
|
+ } // 计划选项对象,包含性别和目标属性
|
|
|
+ setOption(key: string, event: any) {
|
|
|
+ this.planOptions[key] = event.detail.value; // 更新计划选项对象的属性值
|
|
|
+ }
|
|
|
+ // 触底加载函数逻辑
|
|
|
+ pageSize = 30
|
|
|
+ skip: number = 0 // 跳过多少条进行加载
|
|
|
+ async onBottomLoad(event: any, infiScroll: any) {
|
|
|
+ console.log("onBottomLoad", this.courseList.length)
|
|
|
+ this.skip = this.courseList.length;
|
|
|
+ let list = await this.getMenuData();
|
|
|
+ this.courseList = this.courseList.concat(list)
|
|
|
+ infiScroll?.complete();
|
|
|
+ }
|
|
|
+ // goLessonDetail(lesson: any) {
|
|
|
+ // this.router.navigate(["/lesson/test/detail"], { queryParams: lesson })
|
|
|
+ // }
|
|
|
+ }
|