MyBookingsApe.js
17.0 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
//*
// 个人中心 我的预约
// */
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}">进入学习</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 teacherInfoLeft = `<div class="teacherCorrelatedInfoBox">
<div class="teacherCorrelatedInfoLeft">
<img class="teacherCorrelatedInfoImg" id="teacherCorrelatedInfoImg" src="images/u293.png" alt="">
<div class="teacherCorrelatedInfo">
<b class="teacherCorrelatedInfoName" id="teacherCorrelatedInfoName">{_teacherName}</b>
<b class="teacherCorrelatedInfoMajor">北京市|少儿英语</b>
<b class="teacherCorrelatedInfoCourse">课程:50</b>
<span class="teacherCorrelatedInfoMajorMsg">毕业于外国语学院,专业8级</span>
<p class="cancelReservationBtn"">取消预约</p>
</div>
</div>
<div class="teacherCorrelatedInfoCenter">`;
const teacherInfoCenter= `<img class="teachercourseImg" data="{_id}" src="{_imgSrc}" alt="">`;
const teacherInfoRight = `</div> <div class="teacherCorrelatedInfoBtn" data="{_teacherName}" value="{_meetingId}">更多课程</div>
</div></div>`;
const teacherDetail = `<span class="teacherDetailCurriculumList">《{_detailList}》</span>`
let loger = Loger.getLoger('PC-MyBookingsApe');
class MyBookingsApe extends Ape {
constructor() {
super();
this.dataList = {};
this.teacherList = {};
this.presentInd = 1;//点击翻页默认为第一页
this.pageNo = 0;
this.orderId = 0;
this.collectId = 0;
this.addEvent();
this.init();
}
init() {
$('#subscribeList .liveInfoLeftLi').on('click',this._subscribeListHandler.bind(this));//课程 老师
$('#studentMyCenterContentList').on('mouseenter','.classifyListMyCenter',this._mouseenter.bind(this));//个人中心移入进入课堂
$('#studentMyCenterContentList').on('mouseleave','.classifyListMyCenter',this._mouseleave.bind(this));//个人中心移出进入课堂
$('#courseMinuteList').on('mouseenter','.classifyListMyCenter',this._mouseenter.bind(this));//课程移入进入课堂
$('#courseMinuteList').on('mouseleave','.classifyListMyCenter',this._mouseleave.bind(this));//课程移出进入课堂
$('#teacherCorrelatedInfo').on('mouseenter','.classifyListMyCenter',this._cancelMouseenter.bind(this));//我的预约 课程移入显示取消预约
$('#teacherCorrelatedInfo').on('mouseleave','.classifyListMyCenter',this._cancelMouseleave.bind(this));//我的预约 课程移出隐藏取消预约
$('#studentMyCenterContentList').on('click','.accessLearningBtn',this._enterClassRoomHandler.bind(this));//我的预约进入课堂
$('#courseMinuteList').on('click','.accessLearningBtn',this._enterClassRoomHandler.bind(this));//我的预约进入课堂
$('#myCurriculumInfo').on('click','.teacherEnterClass',this._enterClassRoomHandler.bind(this));//我的课程进入课堂
$('#teacherCorrelatedInfo').on('click','.teacherCorrelatedInfoBtn',this._teacherSubscribeMoveHandler.bind(this));//点击预约查看当前点击的更多信息
$('#teacherCorrelatedInfo').on('click','.cancelReservation',this._cancelReservationBtn.bind(this));//取消预约
$('#removeCancel').on('click',this._removeCancelHandler.bind(this));//取消预约 取消
$('#removeConfirm').on('click',this._removeConfirmHandler.bind(this));//取消预约 确定
$('#teacherCorrelatedInfo').on('click','.teachercourseImg',this._teacherClassDetails.bind(this));//点击进入老师课堂详情页
$('#courseHomePage').on('click',this._homePageHandler.bind(this));//首页
$('#courseUpPage').on('click',this._upPageHandler.bind(this));//上页
$('#courseDownPage').on('click',this._downPageHandler.bind(this));//下页
$('#courseEndPage').on('click',this._endPageHandler.bind(this));//尾页
$('#courseSpecificPage').on('click',this._assignPageHandler.bind(this));//指定页
}
addEvent() {
}
//首页
_homePageHandler(){
this.presentInd = 1;
this.studentBookings(this.presentInd);
}
//上页
_upPageHandler(){
if(this.presentInd > 1){
this.presentInd--;
this.studentBookings(this.presentInd);
}
}
//下页
_downPageHandler(){
loger.log('点击下一页')
if(this.presentInd < this.pageNo){
this.presentInd++;
this.studentBookings(this.presentInd);
}
}
//尾页
_endPageHandler(){
this.presentInd = this.pageNo;
this.studentBookings(this.presentInd);
}
//指定页
_assignPageHandler(){
let inputVal = $('#classHandlerPageInfoInput').val();
if(parseInt(inputVal) <= this.pageNo || parseInt(inputVal) >= 1 ){
this.studentBookings(parseInt(inputVal));
}
}
//我的预约
myBookingsMessage(){
let subscribeList = $('#subscribeList');
this._anewLoad(subscribeList)
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_8){
this.studentBookings(1);
}
}
_anewLoad(ele){
ele.find('.liveInfoLeftLi').eq(0).addClass('liveInfoLeftLiCheck').siblings().removeClass('liveInfoLeftLiCheck')
}
studentBookings(ind){
let that = this;
let data = $('#subscribeList').find('.liveInfoLeftLiCheck').attr('data');
if(parseInt(data) == 1){
this._studentCurriculumInfo(32,ind,function(_data){
if(_data){
that._studentSubscribeTeacher(_data.returnData.data)
}
})
}else{
this._studentCurriculumInfo(12,ind,function(_data){
if(_data){
that._studentSubscribe(_data.returnData.data)
}
})
}
}
_studentSubscribe(_data){
let teacherCorrelatedInfo = $('#teacherCorrelatedInfo');
teacherCorrelatedInfo.empty();
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;
$('#coursePageBox').hide();
for(let i = 0;i<_data.length;i++){
if(_data[i]){
let j = (i%4)==3;
let _classifyList = this._format(classifyList,{
_classifyListR : j?'classifyListR':'',
_isShowTitle : 'none',
_id:_data[i].meetingId,
_meetingNumber : _data[i].meetingNumber,
_msgImg : '../images/u373.png',
_meetingName : _data[i].meeting_name,
_create_user : _data[i].teacherName,
_liveTimer : _data[i].meetingBeginTime.split(' ')[0],
_studentMeetingId : _data[i].studentMeetingId
})
teacherCorrelatedInfo.append(_classifyList)
}else{
console.error('_gainClassData没数据')
}
}
}
}
_studentSubscribeTeacher(_data){
let teacherCorrelatedInfo = $('#teacherCorrelatedInfo');
teacherCorrelatedInfo.empty();
if(_data){
this.teacherList={};
for(let i = 0;i<_data.length;i++){
let item=_data[i];
if(item){
let temp = item.teacherName;
if(!this.teacherList[temp]) {
this.teacherList[temp] = [];
}
this.teacherList[temp].push(item)
}
}
for( let key in this.teacherList){
let teacherInfo = ''
let arrList = this.teacherList[key];
teacherInfo = this._format(teacherInfoLeft,{
_teacherName : key
})
for(let n = 0;n<arrList.length;n++){
if(n<2){
teacherInfo += this._format(teacherInfoCenter,{
_imgSrc : 'images/u374.png',
_id : arrList[n].teacherName
})
}
}
teacherInfo += this._format(teacherInfoRight,{
_teacherName : key,
_meetingId :arrList[0].meetingId
})
teacherCorrelatedInfo.append(teacherInfo)
}
}
}
_cancelReservationBtn(evt){
let _id = $(evt.target).attr('data');
this.orderId = _id;
ClassDataProxy.getMarginTopHandler($('#removeHandler'));
$("#removeHandlerBox").show();
$('#removeHandlerContent').html('确定要取消预约吗?');
$('#removeConfirm').attr('data',1);
}
_removeCancelHandler(){
this._hideRemoveBox();
}
_removeConfirmHandler(evt){
let ind = $(evt.target).attr('data')
if(parseInt(ind) == 7){
this.classCancelCollect(this.collectId);
}else if(parseInt(ind) == 1){
this._cancelSubscribeHandler(this.orderId);
}
this._hideRemoveBox();
}
_hideRemoveBox(){
$("#removeHandlerBox").hide();
$('#removeHandlerContent').html('');
}
//取消预约
_cancelSubscribeHandler(_id){
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/studentMeeting/updateStudentMeetingBySite/'+_id;
let that = this;
$.ajax({
type: "PUT",
url: _url,
timeout:5000,
headers: {
siteId:ClassDataProxy.siteId,
'token':ClassDataProxy.token
},
data:{status:'5'},
success:function(_data){
//获取课堂数据
if(_data && _data.code == 200){
that.studentBookings();
}
},
error:function(error){
console.log(error,'失败')
}
})
}
//点击老师预约显示 老师详细
_teacherClassDetails(evt){
let name = $(evt.target).attr('data');
let ind = $(evt.target).index();
let _data = this.teacherList[name][ind]
$('#lanclassBox').show();
$('#myCenterBox').hide();
$('#lanclassContentTitle').html(_data.meeting_name);
$('#lanclassContentInfoName').html(_data.teacherName);
$('#lanclassContentInfoTimeStart').html('开始时间:'+_data.meetingBeginTime);
$('#lanclassContentInfoTimeEnd').html('结束时间:'+_data.meetingEndTime);
}
_teacherSubscribeMoveHandler(evt){
let _id = $(evt.target).attr('value');
$('#teacherDetailBox').attr('data',_id);
$('#teacherDetailBox').show();
$('#myCenterBox').hide();
/* let buttonIsCheck = $('#orderBtn').attr('value','0');
if($('#orderBtn').attr('value') == '0'){
$('#orderBtn').attr('disabled',false)
$('#orderBtn').css('background','#ccc')
}*/
let teacherDetailCurriculum = $('#teacherDetailCurriculum');
teacherDetailCurriculum.empty();
let _data = $(evt.target).attr('data');
if(_data){
let _dataList = this.teacherList[_data];
$('#teacherDetailInfoDetailName').html(_dataList[0].teacherName);
for(let i = 0;i<_dataList.length;i++){
let _teacherDetail = this._format(teacherDetail,{
_detailList : _dataList[i].meeting_name
})
teacherDetailCurriculum.append(_teacherDetail)
}
}
}
//切换类的公用样式
commonality(evt){
$(evt.currentTarget).addClass('liveInfoLeftLiCheck').siblings().removeClass('liveInfoLeftLiCheck');
}
_subscribeListHandler(evt){
this.commonality(evt);
this.studentBookings();
}
_cancelMouseenter(evt){
$(evt.currentTarget).find('.cancelReservation').show();
}
_cancelMouseleave(evt){
$(evt.currentTarget).find('.cancelReservation').hide();
}
_mouseenter(evt){
$(evt.currentTarget).find('.accessLearningBtn').show();
}
_mouseleave(evt){
$(evt.currentTarget).find('.accessLearningBtn').hide();
}
_enterClassRoomHandler(evt){
let val = $(evt.currentTarget).find('.myCenterContentMaskBtn').attr('value');
let _id = $(evt.currentTarget).parents('.classifyListMyCenter').attr('data');
this.collectId = _id;
if(val == '取消收藏'){
this.showcancelBox();
}else{
let ind = $(evt.target).attr('data');
window.open('http://networkshool.xuedianyun.com/3m/attend.do?meetingNumber=' + ind);
}
}
showcancelBox(_id){
ClassDataProxy.getMarginTopHandler($('#removeHandler'));
$("#removeHandlerBox").show();
$('#removeHandlerContent').html('确定要取消收藏吗?');
$('#removeConfirm').attr('data',7)
}
//课堂取消收藏
classCancelCollect(_id){
let that = this;
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/studentMeeting/delStudentMeetingBySite/'+_id+'/'+ClassDataProxy.siteId;
$.ajax({
type: "delete",
url: _url,
timeout:5000,
headers: {
siteId:ClassDataProxy.siteId,
'token':ClassDataProxy.token
},
data:{siteId:ClassDataProxy.siteId,id:ClassDataProxy.id},
success:function(_data){
//获取课堂数据
if(_data && _data.code == 200){
console.log(_data,'课堂取消收藏成功')
this._emit(MessageTypes.COLLECT_BREAK);
}
},
error:function(error){
console.log(error,'课堂取消收藏失败')
}
})
}
_studentCurriculumInfo(num,ind,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,
headers: {siteId:ClassDataProxy.siteId,pageno:num,page:ind,id:ClassDataProxy.id,
'token':ClassDataProxy.token},
success:function(_data){
// loger.log('预约信息斯柯达开始',_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 MyBookingsApe;