ManagementHomePageApe.js
21.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
//*
// 管理员首页界面
// */
import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import MessageTypes from "../MessageTypes";
import ErrorApe from "./ErrorApe";
let loger = Loger.getLoger('PC-ManagementHomePageApe');
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="8%" class="tr_center">
课堂主题
</th>
<th width="8%" class="tr_center">
课堂号
</th>
<th width="7%" class="tr_center">
老师
</th>
<th width="6%" class="tr_center">
课堂状态
</th>
<th width="20%" class="tr_center">
课堂时间
</th>
<th width="6%" class="tr_center">
在线人数
</th>
<th width="23%" 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">{_esenglish}</td>
<td width="7%" class="tr_main">{_userName}</td>
<td width="6%" class="tr_main">{_stateInfo}</td>
<td width="18%" class="tr_main">{_time}</td>
<td width="6%" class="tr_main">{_onlineLen}</td>
<td width="21%" class="tr_main tr_mainRight" align="center" data="{_esenglish}">
<a id="{_DocInd}" class="classHandlePort" href="###">课件</a>
<a id="{_updateInd}" class="classHandlePort" href="###">修改</a>
<a data="{_removeInd}" class="classHandlePort deleteClass" href="#">删除</a>
<a data="{_joinInd}" class="classHandlePort joinClass" href="#">加入课堂</a>
<a data="{_removeInd}" class="classHandlePort updatacover" value="{_value}" href="javascript:void(0);">上传封面</a>
<a data="{_removeInd}" class="classHandlePort generalize" value="{_value}" href="javascript:void(0);">推广</a>
</td>
</tr>
`;
const adminListEnd = `</tbody></table>`;
class ManagementHomePageApe extends Ape {
constructor() {
super();
this.pageNo = 0;
this.presentInd = 1;
this.files = {};
this.dataId = 0;
this.addEvent();
this.init();
}
init() {
$('#liveInfoList0 li').on('click',this._liveInfoLeftLiHandler.bind(this));//首页
$('#classHandlerHomePage0_0').on('click',this._homePageHandler.bind(this));//首页
$('#classHandlerUpPage0_0').on('click',this._upPageHandler.bind(this));//上页
$('#classHandlerDownPage0_0').on('click',this._downPageHandler.bind(this));//下页
$('#classHandlerEndPage0_0').on('click',this._endPageHandler.bind(this));//尾页
$('#classHandlerSpecificPage0_0').on('click',this._assignPageHandler.bind(this));//指定页
$('#classHandlerHomePage0_1').on('click',this._homePageHandler.bind(this));//首页
$('#classHandlerUpPage0_1').on('click',this._upPageHandler.bind(this));//上页
$('#classHandlerDownPage0_1').on('click',this._downPageHandler.bind(this));//下页
$('#classHandlerEndPage0_1').on('click',this._endPageHandler.bind(this));//尾页
$('#classHandlerSpecificPage0_1').on('click',this._assignPageHandler.bind(this));//指定页
$('#classHandlerHomePage0_2').on('click',this._homePageHandler.bind(this));//首页
$('#classHandlerUpPage0_2').on('click',this._upPageHandler.bind(this));//上页
$('#classHandlerDownPage0_2').on('click',this._downPageHandler.bind(this));//下页
$('#classHandlerEndPage0_2').on('click',this._endPageHandler.bind(this));//尾页
$('#classHandlerSpecificPage0_2').on('click',this._assignPageHandler.bind(this));//指定页
$('#courseContent0').on('click','.deleteClass',this._deleteClass.bind(this));//删除课堂
$('#courseContent0').on('click','.joinClass',this._joinClass.bind(this));//加入课堂
$('#courseContent0').on('click','.updatacover',this._updatacover.bind(this));//上传课堂封面
$('#courseContent0').on('click','.generalize',this._generalize.bind(this));//上传课堂封面 推广
$('#updataPhotoA').on('click',this._closeUpdatacover.bind(this));//上传课堂封面 取消
$('#updataPhotoInput').on('change',this._updataPhotoBtnHandler.bind(this));//上传课堂封面
$('#updataPhotoBtn').on('click',this._submitBtnHandler.bind(this));//上传课堂封面 上传按钮
}
addEvent() {
}
//首页
_homePageHandler(){
this.presentInd = 1;
let ind = $('#classHandlerPageBox0').attr('data');
switch (parseInt(ind)){
case 1:
this._adminLiveModule(this.presentInd);
break;
case 2:
this._adminNoneLiveModule(this.presentInd);
break;
case 4:
this._adminEndLiveModule(this.presentInd);
break;
default:
return;
}
}
//上页
_upPageHandler(){
if(this.presentInd > 1){
this.presentInd--;
let ind = $('#classHandlerPageBox0').attr('data');
switch (parseInt(ind)){
case 1:
this._adminLiveModule(this.presentInd);
break;
case 2:
this._adminNoneLiveModule(this.presentInd);
break;
case 4:
this._adminEndLiveModule(this.presentInd);
break;
default:
return;
}
}
}
//下页
_downPageHandler(){
if(this.presentInd < this.pageNo){
this.presentInd++;
let ind = $('#classHandlerPageBox0').attr('data');
switch (parseInt(ind)){
case 1:
this._adminLiveModule(this.presentInd);
break;
case 2:
this._adminNoneLiveModule(this.presentInd);
break;
case 4:
this._adminEndLiveModule(this.presentInd);
break;
default:
return;
}
}
}
//尾页
_endPageHandler(){
this.presentInd = this.pageNo;
let ind = $('#classHandlerPageBox0').attr('data');
switch (parseInt(ind)){
case 1:
this._adminLiveModule(this.presentInd);
break;
case 2:
this._adminNoneLiveModule(this.presentInd);
break;
case 4:
this._adminEndLiveModule(this.presentInd);
break;
default:
return;
}
}
//指定页
_assignPageHandler(){
let val;
let ind = $('#classHandlerPageBox0').attr('data');
let card = $('#liveInfoList0 .liveInfoLeftLiCheck').index();
let inputVal = $('#classHandlerPageInfoInput0_'+card).val();
if(parseInt(inputVal) > this.pageNo ){
val = this.pageNo;
}else if(parseInt(inputVal) < 1){
val = 1;
}else{
val = parseInt(inputVal)
}
switch (parseInt(ind)){
case 1:
this._adminLiveModule(val);
break;
case 2:
this._adminNoneLiveModule(val);
break;
case 4:
this._adminEndLiveModule(val);
break;
default:
return;
}
$('#classHandlerPageInfoInput0_'+card).val('')
}
_adminInfo(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,'直播数据获取失败')
}
})
}
adminListSwitch(){
let ind = $('#liveInfoList0 .liveInfoLeftLiCheck').attr('data');
let card = $('#liveInfoList0 .liveInfoLeftLiCheck').index();
$('#classHandlerPageBox0').attr('data',ind)
let status = parseInt(ind);
$('#classHandlerPageBox0_'+card).show().siblings().hide();
this.presentInd = 1;
switch (status){
case 1:
//正在直播
this._adminLiveModule(1);
break;
case 2:
//未开始
this._adminNoneLiveModule(1);
break;
case 4:
//已结束
this._adminEndLiveModule(1);
break;
default:
return;
}
}
//正在直播
_adminLiveModule(ind){
let data = {siteId:ClassDataProxy.siteId,meetingStatus:1};
let that = this;
this._adminInfo(data,8,ind,function(_data){
//首页直播信息渲染
if(_data){
that._adminLiveCourse(_data.returnData.data);
that._adminLivePage(_data.returnData.data);
}
})
}
_adminLiveCourse(_data){
let courseContent = $('#courseContent0');
courseContent.empty();
let _dataList = _data.meetingInfo;
courseContent.append(adminListTit);
if(_dataList.length > 0){
for(let i = 0;i<_dataList.length;i++){
let _adminList = this._format(adminList,{
_meetingName : _dataList[i].meetingName,
_esenglish : _dataList[i].meetingNumber,
_userName : _dataList[i].create_user,
_stateInfo : '准备',
_time: _dataList[i].beginTime+' - '+_dataList[i].endTime,
_onlineLen : '0',
_DocInd : 'classDoc'+i,
_mediaInd : 'classMedia'+i,
_musicInd : 'classMusic'+i,
_updateInd : 'classUpdate'+i,
_updatacover : 'updatacover'+i,
_removeInd : _dataList[i].id,
_value : _dataList[i].meetingPhoto ? _dataList[i].meetingPhoto : '',
_joinInd : _dataList[i].meetingNumber
})
courseContent.append(_adminList);
}
courseContent.append(adminListEnd);
}else{
this._gainUserClassDataErr();
}
}
_adminLivePage(_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.pageNo = pagenum;
$('#classHandlerPageMsg0_0').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <=8){
$('#classHandlerPageBox0_0').hide();
}
}
}
//未开始
_adminNoneLiveModule(ind){
let data = {siteId:ClassDataProxy.siteId,meetingStatus:2};
let that = this;
this._adminInfo(data,8,ind,function(_data){
//首页直播信息渲染
if(_data){
that._adminLiveCourse(_data.returnData.data);
that._adminNotPage(_data.returnData.data);
}
})
}
_adminNotPage(_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.pageNo = pagenum;
$('#classHandlerPageMsg0_1').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <=8){
$('#classHandlerPageBox0_1').hide();
}
}
}
//已结束
_adminEndLiveModule(ind){
let data = {siteId:ClassDataProxy.siteId,meetingStatus:4};
let that = this;
this._adminInfo(data,8,ind,function(_data){
//首页直播信息渲染
if(_data){
that._adminLiveCourse(_data.returnData.data);
that._adminOverPage(_data.returnData.data);
}
})
}
_adminOverPage(_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.pageNo = pagenum;
$('#classHandlerPageMsg0_2').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
if(count <=8){
$('#classHandlerPageBox0_2').hide();
}
}
}
//点击翻页
detailPage(ind){
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/getMeeting';
let that = this;
let status = $('#liveInfoList0').find('.liveInfoLeftLiCheck').attr('data');
$.ajax({
type: "POST",
url: _url,
data:{siteId:ClassDataProxy.siteId,meetingStatus:status},
headers: {
siteId:ClassDataProxy.siteId,
page:ind,
pageno:2,
'token':ClassDataProxy.token
},
success:function(_data){
if(_data && _data.code == 200){
that._gainClassData(_data.returnData.data);
}
},
error:function(error){
that._gainUserClassDataErr();
console.log(error,'管理员首页')
}
})
}
_gainClassData(_data){
let courseContent = $('#courseContent0');
courseContent.empty();
let count = _data.count;
let page = _data.page;
let pageno = _data.pageno;
let pagenum = Math.ceil(count / pageno);
let _dataList = _data.meetingInfo;
this.pageNo = pagenum;
$('#classHandlerPageMsg0_0').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
courseContent.append(adminListTit);
if(_dataList){
//
for(let i = 0;i<_dataList.length;i++){
let _adminList = this._format(adminList,{
_meetingName : _dataList[i].meetingName,
_esenglish : _dataList[i].meetingNumber,
_userName : _dataList[i].create_user,
_stateInfo : '准备',
_time: _dataList[i].beginTime+' - '+_dataList[i].endTime,
_onlineLen : '0',
_DocInd : 'classDoc'+i,
_mediaInd : 'classMedia'+i,
_musicInd : 'classMusic'+i,
_updateInd : 'classUpdate'+i,
_updatacover : 'updatacover'+i,
_removeInd : _dataList[i].id,
_value : _dataList[i].meetingPhoto ? _dataList[i].meetingPhoto : '',
_joinInd : _dataList[i].meetingNumber
})
courseContent.append(_adminList);
}
courseContent.append(adminListEnd);
}
}
_gainUserClassDataErr(){
let courseContent = $('#courseContent0');
courseContent.empty();
courseContent.append(adminListTit);
let _adminList = '<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">' +
'<td class="tr_main tr_mainNone">' +
'该课堂暂无课程数据~'+
'</td>>'+
'</tr>'
courseContent.append(_adminList);
courseContent.append(adminListEnd);
}
//删除课堂
_deleteClass(evt){
let id = $(evt.target).attr('data');
loger.log('删除课堂',id)
$.ajax({
type: "POST",
url: "http://networkshool.xuedianyun.com/3m/meeting/updateToCancel.do",
dataType: "text",
data:"meeting.id=" + id + "&temp=" + new Date().getTime(),
success:function(_data){
loger.log('删除课堂',_data)
if(_data){
// window.location.href = "http://networkshool.xuedianyun.com/3m/meeting/updateToCancel.do";
}
},
error:function(error){
loger.log(error,'失败')
window.location.href = "http://networkshool.xuedianyun.com/3m/meeting/updateToCancel.do";
// window.location.href = "http://networkshool.xuedianyun.com/3m/conference_domain.do";
}
})
}
_joinClass(evt){
let _data = $(evt.target).attr('data');
window.open('http://networkshool.xuedianyun.com/3m/attend.do?meetingNumber=' + _data);
}
_updatacover(evt){
ClassDataProxy.getMarginTopHandler($('#updataPhoto'));
$('#updataPhotoBox').attr('data',1);//上传图片
$('#updataPhotoBox').show();
$('#updataPhotoImg').css({
'width':'120px',
"margin-left":'80px'
})
let _data = $(evt.target).attr('data');
this.dataId = _data;
let _value = $(evt.target).attr('value');
$("#updataPhotoImg").attr('src',_value)
}
_generalize(evt){
ClassDataProxy.getMarginTopHandler($('#updataPhoto'));
$('#updataPhotoBox').show();
$('#updataPhotoImg').css({
'width':'230px',
"margin-left":'20px'
})
$('#updataPhotoBox').attr('data',2);//上传推广图片
let _data = $(evt.target).attr('data');
this.dataId = _data;
let _value = $(evt.target).attr('value');
$("#updataPhotoImg").attr('src',_value)
}
_closeUpdatacover(){
$('#updataPhotoBox').hide();
$("#updataPhotoInput").val('');
$("#updataPhotoImg").attr('src','')
}
_updataPhotoBtnHandler() {
let fileInput = document.getElementById('updataPhotoInput');
let preview = document.getElementById('updataPhotoImg');
let file = fileInput.files[0];
if (!file) {
loger.log("没有选择文件");
return;
}
let fileStr = file.name;
if(fileStr){
fileStr=fileStr.toLowerCase();
}
if (fileStr.lastIndexOf('.jpg') < 0 &&
fileStr.lastIndexOf('.png') < 0) {
alert('不是有效的图片文件!');
return;
}
let reader = new FileReader();
reader.onload = function(e){
let data = e.target.result;
$(preview).attr('src',data )
}
reader.readAsDataURL(file);
let data = new FormData($('#updataPhotoForm')[0]);
this.files = data;
}
_submitBtnHandler(){
let genre = $('#updataPhotoBox').attr('data');
let _dataId = this.dataId;
let _url = 'http://networkschool.xuedianyun.com:3001/upload/upLoadDoc?businessId='+_dataId+'&category='+parseInt(genre)+'&siteId='+ClassDataProxy.siteId;
let files = this.files;
let that = this;
$.ajax({
type: "POST",
url: _url,
data: files,
dataType: 'JSON',
cache: false,
processData: false,
contentType: false,
success:function(_data){
loger.log(_data,'成功1111')
ClassDataProxy.getMarginTopHandler($('#warnHintBox'));
ErrorApe.showWarnError('上传成功');
that._closeUpdatacover();
}.bind(this),
error: function (_data) {
ClassDataProxy.getMarginTopHandler($('#warnHintBox'));
ErrorApe.showWarnError('上传失败');
loger.log(_data,'error')
}
})
}
_switchover(evt){
$(evt.currentTarget).addClass('liveInfoLeftLiCheck').siblings().removeClass('liveInfoLeftLiCheck');
}
_liveInfoLeftLiHandler(evt){
this._switchover(evt);
this.adminListSwitch();
}
//工具类
_format(str, obj) {
return str.replace(/\{(\w+)\}/g, function (match, group, index) {
return obj[group];
});
};
}
export default ManagementHomePageApe;