import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {DatePipe} from "@angular/common";
import {CommonService} from "../../../../provide/common.service";

/**
 * Generated class for the RankListPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
    selector: 'page-rank-list',
    templateUrl: 'rank-list.html',
})
export class RankListPage {

    testId;
    pageNumber = 1;
    pageSize = 25;
    list = [
        {username: '1', score: '100'},
        {username: '2', score: '100'},
        {username: '3', score: '100'},
        {username: '4', score: '100'},
        {username: '5', score: '100'},
        {username: '6', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
        {username: '7', score: '100'},
    ];

    constructor(public navCtrl: NavController, public navParams: NavParams,
                public datePipe:DatePipe,public commonSer:CommonService) {
    }

    ionViewDidLoad() {
        this.testId = this.navParams.get('testId');
    }

    // 下拉
    doRefresh(refresher) {
        this.commonSer.log("下拉")
        this.pageNumber = 1;
        const nowDate = this.datePipe.transform(new Date(), 'yyyy/MM/dd HH:hh:ss')
        const data = {
            pageNumber: this.pageNumber,
            pageSize: this.pageSize,
            selectType: '1',   //全部状态
            queryTime: nowDate,
        };

        refresher.complete()

    }

    //上拉
    doInfinite(infiniteScroll) {
        this.commonSer.log("上拉")
        this.pageNumber++;
        const nowDate = this.datePipe.transform(new Date(), 'yyyy/MM/dd HH:hh:ss')
        const data = {
            pageNumber: this.pageNumber,
            pageSize: this.pageSize,
            selectType: '1',   //全部状态
            queryTime: nowDate,
        };
        infiniteScroll.complete();

    }

}
