main.js
15.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
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
import $ from 'jquery';
import url from 'url';
import ClassDataProxy from "proxy/ClassDataProxy";
import localConfig from "local/localConfig";
import UIMagnifyApe from "ape/UIMagnifyApe";
import UIControlApe from "ape/UIControlApe";
import ErrorApe from 'ape/ErrorApe';
import Slideshow from 'ape/Slideshow';//图片轮播
import LoginOrRegister from 'ape/LoginOrRegister';//登录注册
import LanclassApe from 'ape/LanclassApe';//互动课堂
import LiveClassApe from 'ape/LiveClassApe';//直播课堂
import HomeApe from 'ape/HomeApe';//首页
import TeacherDetailApe from 'ape/TeacherDetailApe';//老师
import PartTimeTeachingApe from 'ape/PartTimeTeachingApe';//兼课
import ManagementHomePageApe from 'ape/ManagementHomePageApe';//管理员首页
import CreateClassApe from 'ape/CreateClassApe';//创建课堂
import CreateUserApe from 'ape/CreateUserApe';//创建用户界面
import CreateGradeApe from 'ape/CreateGradeApe';//创建班级界面
import AboutClassApe from 'ape/AboutClassApe';//约课界面
import ListDetailsApe from 'ape/ListDetailsApe';//列表详情
import AdministratorApe from 'ape/AdministratorApe';//管理员
import PlayRecordApe from 'ape/PlayRecordApe';//录制管理
import MyCenterApe from 'ape/MyCenterApe';//个人中心
import MyCenterStudentApe from 'ape/MyCenterStudentApe';//个人中心老师
import MyCenterTeacherApe from 'ape/MyCenterTeacherApe';//个人中心学生
import SubscribeApe from 'ape/SubscribeApe';//预约
import CollectApe from 'ape/CollectApe';//预约
import MessageTypes from "MessageTypes";
import Loger from "Loger";
let loger = Loger.getLoger('networkSchool');
let _loginOrRegister;
let _lanclassApe;
let _liveClassApe;
let _homeApe;
let _teacherDetailApe;
let _partTimeTeachingApe;
let _managementHomePageApe;
let _createClassApe;
let _createUserApe;
let _createGradeApe;
let _aboutClassApe;
let _listDetailsApe;
let _administratorApe;
let _playRecordApe;
let _myCenterApe;
let _myCenterStudentApe;
let _myCenterTeacherApe;
let _subscribeApe;
let _collectApe;
let _headSwitchTitleApe;
class Main {
constructor() {
this.clientVersion="v1.8.2.20170914";
loger.warn("clientVersion:"+this.clientVersion);
let locationProtocol= location.protocol;
if(locationProtocol=="https:"){
ClassDataProxy.locationProtocol="https://";
}else {
ClassDataProxy.locationProtocol="http://";
}
//获取国际化语言
this._localConfig();
//获取地址栏参数
this.getURLParams();
this.localStorage = window.localStorage;
//判断当前用户登录身份状态
this._localStorageState();
//课堂初始化和启动流程
this.init();
//默认显示管理员首页
this.switchClass(0);
}
//获取地址栏参数
getURLParams() {
let urlParams = this._parseUrlParams();
loger.log("urlParams", urlParams);
if (urlParams) {
ClassDataProxy.classId = parseInt(urlParams.classId) || 0;
let userName = urlParams.userName || "";
ClassDataProxy.userName = decodeURI(userName);
ClassDataProxy.userId = urlParams.userId || userName;
ClassDataProxy.userRole = urlParams.userRole || "normal";
ClassDataProxy.isRecordPlayBack = Boolean(urlParams.playRecord);
ClassDataProxy.autoLogin = urlParams.m || 0;
ClassDataProxy.maxMediaChannels=parseInt(urlParams.channels)||0;
ClassDataProxy.userRole = urlParams.userRole;
if(ClassDataProxy.userRole!=ClassDataProxy.USER_HOST&&ClassDataProxy.userRole!=ClassDataProxy.USER_INVISIBLE){
ClassDataProxy.userRole=ClassDataProxy.USER_NOTMAL;
}
//IP+PORT
let portal = urlParams.portalIP || "";
let port = urlParams.portalPort || "";
if (port) {
portal = portal + ":" + port;
}
ClassDataProxy.portal = portal || "";
ClassDataProxy.siteId = ClassDataProxy.userName;
}
}
//将地址转化成一个对象
_parseUrlParams() {
let url = encodeURI(location.search);
let thisParam = {};
let strs;
// 判断是否存在请求的参数
if (url.indexOf("?") != -1) {
let str = url.substr(1);
// 截取所有请求的参数,以数组方式保存
strs = str.split("&");
for (let i = 0; i < strs.length; i++) {
// 获取该参数名称,值。其中值以unescape()方法解码,有些参数会加密
thisParam[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
// 返回改参数列表对象
return thisParam;
}
//初始化界面
init() {
loger.log("init");
//显示图片大图
UIMagnifyApe.init($('#magnifyBox'));
//登录注册
_loginOrRegister = new LoginOrRegister();
_loginOrRegister.on(MessageTypes.LOGIN_OUT,this.loginOut.bind(this));
_loginOrRegister.on(MessageTypes.LOGIN_IN,this.loginIn.bind(this));
// _loginOrRegister.on(MessageTypes.LOGIN_MYCENTER,this.loginMycenter.bind(this));
//互动课堂
_lanclassApe = new LanclassApe();
//互动课堂
_liveClassApe = new LiveClassApe();
//首页
_homeApe = new HomeApe();
_homeApe.on(MessageTypes.HOME_SKIP,this.homeSkip.bind(this));
_homeApe.on(MessageTypes.SWITCH_HEADER,this.switchHeader.bind(this));
//老师
_teacherDetailApe = new TeacherDetailApe();
//兼课
_partTimeTeachingApe = new PartTimeTeachingApe();
//创建课堂
_managementHomePageApe = new ManagementHomePageApe();
//创建课堂
_createClassApe = new CreateClassApe();
_createClassApe.on(MessageTypes.ADD_CLASS,this.addClass.bind(this));
//创建用户老师
_createUserApe = new CreateUserApe();
//创建班级
_createGradeApe = new CreateGradeApe();
//创建约课
_aboutClassApe = new AboutClassApe();
//列表详情
_listDetailsApe = new ListDetailsApe();
//管理员
_administratorApe = new AdministratorApe();
_administratorApe.on(MessageTypes.SWITCH_CLASS,this.switchClass.bind(this));
//录制回放
_playRecordApe = new PlayRecordApe();
//个人中心
_myCenterApe = new MyCenterApe();
//预约管理
_subscribeApe = new SubscribeApe();
_subscribeApe.on(MessageTypes.ORDER_FINISH,this.orderFinish.bind(this));
//收藏
_collectApe = new CollectApe();
}
//
loginOut(_data){
//
if(_homeApe){
_homeApe.detailPage();
}
}
loginIn(_data){
loger.log('进入课堂时显示的type值---登录',_data.userType)
if(_data && _data.userType){
if(_data.userType == ClassDataProxy.USER_TYPE_1){
this._teacherHome();
_teacherDetailApe.detailPage();
_myCenterApe.isLocalStorage();
}else if(_data.userType == ClassDataProxy.USER_TYPE_2){
this._showAdministratorInfo();
_managementHomePageApe.detailPage();
}else if(_data.userType == ClassDataProxy.USER_TYPE_8){
_homeApe.detailPage();
}else if(_data.userType == ClassDataProxy.USER_TYPE_32){
}else{
}
}
}
homeSkip(_data) {
if (_data && _data.userType) {
if (_data.userType == ClassDataProxy.USER_TYPE_1) {
_teacherDetailApe.detailPage();
}
}
}
//个人中心
loginMycenter(){
loger.log('个人中心')
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_1){
loger.log('个人中心老师')
//个人中心老师
_myCenterTeacherApe = new MyCenterTeacherApe();
}else if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_8){
loger.log('个人中心学生')
//个人中心学生
_myCenterStudentApe = new MyCenterStudentApe();
}
}
switchClass(_data){
let ind = parseInt(_data);
loger.log('管理员列表',ind)
switch (ind){
case 0:
//首页
_managementHomePageApe.detailPage();
break;
case 1:
//创建课堂
_createClassApe._createClassBtnHandler();
break;
case 2:
//班级管理
_createGradeApe.userAdminHandler(1);
break;
case 3:
//用户管理
_createUserApe.userAdminHandler(1);
break;
case 4:
//约课管理
_aboutClassApe.userAdminHandler(1);
break;
case 5:
//录制管理
_playRecordApe.detailPage(1);
break;
case 6:
//站点配置
break;
case 7:
//统计报告
break;
case 8:
//个人设置
break;
}
}
switchHeader(_data){
let ind = parseInt(_data);
switch (ind){
case 0:
_homeApe.studentClick();
break;
case 1:
_liveClassApe.isLocalStorage();
break;
case 2:
_lanclassApe.isLocalStorage();
break;
case 3:
_teacherDetailApe.isLocalStorage();
break;
default:
return;
}
}
addClass(_data){
loger.log('创建课堂成功')
_managementHomePageApe.detailPage();
}
//预约成功重新渲染数据
orderFinish(){
_homeApe.homeAllDate();
}
//判断登录用户的状态
_localStorageState(){
let userType = window.localStorage.getItem('userType')||0;
let loginName = window.localStorage.getItem('loginName')|| '';
let id = window.localStorage.getItem('id')|| '';
let siteId = window.localStorage.getItem('siteId')|| 'markettest';
let userMobile = window.localStorage.getItem('userMobile')|| '';
let userEmail = window.localStorage.getItem('userEmail')|| '';
let monicker = window.localStorage.getItem('monicker')|| '';
let status = window.localStorage.getItem('status')|| '';
let token = window.localStorage.getItem('token')|| '';
ClassDataProxy.userType = parseInt(userType);
ClassDataProxy.loginName = loginName;
ClassDataProxy.id = id;
ClassDataProxy.siteId = siteId;
//个人信息
ClassDataProxy.userMobile = userMobile;
ClassDataProxy.userEmail = userEmail;
ClassDataProxy.monicker = monicker;
ClassDataProxy.status = status;
ClassDataProxy.token = token;
loger.log('进入课堂时显示的type值',ClassDataProxy.userType)
switch (parseInt(userType)){
case ClassDataProxy.USER_TYPE_1:
loger.log('老师')
this._teacherHome();
break;
case ClassDataProxy.USER_TYPE_2:
loger.log('管理员')
this._showAdministratorInfo();
break;
case ClassDataProxy.USER_TYPE_8:
loger.log('学生')
this._student();
break;
case ClassDataProxy.USER_TYPE_32:
loger.log('兼课')
this.partTimeTeaching();
break;
default:
loger.log('游客')
this._student();
break;
}
}
_showAdministratorInfo(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#header_list').hide();
$('#header_seek').hide();
$('#androidDownload').hide();
$('#classManagementBox').show();
$('#teacherDetailBox').hide();
$('#myCenterBox').hide();
$('#lanclassBox').hide();
$('#liveContentAllBox').hide();
$('#lanclassAllBox').hide();
$('#teacherIntroAllBox').hide();
$('#partTimeTeachingBox').hide();
$('#recordUl .recordLi').eq(0).addClass('recordLiCheck').siblings().removeClass('recordLiCheck');
$('.classManagementRight').eq(0).show().siblings().hide();
}
_teacherHome(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#header_list').hide();
$('#header_seek').hide();
$('#androidDownload').hide();
$('#classManagementBox').hide();
$('#partTimeTeachingBox').hide();
$('#myCenterBox').show();
$('.myCenterContentBox').eq(0).show().siblings().hide();
$('#teacherMyCerter').show();
$('#studentMyCerter').hide();
$('.recordLi2').eq(0).addClass('recordLiCheck').siblings().removeClass('recordLiCheck');
$('#teacherUI .recordLi').eq(2).hide();
$('#liveContentAllBox').hide();
$('#lanclassAllBox').hide();
$('#teacherIntroAllBox').hide();
}
_student(){
$('#slideshow').show();
$('#defaultBox').show();
$('.curriculumBox').show();
$('#liveContentAllBox').hide();
$('#lanclassAllBox').hide();
$('#teacherIntroAllBox').hide();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
$('#myCenterBox').hide();
$('#partTimeTeachingBox').hide();
$('.myCenterContentBox').eq(0).show().siblings().hide();
$('#teacherMyCerter').hide();
$('#studentMyCerter').show();
$('.recordLi2').eq(0).addClass('recordLiCheck').siblings().removeClass('recordLiCheck');
}
partTimeTeaching(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#header_list').hide();
$('#header_seek').hide();
$('#androidDownload').hide();
$('#classManagementBox').hide();
$('#classifyListBox').hide();
$('#myCenterBox').hide();
$('#partTimeTeachingBox').show();
$('#liveContentAllBox').hide();
$('#lanclassAllBox').hide();
$('#teacherIntroAllBox').hide();
}
//获取国际化语言
_localConfig() {
let language = navigator.language || navigator.browserLanguage;
language = language.toLocaleLowerCase();
// loger.log("language:", language);
if (language == "en-us" || language == "en-gb") {
language = "en-us";
ErrorApe.language = 'en_us';
} else {
language = "zh-cn";
}
// loger.log("language-use:", language);
ClassDataProxy.localConfig = localConfig[language];
if (!ClassDataProxy.localConfig) {
ClassDataProxy.localConfig = localConfig['zh-cn'];
}
}
}
module.exports = new Main();