MyBookingsApe.js
12.2 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
//*
// 个人中心 我的预约
// */
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}">
<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.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._cancelSubscribeHandler.bind(this));//取消预约
$('#teacherCorrelatedInfo').on('click','.teachercourseImg',this._teacherClassDetails.bind(this));//点击进入老师课堂详情页
}
addEvent() {
}
//我的预约
myBookingsMessage(){
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_8){
this.studentBookings();
}
}
studentBookings(){
let that = this;
let data = $('#subscribeList').find('.liveInfoLeftLiCheck').attr('data');
this._studentCurriculumInfo(12,function(_data){
if(_data){
if(data == '1'){
that._studentSubscribeTeacher(_data.returnData.data)
}else{
that._studentSubscribe(_data.returnData.data)
}
}
});
}
_studentSubscribe(_data){
let teacherCorrelatedInfo = $('#teacherCorrelatedInfo');
teacherCorrelatedInfo.empty();
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',
_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,
// meetingNumber
})
for(let n = 0;n<arrList.length;n++){
teacherInfo += this._format(teacherInfoCenter,{
_imgSrc : 'images/u374.png',
_id : arrList[n].teacherName
})
}
teacherInfo += this._format(teacherInfoRight,{
_teacherName : key,
// _meetingId :
})
teacherCorrelatedInfo.append(teacherInfo)
}
}
}
//取消预约
_cancelSubscribeHandler(evt){
let _id = $(evt.target).attr('data');
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){
$('#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 ind = $(evt.target).attr('data');
window.open('http://networkshool.xuedianyun.com/3m/attend.do?meetingNumber=' + ind);
}
_studentCurriculumInfo(num,callback){
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/studentMeeting/getStudentMeetingByStudentId/'+ClassDataProxy.id;
let that = this;
$.ajax({
type: "GET",
url: _url,
timeout:5000,
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 MyBookingsApe;