Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import {Component, ElementRef, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams, Slides} from 'ionic-angular';
import {LearningExplainPage} from "../learning-explain/learning-explain";
import {LearnService} from "../learn.service";
import {DatePipe} from "@angular/common";
import {LearningResultPage} from "../learning-result/learning-result";
import {TabsService} from "../../../tabs/tabs.service";
import {CommonService} from "../../../../provide/common.service";
import {RankPage} from "../rank/rank";
import {EmitService} from "../../../../provide/emit.service";
@IonicPage()
@Component({
selector: 'page-learning-list',
templateUrl: 'learning-list.html',
})
export class LearningListPage {
@ViewChild(Slides) slides: Slides;
@ViewChild('tips') tips: ElementRef;
index = 0;
tabsList = [{name: "全部",}, {name: "未完成",}, {name: "已完成",}];
noList = [];
doList = [];
list = []; //全部测试
link = false; //是否请求完成
pageNumber = 1; //页码
pageSize = 1000; //每页显示条数
constructor(public navCtrl: NavController, public navParams: NavParams,public tabSer:TabsService,
public learnSer: LearnService, public datePipe: DatePipe,public commonSer:CommonService,
public emitSer:EmitService) {
}
ionViewDidLoad(){
let itemWidth = window.screen.width / 3;
this.tips.nativeElement.style.left = itemWidth / 2 - this.tips.nativeElement.offsetWidth / 2 + 'px';
this.readRecoding();
}
ionViewDidEnter() {
this.emitSer.eventEmit.emit('false'); //设置物理按键正常返回
this.getList();
}
//测试问卷的阅读激励
readRecoding(){
this.tabSer.testAddRecodings().subscribe(
(res)=>{
this.commonSer.log("测试列表:增加阅读记录成功!")
}
)
}
getList() {
const nowDate = this.datePipe.transform(new Date(), 'yyyy/MM/dd HH:mm:ss')
const data = {
pageNumber:this.pageNumber,
pageSize:this.pageSize,
selectType:'1', //全部状态
queryTime:nowDate,
};
this.learnSer.getLearnTestList(data).subscribe(
(res) => {
if(res.data){
this.list = res.data.list;
this.noList = this.list.filter((e)=>e.testResult == 0);
this.doList = this.list.filter((e)=>e.testResult == 1 || e.testResult == 2);
}
this.link = true;
}
)
}
// 下拉
doRefresh(refresher){
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,
};
this.learnSer.getLearnTestList(data).subscribe(
(res) => {
if(res.data){
this.list = res.data.list;
this.noList = res.data.list.filter((e)=>e.testResult == 0);
this.doList = res.data.list.filter((e)=>e.testResult == 2);
}
refresher.complete()
this.link = true;
}
)
}
//上拉
doInfinite(infiniteScroll){
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,
};
this.learnSer.getLearnTestList(data).subscribe(
(res) => {
if(res.data){
this.list = this.list.concat( res.data.list );
this.noList = this.list.filter((e)=>e.testResult == 0);
this.doList = this.list.filter((e)=>e.testResult == 2);
}
infiniteScroll.complete();
this.link = true;
}
)
}
change(index) {
let itemWidth = window.screen.width / 3;
// 自身div的一半 - 滑块的一半
this.tips.nativeElement.style.left = itemWidth * index + itemWidth / 2 - this.tips.nativeElement.offsetWidth / 2 + 'px';
this.index = index;
}
//去测试or结果
goToResult(item) {
if(item.testResult == 0){
this.navCtrl.push("LearningExplainPage", { //测试
item: item
})
}else{
this.navCtrl.push("LearningResultPage", { //结果
testId: item.testId,
title:item.title,
isRepeat:item.isRepeat
})
}
}
goToRank(item){
this.navCtrl.push('RankPage',{
testId:item.testId
})
}
}