main.js
8.3 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
import $ from 'jquery';
import url from 'url';
import ClassDataProxy from "proxy/ClassDataProxy";
import localConfig from "local/localConfig";
import UIMagnifyApe from "ape/UIMagnifyApe";
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 CreateClassApe from 'ape/CreateClassApe';//创建课堂
import ListDetailsApe from 'ape/ListDetailsApe';//列表详情
import AdministratorApe from 'ape/AdministratorApe';//管理员
import MyCenterApe from 'ape/MyCenterApe';//个人中心
import SubscribeApe from 'ape/SubscribeApe';//预约
import MessageTypes from "MessageTypes";
import Loger from "Loger";
let loger = Loger.getLoger('networkSchool');
let _loginOrRegister;
let _lanclassApe;
let _liveClassApe;
let _homeApe;
let _teacherDetailApe;
let _createClassApe;
let _listDetailsApe;
let _administratorApe;
let _myCenterApe;
let _subscribeApe;
class Main {
constructor() {
this.clientVersion="v1.6.6.20170904";
loger.warn("clientVersion:"+this.clientVersion);
let locationProtocol= location.protocol;
if(locationProtocol=="https:"){
ClassDataProxy.locationProtocol="https://";
}else {
ClassDataProxy.locationProtocol="http://";
}
this.localStorage = window.localStorage;
//判断当前用户登录身份状态
this._localStorageState();
//获取国际化语言
this._localConfig();
//获取地址栏参数
this.getURLParams();
//课堂初始化和启动流程
this.init();
}
//获取地址栏参数
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 || "";
}
}
//将地址转化成一个对象
_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));
//互动课堂
_lanclassApe = new LanclassApe();
//互动课堂
_liveClassApe = new LiveClassApe();
//首页
_homeApe = new HomeApe();
_homeApe.on(MessageTypes.HOME_SKIP,this.homeSkip.bind(this));
//老师
_teacherDetailApe = new TeacherDetailApe();
//创建课堂
_createClassApe = new CreateClassApe();
//列表详情
_listDetailsApe = new ListDetailsApe();
//管理员
_administratorApe = new AdministratorApe();
//个人中心
_myCenterApe = new MyCenterApe();
//预约管理
_subscribeApe = new SubscribeApe();
}
//
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();
}else if(_data.userType == ClassDataProxy.USER_TYPE_2){
this._showAdministratorInfo();
_administratorApe.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();
}
}
}
//判断登录用户的状态
_localStorageState(){
let userType = window.localStorage.getItem('userType')||0;
let loginName = window.localStorage.getItem('loginName')|| '';
let id = window.localStorage.getItem('id')|| '';
ClassDataProxy.userType = parseInt(userType);
ClassDataProxy.loginName = loginName;
ClassDataProxy.id = id;
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('兼课')
break;
default:
loger.log('游客')
this._student();
break;
}
}
_showAdministratorInfo(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#header_list').hide();
$('#header_seek').hide();
$('#androidDownload').hide();
$('#classManagementBox').show();
}
_teacherHome(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#header_list').hide();
$('#header_seek').hide();
$('#androidDownload').hide();
$('#classManagementBox').hide();
$('#classifyListBox').hide();
$('#myCenterBox').show();
}
_student(){
$('#slideshow').show();
$('#defaultBox').show();
$('.curriculumBox').show();
$('#classifyListBox').hide();
$('#teacherDetailBox').hide();
$('#lanclassBox').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();