TeacherDetailApe.js
8.5 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
//*
// 老师模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
//import lyzCalendar from "css/lyz.calendar.css";
let loger = Loger.getLoger('PC-TeacherDetailApe');
const classifyList = `<div class="classifyList {_classifyListR}" id="{_id}">
<img class="curriculumListImg" src="{_msgImg}" alt="">
<p class="curriculumListTit">{_classroomTitle}</p>
<p class="curriculumListInfo">
<span class="curriculumListTime">{_schoolTime}</span>
<span class="curriculumListNum">{_subscribeNum}</span>
</p>
</div>`;
class TeacherDetailApe extends Ape {
constructor() {
super();
this.classDateList = {};//课堂的所有数据
this.addEvent();
this.init();
}
init() {
$('#collectYes').hide();
$('#teacherBtn').on('click',this._teacherBtnHandler.bind(this));//推荐老师
$('#teacherBtnMove').on('click',this._teacherBtnHandler.bind(this));//推荐老师
$('#classifyListBox').on('click','.pageNumBtn',this._pageNumBtnHandler.bind(this));//点击翻页
}
addEvent() {
}
_teacherBtnHandler(evt){
loger.log('老师',ClassDataProxy.userType)
this._clearListContent();
this._showLoadingImg();
let _ele = $(evt.target);
if(_ele.attr('data')){
$('.header_listMsg').eq(_ele.attr('data')).addClass('header_listMsgCheck').siblings().removeClass('header_listMsgCheck');
}
$(evt.target).addClass('header_listMsgCheck').siblings().removeClass('header_listMsgCheck');
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_1){
this.teacherClickTeacher();//老师点击老师模块
}else if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_8 || ClassDataProxy.userType == ClassDataProxy.USER_TYPE_0){
this.studentClickTeacher();//学生点击老师模块
this.detailPage();
}
}
//点击翻页
_pageNumBtnHandler(evt){
loger.log('点击翻页')
let _ele = $(evt.target);
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/getMeeting';
let that = this;
if(_ele.siblings().length > 0 && _ele.text()!= '...' ){
_ele.addClass('pageNumBtnCheck').siblings().removeClass('pageNumBtnCheck');
$.ajax({
type: "POST",
url: _url,
timeout:5000,
headers: {'page':_ele.text(),
siteId:'markettest',
'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo',
},
data:{siteId:'markettest'},
success:function(_data){
loger.log('点击翻页返回数据',_data)
if(_data != 200 ){
loger.warn(_data.returnData.data.msg)
}
that.classDateList = _data.returnData.data;
//切换列表内容
that._classDateContent(that.classDateList);
},
error:function(error){
//alert('老师翻页数据获取失败')
loger.log(error,'老师翻页数据获取失败')
}
})
}else{
return;
}
}
detailPage(){
loger.log('老师界面渲染')
let that = this;
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/getMeeting';
$.ajax({
type: "POST",
url: _url,
timeout:5000,
headers: {siteId:'markettest',
'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
data:{siteId:'markettest'},
success:function(_data){
loger.log('老师界面渲染数据',_data)
//获取课堂数据
if(_data || _data.code == 200){
that._gainClassData(_data);
}
},
error:function(error){
// alert('老师界面获取数据失败')
loger.log(error,'老师界面获取数据失败')
}
})
}
//清楚列表数据
_clearListContent(){
let classifyListContent = $('#classifyListContent');
classifyListContent.empty();
let classifyListTitle = $('#classifyListTitle');
classifyListTitle.empty();
let pageNumContentBox = $('#pageNumContentBox');
pageNumContentBox.empty();
}
//列表显示loading
_showLoadingImg(){
let loadingImg = `<img class="loadingImg" src="images/loading.gif" alt="">`;
$('#classifyListContent').append(loadingImg);
}
_gainClassData(_data){
this.classDateList = _data.returnData.data;
this._clearListContent();
//切换列表分类的标题
this._classDateTitle();
//切换列表内容
this._classDateContent(this.classDateList);
//页码
this._classDatepageNum(this.classDateList);
}
_classDateTitle(){
$('#classifyListTitle').html($('#teacherTitle').html());
}
_classDateContent(_data){
let classifyListContent = $('#classifyListContent');
classifyListContent.empty();
let _dataList = _data.meetingInfo;
for(let i = 0;i<_dataList.length;i++){
let j = (i%4)==3;
let _getTime = ClassDataProxy.getTimeDifference(_dataList[i].beginTime,_dataList[i].endTime)
let _classifyList = this._format(classifyList,{
_classifyListR : j?'classifyListR':'',
_id : _dataList[i].id,
_msgImg :'../images/u373.png',
_classroomTitle : _dataList[i].meetingName,
_schoolTime : _getTime,
_subscribeNum : _dataList[i].reservationNumber+'人已预约'
})
classifyListContent.append(_classifyList);
}
}
_classDatepageNum(_data){ //page
let _pageContent = _data.count;
let _pageNum = Math.ceil(_pageContent / _data.pageno);
this.pagingConstruct(1,_pageNum);
}
pagingConstruct(paging,total){
let pageNumContentBox = $('#pageNumContentBox');
pageNumContentBox.empty();
let pagingDivInnerHTML = '<div class="pageNumContent">';
let isHiddenExist = 0;
for(let i =1 ;i<=total;i++){
if(i == paging){
pagingDivInnerHTML +='<span class="pageNumBtn pageNumBtnCheck">'+i+'</span>';
}else{
if (i < 4 || i < (paging + 4) && i > (paging - 2) && i < (total / 2 + 2) || i > (total - 2)) {
pagingDivInnerHTML +='<span class="pageNumBtn">'+i+'</span>';
isHiddenExist = 0;
}else{
if(isHiddenExist == 0){
pagingDivInnerHTML += '<span class="pageNumBtn">...</span>';
isHiddenExist = 1;
}
}
}
}
pagingDivInnerHTML += '</div>';
pageNumContentBox.append(pagingDivInnerHTML);
}
_teacherHome(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#header_list').show();
$('#header_seek').show();
$('#androidDownload').show();
$('#classManagementBox').hide();
$('#classifyListBox').show();
}
//学生点击老师模块
studentClickTeacher(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#classifyListBox').show();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
}
//老师点击老师模块
teacherClickTeacher(){
loger.log('老师点击老师列表')
$('#classifyListBox').hide();
$('#myCenterBox').show();
}
//工具类
_format(str, obj) {
return str.replace(/\{(\w+)\}/g, function (match, group, index) {
return obj[group];
});
};
}
export default TeacherDetailApe;