HomeApe.js
5.8 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
//*
// 首页模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import DrawTool from "./DrawTool";
import LaserPen from "./LaserPen";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
const classifyList = `<div class="classifyList {_classifyListR}" id="{_id}">
<img class="curriculumListImg" src="{_msgImg}" alt="">
<p class="curriculumListTit">{_classroomTitle}</p>
<p class="curriculumListInfo">
<span class="curriculumListTime">{_schoolTime}</span>
<span class="curriculumListNum">{_subscribeNum}</span>
</p>
</div>`;
let loger = Loger.getLoger('PC-HomeApe');
class HomeApe extends Ape {
constructor() {
super();
this.classDateList = {};//课堂的所有数据
//判断列表在右侧时取消边距
this._judgeListPlace();
this.isLocalStorage();
this.addEvent();
this.init();
}
init() {
// this.subscribe();
$('#defaultBtn').on('click',this._lanclassBtnHandler.bind(this));
}
addEvent() {
}
isLocalStorage(){
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_0 || ClassDataProxy.userType == ClassDataProxy.USER_TYPE_8){
this.detailPage();
console.log('学生',111111111)
}
}
_judgeListPlace(){
let i;
let curriculumList = document.getElementsByClassName('curriculumList');
for(i=0;i<curriculumList.length;i++){
if((i%4) == 3){
$(curriculumList[i]).addClass('classifyListR');
}
}
}
_lanclassBtnHandler(evt){
$(evt.target).addClass('header_listMsgCheck').siblings().removeClass('header_listMsgCheck');
let userType = window.localStorage.getItem("userType");
if( userType== ClassDataProxy.USER_TYPE_8 || userType== ClassDataProxy.USER_TYPE_0){
this.studentClick();
}else if(userType== ClassDataProxy.USER_TYPE_1){
let userType = ClassDataProxy.userType;
this._emit(MessageTypes.HOME_SKIP,{userType:userType});
}
}
detailPage(){
let that = this;
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/getMeeting';
$.ajax({
type: "POST",
url: _url,
data:{siteId:'markettest'},
headers: {siteId:'markettest',
'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
success:function(_data){
// loger.log(_data,'成功')
//获取课堂数据
if(_data || _data.code == 200){
that._gainClassData(_data.returnData.data);
}
},
error:function(error){
console.log(error,'失败')
}
})
}
subscribe(){
let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/meeting/getMeeting';
$.ajax({
type: "GET",
url: _url,
data:{siteId:'markettest'},
headers: {siteId:'markettest',
'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
success:function(_data){
// loger.log(_data,'成功')
//获取课堂数据
if(_data || _data.code == 200){
that._gainClassData(_data.returnData.data);
}
},
error:function(error){
console.log(error,'失败')
}
})
}
studentClick(){
$('#slideshow').show();
$('#defaultBox').show();
$('#classifyListBox').hide();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
}
teacher(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('#classifyListBox').show();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
}
_gainClassData(_data){
let liveList = $('#liveList');
let lanclassList = $('#lanclassList');
let teacherIntro = $('#teacherIntro');
liveList.empty();
lanclassList.empty();
teacherIntro.empty();
if(_data){
let _dataList = _data.meetingInfo;
for(let i = 0;i<_dataList.length;i++){
if(i<8){
let j = (i%4)==3;
let _getTime = ClassDataProxy.getTimeDifference(_dataList[i].beginTime,_dataList[i].endTime)
let _classifyList = this._format(classifyList,{
_classifyListR : j?'classifyListR':'',
_id : _dataList[i].id,
_msgImg :'../images/u373.png',
_classroomTitle : _dataList[i].meetingName,
_schoolTime : _getTime,
_subscribeNum : _dataList[i].reservationNumber+'人已预约'
})
liveList.append(_classifyList);
lanclassList.append(_classifyList);
teacherIntro.append(_classifyList);
}
}
}
}
//工具类
_format(str, obj) {
return str.replace(/\{(\w+)\}/g, function (match, group, index) {
return obj[group];
});
};
}
export default HomeApe;