MyCoursesApe.js
26.8 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
//*
// 个人中心 我的课程
// */
import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import ErrorApe from "./ErrorApe";
import MessageTypes from "../MessageTypes";
const classifyList = `<div class="courseMinuteListTimeTit" style="display: {_isShowTitle}">
<span class="courseMinuteListTime">{_liveTimer}</span>
<span class="courseMinuteListWire"></span>
</div>
<div class="classifyListMyCenter {_classifyListR}" data="{_id}">
<div class="myCenterContentMask accessLearningBtn">
<button class="myCenterContentMaskBtn btnHover" data="{_meetingNumber}" value="{_studyMsg}">{_studyMsg}</button>
</div>
<div class="myCenterContentMask cancelReservation">
<button class="myCenterContentMaskBtn btnHover" data="{_studentMeetingId}">取消预约</button>
</div>
<img class="myCenterContentListImg" src="{_msgImg}" alt="">
<p class="myCenterContentListTit">{_meetingName}</p>
<p class="myCenterContentListTit1">主讲人:{_create_user}</p>
<p class="myCenterContentMin">45min</p>
<span class="myCenterContentTimer">{_liveTimer}</span>
</div>`;
const curriculumList = `<li class="teacherTodayCourseList">
<span class="courseDetailInfo">{_infoTit}</span>
<span class="courseDetailInfo1">距开始还有:<i class="teacherStartContent">{_countDown}</i></span>
<button class="teacherEnterClass btnHover" data="{_meetingNumber}" style="display: {_isShow}">立即进入</button>
</li>`;
const adminListTit = `<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" class="t_box">
<tbody>
<tr align="center" height="44" class="tr_center" bgcolor="#fff" bordercolor="#e6e6e6">
<th width="7%" class="tr_center">
课堂主题
</th>
<th width="7%" class="tr_center">
课堂号
</th>
<th width="7%" class="tr_center">
老师
</th>
<th width="7%" class="tr_center">
课堂状态
</th>
<th width="15%" class="tr_center">
课堂时间
</th>
<th width="7%" class="tr_center">
在线人数
</th>
<th width="10%" class="tr_center">
操作
</th>
</tr>
`;
//管理首页
const adminList = `<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">
<td width="7%" class="tr_main tr_mainLeft">{_meetingName}</td>
<td width="7%" class="tr_main">{_meetingNumber}</td>
<td width="7%" class="tr_main">{_create_user}</td>
<td width="7%" class="tr_main">{_state}</td>
<td width="15%" class="tr_main">{_timer}</td>
<td width="7%" class="tr_main">{_num}</td>
<td width="10%" class="tr_main tr_mainRight" align="center">
<a class="classHandlePort deleteClass" data="{_aboutMsg}" href="###">文档</a>
<a class="classHandlePort deleteClass" data="{_aboutMsg}" href="###">多媒体</a>
<a class="classHandlePort resolveBtn" href="###" data="{_aboutMsg}">伴音</a>
</td>
</tr>
`;
const adminListEnd = `</tbody></table>`;
let loger = Loger.getLoger('PC-MyCoursesApe');
class MyCoursesApe extends Ape {
constructor() {
super();
this.dataList = {};
this.presentIndT = 1;//点击翻页默认为第一页 老师端
this.presentIndS = 1;//点击翻页默认为第一页 学生端
this.pageNoT = 0; //直播默认页码 老师端
this.pageNoS = 0; //直播默认页码 学生端
this.addEvent();
this.init();
}
init() {
$('#courseInfoList li').on('click',this._courseInfoListHandler.bind(this));//我的课程 学生 待学习 已学完 收藏
$('#teacherLiveList li').on('click',this._teacherLiveListHandler.bind(this));//我的课程 老师 正在直播 未开始 已结束
$('#courseMinuteHomePage0').on('click',this._homePageHandler.bind(this));//首页
$('#courseMinuteUpPage0').on('click',this._upPageHandler.bind(this));//上页
$('#courseMinuteDownPage0').on('click',this._downPageHandler.bind(this));//下页
$('#courseMinuteEndPage0').on('click',this._endPageHandler.bind(this));//尾页
$('#courseMinuteSpecificPage0').on('click',this._assignPageHandler.bind(this));//指定页
$('#courseMinuteHomePage1').on('click',this._homePageHandler.bind(this));//首页
$('#courseMinuteUpPage1').on('click',this._upPageHandler.bind(this));//上页
$('#courseMinuteDownPage1').on('click',this._downPageHandler.bind(this));//下页
$('#courseMinuteEndPage1').on('click',this._endPageHandler.bind(this));//尾页
$('#courseMinuteSpecificPage1').on('click',this._assignPageHandler.bind(this));//指定页
$('#courseMinuteHomePage2').on('click',this._homePageHandler.bind(this));//首页
$('#courseMinuteUpPage2').on('click',this._upPageHandler.bind(this));//上页
$('#courseMinuteDownPage2').on('click',this._downPageHandler.bind(this));//下页
$('#courseMinuteEndPage2').on('click',this._endPageHandler.bind(this));//尾页
$('#courseMinuteSpecificPage2').on('click',this._assignPageHandler.bind(this));//指定页
}
addEvent() {
}
//首页
_createClassHomePage(){
this._teacherLiveModule(1);
}
//首页
_homePageHandler(){
this.presentIndT = 1;
let ind = $('#courseMinutePage').attr('data');
switch (parseInt(ind)){
case 1:
this.teacherNowLiveModule(this.presentIndT);
break;
case 2:
this.teacherNoneLiveModule(this.presentIndT);
break;
case 4:
this._teacherEndLiveModule(this.presentIndT);
break;
default:
return;
}
}
//上页
_upPageHandler(){
if(this.presentIndT > 1){
this.presentIndT--;
let ind = $('#courseMinutePage').attr('data');
switch (parseInt(ind)){
case 1:
this.teacherNowLiveModule(this.presentIndT);
break;
case 2:
this.teacherNoneLiveModule(this.presentIndT);
break;
case 4:
this._teacherEndLiveModule(this.presentIndT);
break;
default:
return;
}
}
}
//下页
_downPageHandler(){
if(this.presentIndT < this.pageNoT){
this.presentIndT++;
let ind = $('#courseMinutePage').attr('data');
switch (parseInt(ind)){
case 1:
this.teacherNowLiveModule(this.presentIndT);
break;
case 2:
this.teacherNoneLiveModule(this.presentIndT);
break;
case 4:
this._teacherEndLiveModule(this.presentIndT);
break;
default:
return;
}
}
}
//尾页
_endPageHandler(){
this.presentIndT = this.pageNoT;
let ind = $('#courseMinutePage').attr('data');
switch (parseInt(ind)){
case 1:
this.teacherNowLiveModule(this.presentIndT);
break;
case 2:
this.teacherNoneLiveModule(this.presentIndT);
break;
case 4:
this._teacherEndLiveModule(this.presentIndT);
break;
default:
return;
}
}
//指定页
_assignPageHandler(){
let val;
let ind = $('#courseMinutePage').attr('data');
let card = $('#teacherInfoList .liveInfoLeftLiCheck').index();
let inputVal = $('#courseMinutePageInfoInput'+card).val();
if(parseInt(inputVal) > this.pageNoT ){
val = this.pageNoT;
}else if(parseInt(inputVal) < 1){
val = 1;
}else{
val = parseInt(inputVal)
}
switch (parseInt(ind)){
case 1:
this.teacherNowLiveModule(val);
break;
case 2:
this.teacherNoneLiveModule(val);
break;
case 4:
this._teacherEndLiveModule(val);
break;
default:
return;
}
$('#courseMinutePageInfoInput'+card).val('');
}
//我的课程
myCoursesMessage(){
let courseInfoList = $('#courseInfoList');
let teacherLiveList = $('#teacherLiveList');
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_1){
this.teacherCourses();
courseInfoList.hide();
teacherLiveList.show();
this._anewLoad(teacherLiveList);//默认显示第一个列表
this.teacherNowLiveModule(1);
}else if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_8){
let courseMinuteList = $('#courseMinuteList');
this.studentCourses();
courseInfoList.show();
teacherLiveList.hide();
this._anewLoad(courseInfoList)//默认显示第一个列表
this.studentFutureModule(courseMinuteList);
}
}
_anewLoad(ele){
ele.find('.liveInfoLeftLi').eq(0).addClass('liveInfoLeftLiCheck').siblings().removeClass('liveInfoLeftLiCheck')
}
//我的 课程 直播信息
teacherCourses(){
let ind = $('#teacherLiveList .liveInfoLeftLiCheck').attr('data');
let courseMinuteList = $('#courseMinuteList');
let card = $('#teacherLiveList .liveInfoLeftLiCheck').index();
$('#courseMinutePage').attr('data',ind)
$('#courseMinutePageBox'+card).show().siblings().hide();
this.presentIndT = 1;
switch (parseInt(ind)){
case 1:
//正在直播
this.teacherNowLiveModule(1);
break;
case 2:
//未开始
this.teacherNoneLiveModule(1);
break;
case 4:
//已结束
this._teacherEndLiveModule(1);
break;
default:
return;
}
}
teacherNowLiveModule(ind){
let data = {siteId:ClassDataProxy.siteId,create_user : ClassDataProxy.loginName,meetingStatus:1};
let that = this;
this._teacherCurriculumInfo(data,8,ind,function(_data){
//首页直播信息渲染
if(_data){
that._teacherLivePage(_data.returnData.data);
that._teacherCourse(_data.returnData.data);
}
})
}
//我的课程 未开始
teacherNoneLiveModule(ind){
let data = {siteId:ClassDataProxy.siteId,create_user : ClassDataProxy.loginName,meetingStatus:2};
let that = this;
this._teacherCurriculumInfo(data,8,ind,function(_data){
//首页直播信息渲染
if(_data){
that._teacherNotPage(_data.returnData.data);
that._teacherCourse(_data.returnData.data);
}
})
}
//我的课程 已结束
_teacherEndLiveModule(ind){
let data = {siteId:ClassDataProxy.siteId,create_user : ClassDataProxy.loginName,meetingStatus:4};
let that = this;
this._teacherCurriculumInfo(data,8,ind,function(_data){
//首页直播信息渲染
if(_data){
that._teacherOverPage(_data.returnData.data);
that._teacherCourse(_data.returnData.data);
}
})
}
_teacherCourse(_data){
let courseMinuteList = $('#courseMinuteList');
courseMinuteList.empty();
if(_data){
let _dataList = _data.meetingInfo;
if(_dataList.length > 0){
courseMinuteList.append(adminListTit)
for(let i = 0;i<_dataList.length;i++){
let _adminList = this._format(adminList,{
_meetingName : _dataList[i].meetingName,
_meetingNumber : _dataList[i].meetingNumber,
_create_user : _dataList[i].create_user,
// _state : ClassDataProxy.getTimeEnd(_dataList[i].beginTime,_dataList[i].endTime),
_state : "准备",
_timer : _dataList[i].beginTime + '-' + _dataList[i].endTime,
_num : '0'
})
courseMinuteList.append(_adminList)
}
courseMinuteList.append(adminListEnd)
}else{
let _classifyList = '<div class="dataCenterErrorTitle">暂无数据~</div>';
courseMinuteList.append(_classifyList)
}
}
}
_teacherLivePage(_data){
if(_data){
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
let _dataList = _data.meetingInfo;
this.pageNoT = pagenum;
$('#courseMinutePageMsg0').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <=8){
$('#courseMinutePageBox0').hide();
}
}
}
_teacherNotPage(_data){
if(_data){
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
let _dataList = _data.meetingInfo;
this.pageNoT = pagenum;
$('#courseMinutePageMsg1').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <=8){
$('#courseMinutePageBox1').hide();
}
}
}
_teacherOverPage(_data){
if(_data){
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
let _dataList = _data.meetingInfo;
this.pageNoT = pagenum;
$('#courseMinutePageMsg2').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <=8){
$('#courseMinutePageBox2').hide();
}
}
}
// 学生端
//学生端 我的课程 切换
studentCourses(){
let ind = $('#courseInfoList .liveInfoLeftLiCheck').attr('data');
$('#courseMinutePageBox0').hide();
$('#courseMinutePageBox1').hide();
$('#courseMinutePageBox2').hide();
switch (parseInt(ind)){
case 0:
//待学习
this.studentFutureModule();
break;
case 1:
//已学完
this.studentFormerlyModule();
break;
case 2:
//收藏
this.studentCollectModule();
break;
default:
return;
}
}
//学生端 我的课程 待学习
studentFutureModule(){
let courseMinuteList = $('#courseMinuteList');
let that = this;
let data = {siteId:ClassDataProxy.siteId}
this._studentCurriculumInfo(12,data,function(_data){
if(_data){
that._studentCourseRender(courseMinuteList,_data.returnData.data)
}
});
}
//学生端课程数据 待学习
_studentCourseRender(courseMinuteList,_data){
courseMinuteList.empty();
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
let _dataList = _data;
this.pageNo = pagenum;
let recordData = 0;
if(count <= 12){
$('#courseMinutePageBox').hide();
}
//存储数据按日期分类
this.dataList={};
//if(ClassDataProxy.getTimeDay(_data[i].meetingBeginTime)){
for(let i = 0;i<_dataList.length;i++){
let item=_dataList[i];
if(item){
let temp = item.meetingBeginTime.split(' ')[0]
if(!this.dataList[temp]) {
this.dataList[temp] = [];
}
this.dataList[temp].push(item)
}
}
for(let key in this.dataList){
if(ClassDataProxy.getTimeDay(key)){
let arrList = this.dataList[key];
if(arrList){
for(let n = 0;n<arrList.length;n++){
let j = (n%4) == 3;
let defaultImg = '../images/u373.png';
let _img = arrList[n].meetingPhoto;
let _classifyList = this._format(classifyList,{
_classifyListR : j ?'classifyListR':'',
_isShowTitle : n == 0 ?'block':'none',
_meetingNumber : arrList[n].meetingNumber,
_id:arrList[n].meetingId,
_studyMsg:'进入学习',
_msgImg : _img?_img: defaultImg,
_meetingName : arrList[n].meeting_name,
_create_user : arrList[n].teacherName,
_liveTimer : key
})
courseMinuteList.append(_classifyList)
}
}
recordData = 1;
}
}
if(recordData == 0){
let _classifyList = '<div class="dataCenterErrorTitle">暂无数据~</div>'
courseMinuteList.append(_classifyList)
}
}
//学生端 我的课程 已学完
studentFormerlyModule(){
let courseMinuteList = $('#courseMinuteList');
let that = this;
let data = {siteId:ClassDataProxy.siteId}
this._studentCurriculumInfo(12,data,function(_data){
if(_data){
that._studentFormerlyRender(courseMinuteList,_data.returnData.data)
}
});
}
//学生端课程数据 已学完
_studentFormerlyRender(courseMinuteList,_data){
courseMinuteList.empty();
if(_data){
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
let _dataList = _data;
this.pageNo = pagenum;
// $('#courseMinutePageMsg').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <= 12){
$('#courseMinutePageBox').hide();
}
//存储数据按日期分类
this.dataList={};
for(let i = 0;i<_dataList.length;i++){
let item=_dataList[i];
if(item){
let temp = item.meetingBeginTime.split(' ')[0]
if(!this.dataList[temp]) {
this.dataList[temp] = [];
}
this.dataList[temp].push(item)
}
}
for(let key in this.dataList){
if(!ClassDataProxy.getTimeDay(key)){
let arrList = this.dataList[key];
if(arrList){
for(let n = 0;n<arrList.length;n++){
let j = (n%4) == 3;
let defaultImg = '../images/u373.png';
let _img = arrList[n].meetingPhoto;
let _classifyList = this._format(classifyList,{
_classifyListR : j ?'classifyListR':'',
_isShowTitle : n == 0 ?'block':'none',
_studyMsg:'继续学习',
_id:arrList[n].meetingId,
_meetingNumber : arrList[n].meetingNumber,
_msgImg : _img?_img: defaultImg,
_meetingName : arrList[n].meeting_name,
_create_user : arrList[n].teacherName,
_liveTimer : key
})
courseMinuteList.append(_classifyList)
}
}
}
}
}
}
//学生端 我的课程 收藏
studentCollectModule(){
let courseMinuteList = $('#courseMinuteList');
let that = this;
let data = {status:7,siteId:ClassDataProxy.siteId,id:ClassDataProxy.id}
this._studentCurriculumInfo(12,data,function(_data){
if(_data){
that._studentCollectRender(courseMinuteList,_data.returnData.data)
}
});
}
//学生端课程数据 收藏
_studentCollectRender(courseMinuteList,_data){
courseMinuteList.empty();
if(_data){
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
let _dataList = _data;
this.pageNo = pagenum;
// $('#courseMinutePageMsg').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <= 12){
$('#courseMinutePageBox').hide();
}
//存储数据按日期分类
this.dataList={};
for(let i = 0;i<_dataList.length;i++){
let item=_dataList[i];
if(item){
let temp = item.meetingBeginTime.split(' ')[0]
if(!this.dataList[temp]) {
this.dataList[temp] = [];
}
this.dataList[temp].push(item)
}
}
// let arrList = this.dataList[key];
if(_dataList){
for(let n = 0;n<_dataList.length;n++){
let j = (n%4) == 3;
let defaultImg = '../images/u373.png';
let _img = _dataList[n].meetingPhoto;
let _classifyList = this._format(classifyList,{
_classifyListR : j ?'classifyListR':'',
_isShowTitle : 'none',
_studyMsg:'取消收藏',
_id:_dataList[n].meetingId,
_meetingNumber : _dataList[n].meetingNumber,
_msgImg : _img?_img: defaultImg,
_meetingName : _dataList[n].meeting_name,
_create_user : _dataList[n].teacherName,
_liveTimer : _dataList[n].meetingBeginTime.split(' ')[0]
})
courseMinuteList.append(_classifyList)
}
}
}
}
//学生端 我的课程
_courseInfoListHandler(evt){
this.commonality(evt);
this.studentCourses();
}
//老师端 我的课程
_teacherLiveListHandler(evt){
this.commonality(evt);
this.teacherCourses();
}
//切换类的公用样式
commonality(evt){
$(evt.currentTarget).addClass('liveInfoLeftLiCheck').siblings().removeClass('liveInfoLeftLiCheck');
}
//老师端数据请求
_teacherCurriculumInfo(data,num,ind,callback){
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/getMeeting';
let that = this;
$.ajax({
type: "POST",
url: _url,
timeout:5000,
data : data,
headers: {siteId:ClassDataProxy.siteId,pageno:num, page:ind,
'token':ClassDataProxy.token},
success:function(_data){
//获取我的课程数据
if(_data && _data.code == 200){
if(callback){
callback(_data);
}
}else{
if(callback){
callback(null);
}
}
},
error:function(error){
//alert('直播数据获取失败')
if(callback){
callback(null);
}
loger.log(error,'直播数据获取失败')
}
})
}
_studentCurriculumInfo(num,_data,callback){
if(ClassDataProxy.id == ''){
return;
}
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/studentMeeting/getStudentMeetingByStudentId/'+ClassDataProxy.id;
let that = this;
$.ajax({
type: "POST",
url: _url,
timeout:5000,
data:_data,
headers: {siteId:ClassDataProxy.siteId,pageno:num,id:ClassDataProxy.id,
'token':ClassDataProxy.token},
success:function(_data){
//获取我的课程数据
if(_data && _data.code == 200){
if(callback){
callback(_data);
}
}else{
if(callback){
callback(null);
}
}
},
error:function(error){
//alert('直播数据获取失败')
if(callback){
callback(null);
}
loger.log(error,'直播数据获取失败')
}
})
}
//工具类
_format(str, obj) {
return str.replace(/\{(\w+)\}/g, function (match, group, index) {
return obj[group];
});
};
}
export default MyCoursesApe;