CreateClassApe.js
13.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
//*
// 创建课堂模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import dateUI from 'libs/laydate';
import ErrorApe from "./ErrorApe";
import MessageTypes from "../MessageTypes";
let loger = Loger.getLoger('PC-CreateClassApe');
class CreateClassApe extends Ape {
constructor() {
super();
this.classDateList = {};//创建课堂信息
this.teacherArr = [];
this.isLocalStorage();
this.allotSpeaker();
this.addEvent();
this.init();
}
init() {
$('#collectYes').hide();
//默认显示当前时间戳
this._showPresentTime();
//创建课堂
$('#createClassA').on('click',this._closeClassHandler.bind(this));//关闭创建课堂
$('.main_closeBtn').on('click',this._closeClassHandler.bind(this));//关闭创建课堂
$('#createClassSubmit1').on('click',this._createClassSubmit1Handler.bind(this));//创建课堂第一步
$('#createClassUpOne').on('click',this._createClassUpHandler.bind(this));//创建课堂第一步 返回
$('#createClassSubmit2').on('click',this._createClassSubmit2Handler.bind(this));//创建课堂第二步
$('#createClassUpTwo').on('click',this._createClassUpTwoHandler.bind(this));//创建课堂第二步 返回
$('#createClassSubmit3').on('click',this._createClassSubmit3Handler.bind(this));//创建课堂第三步
$('#openParamBtn').on('click',this._openParamBtnHandler.bind(this));//打开更多参数
$('#courseContent').on('click','.classHandlePort',this._classHandlePortHandler.bind(this));//加入课堂
//日历插件
this._dateUI();
}
addEvent() {
}
isLocalStorage(){
//设置当前时间 给输入框默认值
this._setNewTime();
//设置弹框位置
this._setMarginTop();
}
_showPresentTime(){
let newDate = new Date();
let month = (newDate.getMonth()+1)<10?'0'+(newDate.getMonth()+1):(newDate.getMonth()+1);
let date = newDate.getDate()<10?'0'+newDate.getDate():newDate.getDate();
let timer = newDate.getFullYear() + '-'+ month +'-'+ date;
let hours = newDate.getHours();
$('.createClassTime1').text(timer);
$("#meeting_starthour").find("option[value = '"+hours+"']").attr("selected","selected");
$('#meeting_endhour').find("option[value = '"+ (hours + 2) +"']").attr("selected","selected");
}
_createClassBtnHandler(){
$('#createClassBox').show();
$('#scheduleForm1').show();
$('#scheduleForm2').hide();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
//获取第一步中老师列表
this.allotSpeaker();
}
//获取第一步中老师列表
allotSpeaker(){
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/users/getUser';
let that = this;
let dataInfo = {
siteId : ClassDataProxy.siteId,
userType : 1
}
$.ajax({
type: "POST",
url: _url,
timeout:5000,
data:dataInfo,
headers: {siteId:ClassDataProxy.siteId,
pageno:7,
'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
success:function(_data){
//获取课堂数据
if(_data && _data.code == 200){
that.teacherInfo(_data.returnData.data.users);
}
},
error:function(error){
//alert('直播数据获取失败')
loger.log(error,'直播数据获取失败')
}
})
}
teacherInfo(_data){
let classTeacherInfo = $('#classTeacherInfo');
classTeacherInfo.empty();
let option = ``;
for(let i = 0;i<_data.length;i++){
option += `<option value="${_data[i].loginName}">${_data[i].loginName}</option>`;
}
classTeacherInfo.append(option);
}
_closeClassHandler(){
$('#createClassBox').hide();
this._closeCreateClass();
}
_createClassSubmit1Handler(){
let meetingName = $('#classThemeUserName');//课堂主题
let presenterPassword = $('#classThemePassWord');//主持人密码
let createClassSubmit1 = $('#createClassSubmit1');//
let isPublic = $("input[name='allowPublic']:checked").val();//是否公开课堂
let meetingType = $("input[name='meetingType']:checked").val();//课堂类型
let h5Module = $("input[name='h5Module']:checked").val();//是否支持H5
let partcKey = $('#partcKey').val(); //课堂密码
let meetingContent = $("meeting_content").val();//课堂描述
let classTeacherInfo = $('#classTeacherInfo').val();
if( meetingName.val().length < 1 || meetingName.val().length>32 ){
meetingName.focus();
return false;
}
if(presenterPassword.val().length < 6 || presenterPassword.val().length > 12){
presenterPassword.focus();
return false;
}
console.log('第一步信息完成')
let dateList ={
"meetingName":meetingName.val(),
"presenterPassword":presenterPassword.val(),
"isPublic":isPublic,
"meetingType":meetingType,
"h5Module":h5Module,
"partcKey":'',
"meetingContent":meetingContent,
"loginName":classTeacherInfo
}
this.classDateList = dateList;
$('#scheduleForm1').hide();
$('#scheduleForm2').show();
}
_createClassUpHandler(){
$('#scheduleForm1').show();
$('#scheduleForm2').hide();
}
_createClassSubmit2Handler(){
let createClassStartTime = $('#createClassStartTime').text();//开始年
let meeting_starthour = $('#meeting_starthour').val();//开始月
let meeting_startminute = $('#meeting_startminute').val();//开始日
let createClassEndTime = $('#createClassEndTime').text();//结束年
let meeting_endhour = $('#meeting_endhour').val();//结束月
let meeting_endminute = $('#meeting_endminute').val();//结束日
let maxAudio = $('#maxAudio');
let maxVideo = $('#maxVideo');
maxAudio.empty();
maxVideo.empty();
let meetingType = this.classDateList.meetingType;
let option = ``;
switch (parseInt(meetingType)){
case 1:
//1v1
option = `<option value="2">2路</option>`;
break;
case 2:
//直播
option = `<option value="1">1路</option>`;
break;
case 3:
//小班课
for(let i = 1;i<7;i++){
option += `<option value="${i}">${i}路</option>`;
}
break;
default:
return;
}
maxAudio.append(option);
maxVideo.append(option);
loger.log('meetingType',meetingType)
let dateList = {
"beginTime":createClassStartTime+' '+meeting_starthour+':'+meeting_startminute,
"endTime":createClassEndTime+' '+meeting_endhour+':'+meeting_endminute
}
$.extend(this.classDateList,dateList);
$('#scheduleForm2').hide();
$('#scheduleForm3').show();
}
_createClassUpTwoHandler(){
$('#scheduleForm2').show();
$('#scheduleForm3').hide();
$('#classConfig_details').hide();
}
_createClassSubmit3Handler(){
let chatInterval = $('#chatInterval').val();
let aheadTime = $('#aheadTime').val();
let maxVideoChannels = $('#maxAudio').val();
let max_audioChannels = $('#maxVideo').val();
let video_quality = $("input[name='videoQuality']:checked").val();//视频画质
let dateList = {
"chatInterval":chatInterval,
"aheadTime":aheadTime,
"maxVideoChannels":maxVideoChannels,
"max_audioChannels":max_audioChannels,
"video_quality":video_quality,
}
$.extend(this.classDateList,dateList);
//发送创建新课堂
this.detailClass();
$('#createClassBox').hide();
$('#scheduleForm3').hide();
//清空创建信息界面
this._closeCreateClass();
}
//打开更多参数
_openParamBtnHandler(){
let classConfig_details = $('#classConfig_details');
let createClassLegendImg = $('#createClassLegendImg');
if(classConfig_details.is(':hidden')){
classConfig_details.show();
createClassLegendImg.attr('src','images/icon-t.png');
}else{
classConfig_details.hide();
createClassLegendImg.attr('src','images/icon-.png');
}
}
detailClass(){
let dateList = this.classDateList;
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/createMeeting';
let userName = window.localStorage.getItem('loginName');
let userType = window.localStorage.getItem('userType');
dateList.siteId = 'networkschool';
dateList.userId = '123';
dateList.userName = userName;
dateList.userType = userType;
let that = this;
$.ajax({
type : "POST",
url : _url,
data : dateList,
timeout:5000,
headers: {'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
success:function(_data){
//获取课堂数据
if(_data && _data.code == 0){
loger.log('创建课堂成功',_data)
that._enterClass(_data.returnData.data);
}
},
error:function(error){
console.log(error,'失败')
}
})
}
_enterClass(_data){
window.open(_data.meetingUrl);
this._emit(MessageTypes.ADD_CLASS);
}
//清空创建课堂数据
_closeCreateClass(){
$('#classThemeUserName').val('');
$('#classThemePassWord').val('');
$("input[name='allowPublic']").get(0).checked = true;
$("input[name='meetingType']").get(0).checked = true;
$("input[name='h5Module']").get(0).checked = true;
$('#partcKey').text('');
$('#meeting_content').val('');
this._showPresentTime();
$('#chatInterval').val('0');
$('#aheadTime').val('0');
}
_classHandlePortHandler(evt){
let id = $(evt.target).attr('data');
// window.open('/3m/attend.do?meetingNumber=' + id);
}
//设置当前时间 给输入框默认值
_setNewTime(){
let newDate = new Date();
let ysar = newDate.getFullYear();
let month = newDate.getMonth()+1;//月
let date = newDate.getDate();//日
month<10?'0'+month:month;
date<10?'0'+date:date;
let time = ysar+'-'+month+'-'+date;
$('#liveInfoCenterLiveStart').html(time);
$('#liveInfoCenterLiveEnd').html(time);
$('#createUserAbortTime').html(time);
}
//设置弹框位置
_setMarginTop(){
this._setMarginTopHandler($('#createUserAccount'));//创建用户选择身份
this._setMarginTopHandler($('#userLogin'));//登录
this._setMarginTopHandler($('#usersign'));//注册
this._setMarginTopHandler($('#warnHintBox'));//错误提示
this._setMarginTopHandler($('#removeHandler'));//删除
this._setMarginTopHandler($('#updateInputBox'));//修改信息输入框
this._setMarginTopHandler($('#teacherDetailReminders'));//预约成功弹框
this._setMarginTopHandler($('#createUser'));//注册老师账号
this._setMarginTopHandler($('#createClass'));//创建课堂
}
//设置弹框位置 方法
_setMarginTopHandler(_data){
let clienth = document.documentElement.clientHeight || document.body.clientHeight
_data.css('margin-top',(clienth - parseInt(_data.height()))/2)
}
_dateUI(){
//执行一个laydate实例
dateUI.render({
elem: '#liveInfoCenterLiveStart' //指定元素
});
//执行一个laydate实例
dateUI.render({
elem: '#liveInfoCenterLiveEnd' //指定元素
});
//执行一个laydate实例
dateUI.render({
elem: '#createClassStartTime' //指定元素
});
//执行一个laydate实例
dateUI.render({
elem: '#createClassEndTime' //指定元素
});
//执行一个laydate实例
dateUI.render({
elem: '#createUserAbortTime' //指定元素
});
}
}
export default CreateClassApe;