要显示太多修改。

为保证性能只显示 20 of 20+ 个文件。

... ... @@ -228,6 +228,7 @@ body{
height:540px;
overflow: hidden;
position: relative;
display: none;
}
.motionMapBox{
height:540px;
... ... @@ -272,6 +273,7 @@ body{
left:0;
right:0;
margin:0 auto;
min-height:600px;
}
/*首页*/
.box{
... ... @@ -280,11 +282,11 @@ body{
left:0;
right:0;
margin:0 auto;
min-height: 1000px;
}
.curriculumBox{
float: left;
width: 100%;
display: none;
}
.curriculumBox1{
margin-bottom:45px;
... ...
/*
*
* 音视频设置的消息类型
* */
class ActionType {
constructor() {
}
}
ActionType. CHANGE_CAMERA = "changeCamera";//
ActionType. CHANGE_MICROPHONE = "changeMicrophone";//
ActionType. CHANGE_RESOLUTION = "changeResolution";//
ActionType. CHANGE_SPEAKER_VOLUME = "changeSpeakerVolume";//
ActionType. CHANGE_MICROPHONE_GAIN = "changeMicrophoneGain";//
ActionType. CHANGE_MICROPHONE_CODE = "changeMicrophoneCode";
export default ActionType;
\ No newline at end of file
... ... @@ -4,9 +4,6 @@
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";
let loger = Loger.getLoger('PC-AdministratorApe');
... ... @@ -84,7 +81,6 @@ class AdministratorApe extends Ape {
isLocalStorage(){
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_2){
this.detailPage();
console.log('管理员',111111111)
}
}
//首页
... ...
//*
// 答题卡模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import ClassDataProxy from "proxy/ClassDataProxy";
import $ from "jquery";
let loger = Loger.getLoger('PC-AnswerApe');
const newAnswerInput = `<li class="themeTrendsLi">
<input type="text" class="themeVal" value="输入答案" maxlength="26">
<span>&times;</span>
</li>`;
const newAnswerP = `<li class="themeTrendsLi">
<p></p>
<span>&times;</span>
</li>`;
const newList = `<li class="resultValueList">
<input type="radio" name="result" value="{value}" data-val="{index}">{value}
</li>`;
const newResultList = `<li class="resultList">
<b>{ele}</b>
<span>{_ratio}%</span>
<p class="staticPlan"></p>
<p class="dynamicPlan dynamicPlan{index}"></p>
</li>`;
class AnswerApe extends Ape {
constructor () {
super();
this._questionObject = {};//问题 对象
this._isErrer = false;//自定义题目的时候用来判断是不是输入值
this._showPage = false;//判断当前页面是不是终止状态
this._maxLen = 6;//题目最大长度
this._minLen = 2;//input最小长度
this._minLen1 = 1;//其他题目最小长度
this._countNum = 0;//控制题目长度,默认为0
this._brevity = []
this.timerList = [0,30,60,120,180,300]; //选择答题倒计时
this.isCancel = false;//控制学生端是否显示
this.isHide = false;//控制老师端是否显示
this.addEvent();
this.init();
}
init() {
$('.slelctShow').on("click", this._slelctShowHandler.bind(this));//点击显示答题倒计时
$('.answer').on("click", this._answerHandler.bind(this));//点击弹出答题卡
$(".themeHeadline .iconfont").on("click", this._closeAnswerHandler.bind(this));//关闭答题卡/最小化
$('.themeUl').on("click",'li',this._answerLiHandler.bind(this));//选择答题计时时间
$('.themeList').on('mouseenter',this._mouseenterAnswer.bind(this));//移入题目项显示发布按钮
$('.themeList').on('mouseleave',this._mouseleaveAnswer.bind(this));//移出题目项移除发布按钮
$('.themeTrendsUl').on('mouseenter','li',this._mouseenterAddOff.bind(this));//移入每一条题目列表时显示关闭按钮
$('.themeTrendsUl').on('mouseleave','li',this._mouseleaveAddOff.bind(this));//移出每一条题目列表时移除关闭按钮
$('.themeTrendsUl').on('focus','.themeVal',this._answerFocus.bind(this));//input框获得焦点隐藏默认字体
$('.themeTrendsUl').on('blur','.themeVal',this._answerBlur.bind(this));//input框失去焦点显示默认字体
$('.themeTrendsUl').on('click','span',this._answerListRemove.bind(this));//点击X删除列表项
$('.themeAdd').on('click',this._answerAdd.bind(this));//点击列表后添加按钮 来添加列表项
$('.dynamicRight').on('click',this._answerSubmit.bind(this));//点击发布提交信息
$('.inputErrerA').on('click',this._inputErrerClone.bind(this));//关闭input自定义题目为空时弹出框
$('.resultConceal').on('click',this._resultConcealClone.bind(this));//隐藏按钮
$('.resultHeadline .iconfont').on('click',this._resultConcealClone.bind(this));//答题卡结果关闭按钮
$('.resultTermination').on('click',this._resultTermination.bind(this));//终止答题卡
$('.referBtn').on('click',this._referBtnClone.bind(this));//学生端提交信息
$('.abandonBtn').on('click',this._abandonBtnClone.bind(this));//学生端放弃提交信息
//老师端结果 移入显示当前选项选择人数
$('.resultListUl').on('mouseenter','p',this._mouseenterResult.bind(this));
$('.resultListUl').on('mouseleave','p',this._mouseleaveResult.bind(this));
$('body').on('click',function(evt){
$('.layerBox').hide();
if(!$(evt.target).is('.themeShow')){
$('.themeUl').hide();
}
});
//渲染题目列表显示数据
this._renderDom();
//刷新列表时input框重新改为默认值
this._setDefault();
}
addEvent() {
//更新显示答题结果
xdysdk.on('update_answer_question',this.upDateAnswerQuestion.bind(this));
//答题结束
xdysdk.on('stop_answer_question',this.stopAnswerQuestion.bind(this));
//收到答题消息
xdysdk.on('start_answer_question',this.startAnswerQuestion.bind(this));
//点名和答题卡的计时器
xdysdk.on("update_question_time",this.updateQuestionTime.bind(this));
}
timerCounterUptate(timestamp){
$('#answerCountDown').html(this._newTime(timestamp));
}
_newTime(timestamp){
let minute = 0,
second = 0;
minute = Math.floor(timestamp / 60)<10 ? '0'+Math.floor(timestamp / 60):Math.floor(timestamp / 60);
second = Math.floor(timestamp - minute * 60)<10?'0'+Math.floor(timestamp - minute * 60):Math.floor(timestamp - minute * 60)
let timeValue = ClassDataProxy.localConfig.answerCountdown
timeValue +=( minute > 0 ) ? minute + ' : ' : '00 : '
timeValue += (second > 0 ) ? second : '00'
return timeValue;
}
//事件监听-----------
//更新显示答题结果
upDateAnswerQuestion(_data){
if(_data.type!=100 && ClassDataProxy.userRole==ClassDataProxy.USER_HOST){
this._questionObject = _data;
this._showPage = true;
loger.log('更新显示答题结果');
if(!this.isHide){
this._showResultBox();
}
this._resultDom(_data);
}
}
//答题结束
stopAnswerQuestion(_data){
if(_data.type!=100){
loger.log('答题结束',_data);
this._questionObject = null;
this._hideAnswerStudentBox();
this._hideResultBox();
this._showPage = false;
this.isCancel = false;
this.isHide = false;
}
}
//收到答题消息
startAnswerQuestion(_data){
if(_data.type!=100){
if(ClassDataProxy.userRole==ClassDataProxy.USER_NOTMAL){
this._questionObject = _data;
loger.log('收到答题消息',_data)
if(_data.timeLimit == 100000){
$('.countdown').css('opacity',0);
}else{
$('.countdown').css('opacity',1);
}
if(!this.isCancel){
this._showAnswerStudentBox();
}
this._answerStudent(_data);
}
}
}
//答题卡的计时器
updateQuestionTime(_data){
if(_data.type!=100){
//loger.log('答题卡的计时器',_data)
this.timerCounterUptate(_data.timestamp);
}
}
_setDefault(){
$('.themeTrendsUl .themeVal').val(ClassDataProxy.localConfig.inputAnswer);
}
_renderDom(){
let renderArray = ['A','B','C','D','E','F'];
let themeTrendsUlA = $('#themeTrendsUlA li p');
let themeTrendsUlB = $('#themeTrendsUlB li p');
let themeTrendsUlC = $('#themeTrendsUlC li input');
$.each(themeTrendsUlA,function(index,ele){
$(ele).text(renderArray[index])
})
$.each(themeTrendsUlB,function(index,ele){
$(ele).text(index+1)
})
}
// 渲染答题结果
_resultDom(_data){
if(_data){
//清除原数据 重新渲染老师端答题结果列表
$('.resultListUl').html('');
let list = _data.totalUser;
let _newResultList = '';
let _this = this;
$('.attendNum').text(list)
let _ratio = 0;
$.each(_data.options,function(index,ele){
_ratio = _data.answers[index].percent;
_newResultList = _this._format(newResultList, {
ele : ele,
_ratio :_ratio,
index : index
});
$('.resultListUl').append(_newResultList);
$('.resultListUl').find('.dynamicPlan'+index).css('width',_ratio+'%');
})
}
}
//点击弹出答题卡
_answerHandler(){
//弹出答题卡时 渲染倒计时列表
this._showTimerList();
//显示时间格式
$('.themeShow').html($('.themeUl').find('li').eq(0).html()) //默认答题计时显示第一个
.attr('data-val',$('.themeUl li').eq(0).attr('data-val'));
this._showAnswerAllBox();
if(!this._showPage){
$(".themeBox").fadeIn(800);
}else{
$('.resultBox').fadeIn(800);
}
}
//关闭答题卡/最小化
_closeAnswerHandler() {
this.isHide = true;
this._hideAnswerAllBox();
}
//点击显示答题倒计时
_slelctShowHandler() {
$('.themeUl').is(':hidden') ? $('.themeUl').show() : $('.themeUl').hide();
}
//选择答题计时时间
_answerLiHandler(evt){
let ele = $(evt.target);
let index = ele.index();
//选择倒计时时 添加类
this._judgeDddClass($('.themeUl li'),index)
$('.themeShow').html(ele.html())
.attr('data-val',ele.data('val'));
$('.themeUl').hide();
}
//选择倒计时时 添加类
_judgeDddClass(ele,ind){
ele.eq(ind).addClass('active').siblings().removeClass('active');
}
//移入题目项显示发布按钮
_mouseenterAnswer(evt){
$(evt.target).find('.dynamicRight').show();
/* if($('#themeTrendsUlC .themeTrendsLi').length >= 6){
$('#themeAdd').hide();
}*/
}
//移出题目项移除发布按钮
_mouseleaveAnswer(evt){
$('.dynamicRight').hide();
}
//移入每一条题目列表时显示关闭按钮
_mouseenterAddOff(evt){
$(evt.target).next().show();
}
//移出每一条题目列表时移除关闭按钮
_mouseleaveAddOff(){
$('.themeList span').hide();
}
//input框获得焦点隐藏默认字体
_answerFocus(evt){
let price = $(evt.target);
if(price.val() === ClassDataProxy.localConfig.inputAnswer) price.val('');
}
//input框失去焦点显示默认字体
_answerBlur(evt){
let price = $(evt.target);
if(price.val() === '') price.val(ClassDataProxy.localConfig.inputAnswer);
}
//点击发布提交信息
_answerSubmit(evt){
let _themeLi = $(evt.target).prev().children();
let _themeP = _themeLi.find('p');
let _themeInput = _themeLi.find('input');
let _parentType = $(evt.target).parent().data('type');
let _this = this;
let array =[];
$.each(_themeP,function(key,val){
let text = $(val).text();
array.push(text);
})
let length = [];
$.each(_themeInput,function(key,val){
let text = $(val).val();
let parten = /(^\s*)|(\s*$)/g ;
if(text=== ClassDataProxy.localConfig.inputAnswer || text.replace(parten,'') == ''){
length.push(text)
_this._isErrer = true;
_this._inputErrerOpen();
}else{
array.push(text);
}
})
if(length.length > 0){
this._inputErrerOpen();
}else{
this._resultBounced();
let _timeLimit = parseInt( $('.themeShow').attr('data-val') );
let paramInfo = {};
paramInfo.type = parseInt(_parentType) || 1;; //1单选,2多选,3判断,4点名
paramInfo.content = '答题'; //题目 没有就传""
paramInfo.timeLimit = _timeLimit;//有效时间(秒)
paramInfo.correct = [];//正确答案,没有就传[]
paramInfo.options = array || [] ;//选项数组,没有就传[]
paramInfo.answer = [];//学生选择的答案,没有就传[]
xdysdk.api("creatQuestion",paramInfo);
}
}
_resultBounced(){
this._showPage = true;
$('.themeBox').hide();
$('.resultBox').show();
}
//答题题目为自定义时需输入内容否则弹出错误弹框
_inputErrerOpen(){
if(this._isErrer){
$(".inputErrerBox").show();
}
}
//错误弹框关闭
_inputErrerClone(){
$(".inputErrerBox").hide();
}
_inputAdd(_answerLi,Dom){
this._countNum ++;
_answerLi.before(newAnswerInput);
$('.themeTrendsLi').attr('value',ClassDataProxy.localConfig.inputAnswer)
// this._setDefault();
if(this._countNum === this._maxLen){
this._countNum = 6;
Dom.hide();
}
}
_textAdd(_answerLi,Dom){
this._countNum ++;
_answerLi.before(newAnswerP);
this._renderDom();
if(this._countNum === this._maxLen){
this._countNum = 6;
Dom.hide();
}
}
_inputDomPos(){
let themeTrendsLi = $('#themeTrendsUlC').children('.themeTrendsLi');
let liList = $('#themeTrendsUlC li');
let len = themeTrendsLi.length;
let _dynamicRight1 = $('.dynamicRight1');
if(len > 3){
_dynamicRight1.css('top','33px');
}else{
_dynamicRight1.css('top','12px');
}
}
_answerAdd(evt){
let themeTrendsUlA = $('#themeTrendsUlA');
let themeTrendsUlB = $('#themeTrendsUlB');
let themeTrendsUlC = $('#themeTrendsUlC');
let _isInput = $(evt.target).prev().children().is('input');
let _isText = $(evt.target).parent().children().first().text();
let _themeLi = $(evt.target);
let _len = $(evt.target).parent().children('.themeTrendsLi').length;
let _inputLen = $(evt.target).siblings().length;
this._countNum = _inputLen;
if(themeTrendsUlC && _isInput){
this._inputAdd(_themeLi,$(evt.target));
}else if((themeTrendsUlA || themeTrendsUlB ) && ( _isText === 'A×' || _isText === '1×' )){
this._textAdd(_themeLi,$(evt.target));
}
this._inputDomPos();
}
_removeList(_countNum,len,ele){
if(_countNum === len){
_countNum = len;
}else{
_countNum --;
ele.remove();
this._renderDom();
}
}
//点击X删除列表项
_answerListRemove(evt){
let _plus = $(evt.target).parents('ul').children().find('.themeAdd').is(':hidden');
let _isP = $(evt.target).prev().is('p');
let _inputLen = $(evt.target).parent().siblings().length;
let _themeAdd = $(evt.target).parents('ul').children('.themeAdd');
if(_themeAdd.is(":hidden")){
_themeAdd.show();
}
this._countNum = _inputLen;
let parentDom = $(evt.target).parent();
if(_isP){
this._removeList(this._countNum,this._minLen,parentDom);
}else{
this._removeList(this._countNum,this._minLen1,parentDom);
}
this._inputDomPos();
}
//答题卡结果关闭按钮
_resultConcealClone(){
this.isHide = true;
$('.resultBox').hide();
$('.answerAllBox').hide();
}
//终止答题卡
_resultTermination(){
//清除所有数据 还原默认数据
this._clearAnswer();
//终止时隐藏所有盒子
this._hideResultBox();
//调用SDK停止答题
this._stopAnswer();
}
//清除所有数据 还原默认数据
_clearAnswer(){
this._showPage = false;
$('#minute,#second').text('00');
//答题卡结果关闭按钮
this._resultConcealClone();
//终止答题卡时题目列表默认显示原数据
this._revocation();
//终止答题卡时input框的默认值显示原数据
this._setDefault();
//默认 无 默认选中
this._judgeDddClass($('.themeUl li'),0);
this.isCancel = false;
this.isHide = false;
//input框重置
$('.dynamicRight1').css('top','12px');
$('#themeAdd').show();
$('.dynamicPlan').css('width',0)
$('.resultList span').html('0%');
$('.resultList').empty();
$('.attendNum').text('0')
}
_stopAnswer(){
let paramInfo = {};
paramInfo.itemIdx = this._questionObject.itemIdx;
paramInfo.questionId = this._questionObject.questionId;
xdysdk.api("stopQuestion",paramInfo);
this._questionObject = null;
}
_revocation(){
$('.themeShow').html(ClassDataProxy.localConfig.nothing);
let themeTrendsUlA = $('#themeTrendsUlA .themeTrendsLi').length;
let themeTrendsUlB = $('#themeTrendsUlB .themeTrendsLi').length;
let themeTrendsUlC = $('#themeTrendsUlC .themeTrendsLi').length;
let len,len1,len2;
this._recoverfunc(themeTrendsUlC,len,'C',3);
this._recoverfunc(themeTrendsUlB,len2,'B',4);
this._recoverfunc(themeTrendsUlA,len1,'A',4);
}
_recoverfunc(ele,len,val,count){
if( ele < count){
len = count - ele;
this._addfunc(val,len);
}else{
len = ele - count;
this._removefunc(val,len);
}
}
_addfunc(ele,len){
for(let i = 0;i<len;i++){
$('#themeTrendsUl'+ele).prepend($('#themeTrendsUl'+ele).children().first().clone(true));
}
this._renderDom();
}
_removefunc(ele,len){
for(let i = 0; i< len;i++){
$('#themeTrendsUl'+ele).children().first().remove();
}
this._renderDom();
}
_answerStudent(_data){
this._answerStudentShow();
let resultValueUl = $('.resultValueUl');
//清除原数据 重新渲染学生端列表
resultValueUl.html('');
let array = _data.options;
let _newList = '';
let _this = this;
$.each(array,function(index,value){
_newList += _this._format(newList, {
value: value,
index:index
});
})
resultValueUl.append(_newList)
let len = resultValueUl.find('li').length;
$('.resultValueList').width(100/len+'%');
}
_answerStudentShow(){
$('.answerStudentBox').show();
}
//学生端提交信息
_referBtnClone(){
let _val = $('.resultValueList input:checked').attr('data-val');
if(_val){
let paramInfo = {};
paramInfo.itemIdx = this._questionObject.itemIdx;
paramInfo.questionId = this._questionObject.questionId;
paramInfo.answer = [];//答题当前单选 存取的值是答题的索引
paramInfo.answer.push(parseInt(_val));
xdysdk.api("sendAnswer",paramInfo);
loger.log('学生端提交信息',paramInfo)
this._abandonBtnClone();
}
return;
}
//老师端结果 移入显示当前选项选择人数
_mouseenterResult(evt){
let array = this._questionObject;
let _text = $(evt.target).siblings('b').text();
let layerBox = $('.layerBox');
let _resultContentx = $('.resultContent').offset().left;
let _resultContenty = $('.resultContent').offset().top;
let _x = evt.pageX - _resultContentx;
let _y = evt.pageY - _resultContenty - layerBox.outerHeight();
let _span = '';
layerBox.show()
.css({'left':_x,'top':_y})
.html('');
let ind = $(evt.target).parent().index()
let nameList = array.answers[ind].userNames.toString();
let reg = /\,/g;
if( nameList && nameList.length > 0){
nameList = nameList.replace(reg,'、');
_span = '<span>'+ nameList +'</span>';
}
if(_span){
layerBox.html(_span)
}else{
layerBox.hide();
}
}
_mouseleaveResult(){
$('.layerBox').hide();
}
//学生端放弃提交信息
_abandonBtnClone(){
this.isCancel = true;
this._hideAnswerStudentBox();
$('.themeAdd').show();
$('.resultValueList').remove();
}
//渲染时间列表
_showTimerList(){
let themeUl = $('.themeUl'),newLi;
themeUl.html('');
$.each(this.timerList,function(key,val){
if(val == 0){
newLi = '<li data-val="100000" data-ind="'+key+'" class="active">'+ClassDataProxy.localConfig.nothing+'</li>';
}else if(val/60 < 1){
newLi = '<li data-val="'+val+'" data-ind="'+key+'">'+val+ClassDataProxy.localConfig.second+'</li>';
}else{
newLi = '<li data-val="'+val+'" data-ind="'+key+'">'+val/60+ClassDataProxy.localConfig.minute+'</li>';
}
themeUl.append(newLi);
})
}
//工具类
_format(str, obj) {
return str.replace(/\{(\w+)\}/g, function (match, group, index) {
return obj[group];
});
};
//隐藏答题卡弹框
_showAnswerAllBox(){
$('.answerAllBox').show();
}
//隐藏答题卡弹框
_hideAnswerAllBox(){
$('.answerAllBox').hide();
}
//显示答题卡结果弹出框
_showResultBox(){
$('.answerAllBox').show();
$('.resultBox').show();
$('.themeBox').hide();
}
//终止答题卡
_hideResultBox(){
$('.answerAllBox').hide();
$('.themeBox').hide();
$('.resultBox').hide();
$('.answerStudentBox').hide();
}
//显示学生界面弹出框
_showAnswerStudentBox(){
$('.answerAllBox').show();
$('.themeBox').hide();
$('.answerStudentBox').show();
}
//隐藏学生界面弹出框
_hideAnswerStudentBox(){
$('.answerAllBox').hide();
$('.answerStudentBox').hide();
}
}
export default AnswerApe;
\ No newline at end of file
//*
// 聊天模块
// */
import Ape from "./Ape";
import Loger from "../Loger";
import xdysdk from "libs/xdysdk";
import $ from "jquery";
import ChatFace from "./ChatFace";
import UserList from "./UserList";
import ChatImg from "./ChatImg";
import UIMagnifyApe from "ape/UIMagnifyApe";
import ClassDataProxy from "proxy/ClassDataProxy";
let loger = Loger.getLoger('PC-Chat');
let classCurInfo;
// 消息模板-老师
const tpl_message_teacher = `<div class="message_client">
<div class="teaNameBox" >
<span class="teaName">{name}</span>
</div>
<div style="margin-left: 20px">
<div class="message triangle-isosceles leftmsg">{message}</div>
</div>
</div>`;
// 消息模板-学生
const tpl_message_student = `<div class="message_client">
<div class="stuNameBox">
<span class="stuName">{name}</span>
</div>
<div style="margin-right: 15px">
<div class="message stutriangle-isosceles rightmsg">{message}</div>
</div>
</div>`;
class Chat extends Ape {
constructor() {
super();
this.chatFace;
this.userList;
this.addEvent();
this.init();
}
init() {
this.chatFace = new ChatFace();
this.userList = new UserList();
this.chatImg = new ChatImg();
this.chatImg.callback=this._sendImgMessageHandler.bind(this);
this.userList.on(UserList.WINDOW_VIEW_CHANGE, this.onWindowViewChange.bind(this));
//布局
// $("#txt_message")[0].value = ''
//UI按钮点击事件
$("#btn_send").on("click", this._sendMessageHandler.bind(this));
//回车键发送聊天消息
let that = this;
/* $("#txt_message").on("keydown", function (e) {
let curKey = e.which;
if (ClassDataProxy.isKeypress) {
if (curKey == 13) that._sendMessageHandler();
}
});*/
$('.left').on('contextmenu', this._preventDefault.bind(this));
$('.header').on('contextmenu', this._preventDefault.bind(this));
//$('.videoWindow').on('contextmenu', this._preventDefault.bind(this));
$('.middle').on('contextmenu', this._preventDefault.bind(this));
$('.tabTitle').on('contextmenu', this._preventDefault.bind(this));
// $('.input-send').on('contextmenu',this._preventDefault.bind(this));
$('.transmitBox').on('contextmenu', this._preventDefault.bind(this));
$('.fold').on('contextmenu', this._preventDefault.bind(this));
$('.rightGap').on('contextmenu', this._preventDefault.bind(this));
$('.leftGap').on('contextmenu', this._preventDefault.bind(this));
$('.curClassUserList').on('contextmenu', this._preventDefault.bind(this));
/* $("#txt_message").on('focus', function () {
that._sendImgMessageHandler();
})*/
}
onWindowViewChange() {
this._emit(UserList.WINDOW_VIEW_CHANGE);
}
addEvent() {
xdysdk.on("chat_receive_message", this._chatReceiveHandler.bind(this));//// 聊天消息处理
xdysdk.on("class_join_success", this._classJoinSuccess); //监听加入课堂成功
}
clear() {
$("#panel_message").empty();
}
_preventDefault(evt) {
evt.preventDefault();
}
_classJoinSuccess(callBackData) {
classCurInfo = callBackData;
}
_chatReceiveHandler(_data) {
//自己发的消息不需要再次显示,因为自己发送的时候已经直接显示了
if (_data && _data.fromNodeId == ClassDataProxy.nodeId) {
loger.log("自己发送的聊天消息不需要再显示", _data);
return;
}
loger.log("显示聊天消息", _data);
this._showChatMessage(_data);
}
//显示内容
_showChatMessage(_data) {
if (!_data) {
loger.warn("聊天信息无效->", _data);
return;
}
loger.log('上传图片成功是显示图片', _data)
let str = _data.message;
//msgType为1的时候是图片,其他的按文本消息处理
if(_data.msgType==1){
this.showChatImg(_data);
}else {
this.showChatMessage(_data);
}
/* let index = str .lastIndexOf(".");
str = str .substring(index + 1, str.length);
let msgValue =str ;
if(msgValue=="jpg"||msgValue=="png"||msgValue=="gif"||msgValue=="jpeg"||msgValue=="bmp"){
this.showChatImg(_data);
}
else{
this.showChatMessage(_data);
}*/
}
showChatImg(_data) {
let tpl = _data.fromNodeId !== classCurInfo.nodeId ? tpl_message_teacher : tpl_message_student;
let message = '<img class="chatImg" src=' + _data.message + '>';
let strHTML = this._format(tpl, {
name: _data.fromName,
message: message
});
$("#panel_message").append(strHTML);
$("#panel_message")[0].scrollTop = $("#panel_message")[0].scrollHeight;
$(".chatImg").on('load', this._onLoadImage.bind(this));
$(".chatImg").on("click", this._expandChatImg.bind(this)); //放大截图
}
showChatMessage(_data) {
let tpl = _data.fromNodeId !== classCurInfo.nodeId ? tpl_message_teacher : tpl_message_student;
let message = (_data.message + "").replace(/\[img:([^\[:\]]*)\]/ig, function (match, group, index) {
return '<img src="images/face/' + group + '.png"/>';
});
let strHTML = this._format(tpl, {
name: _data.fromName,
message: message
});
$("#panel_message").append(strHTML);
$("#panel_message")[0].scrollTop = $("#panel_message")[0].scrollHeight;
}
_onLoadImage(){
$("#panel_message")[0].scrollTop = $("#panel_message")[0].scrollHeight;
}
//MouseEvent
_expandChatImg(evt) {
UIMagnifyApe.show(evt.target.currentSrc);
}
_sendMessageHandler() {
let msg = $("#txt_message")[0].value;
if (msg) {
let parten = /^\s*$/;
if (parten.test(msg)) {
loger.log("全是空格");
} else {
let msgType=0;////0是文本,1是图片
xdysdk.api("sendChatMsg", {msgType: msgType, "message": msg, "to": 0});
$("#txt_message")[0].value = "";
//自己的直接显示
let chatData = {};
chatData.fromNodeId = ClassDataProxy.nodeId;
chatData.toNodeId = 0;
chatData.msgType=msgType;
chatData.message = msg;
chatData.fromName = ClassDataProxy.userName;
chatData.fromRole = ClassDataProxy.userRole;
this._showChatMessage(chatData);
}
} else {
loger.log("发送消息内容不能为空");
}
$("#txt_message").focus();
}
//图片上传完成后就发送
_sendImgMessageHandler(_data) {
if(!_data){
return;
}
let msg =_data.fileName||"";
if (msg) {
let parten = /^\s*$/;
if (parten.test(msg)) {
loger.log("全是空格");
} else {
//let arr=msg.split('.');
//let len=arr.length;
//let msgValue =arr[len-1];
let index=msg.lastIndexOf(".");
let msgValue=msg.substr(index+1);
if(msgValue){
msgValue = msgValue.toLowerCase();
}
if (msgValue == "jpg" || msgValue == "png" || msgValue == "gif" || msgValue == "jpeg" || msgValue == "bmp") {
let msgType=1;////0是文本,1是图片
let url= _data.url||"";
xdysdk.api("sendChatMsg", {msgType: msgType, "message":url, "to": 0});
//$("#txt_message")[0].value = "";
let chatData = {};
chatData.fromNodeId = ClassDataProxy.nodeId;
chatData.toNodeId = 0;
chatData.msgType=msgType;
chatData.message = url;
chatData.fromName = ClassDataProxy.userName;
chatData.fromRole = ClassDataProxy.userRole;
this._showChatMessage(chatData);
}
}
} else {
loger.log("发送消息内容不能为空");
}
//$("#txt_message")[0].value == '';
}
//工具类
_format(str, obj) {
return str.replace(/\{(\w+)\}/g, function (match, group, index) {
return obj[group];
});
};
}
export default Chat;
//*
// 聊天表情 和选项卡
// */
import Emiter from "Emiter";
import Loger from "Loger";
import $ from "jquery";
let loger = Loger.getLoger('PC-ChatFace');
let step = 0, count = 4;
let $inner = $("#inner-slide"), $tip = $("#tiplist"), $tipList = $tip.children("li");
class ChatFace extends Emiter {
constructor() {
super();
this.addEvent();
this.init();
}
init() {
let that = this;
//布局
$(".face").on("click", that._showHide.bind(this));
$(".swiper-slide").on("click", "li", function (e) {
$("#txt_message").val($("#txt_message").val() + "[img:" + $(this).find("img").attr("data-type") + "]");
const faceList = document.getElementById("facelist");
faceList.style.display = "none";
});
//UI按钮点击事件
$tipList.bind("click", function () {
step = $(this).index();
$inner.stop().animate({left: -step * 320}, 500);
that._changeTip();
});
//选项卡s
this._changeTab();
//文字区域点击后表情消失
/* $("#txt_message").on("focus",that._hideFace.bind(this));
$("#panel_message").on("click",that._hideFace.bind(this));
$(".middle").on("click",that._hideFace.bind(this));
$(".left").on("click",that._hideFace.bind(this));
$(".header").on("click",that._hideFace.bind(this));
$(".videoWindow").on("click",that._hideFace.bind(this));
$(".userListTitle").on("click",that._hideFace.bind(this));*/
}
addEvent() {
}
_showHide() {
let faceList = document.getElementById("facelist");
this._showHideFace(faceList);
}
_showHideFace(obj) {
if (obj.style.display == "none") {
obj.style.display = 'block';
} else {
obj.style.display = 'none';
}
}
_hideFace(){
let faceList = document.getElementById("facelist");
if (faceList.style.display == "block") {
faceList.style.display = 'none';
}
}
_faceSelected() {
$("#txt_message").val($("#txt_message").val() + "[img:" + $(this).find("img").attr("data-type") + "]");
let faceList = document.getElementById("facelist");
faceList.style.display = "none";
}
_changeTip() {
let that = this;
let temp = step;
temp >= count ? temp = 0 : null;
$tipList.each(function (index, item) {
index === temp ? $(this).addClass("bg") : $(this).removeClass("bg");
});
}
_changeTab() {
$(document).ready(function () {
$(".tabTitle li").click(function () {
$(".tabTitle li").eq($(this).index()).addClass("select").siblings().removeClass("select");
$(".tabCon").hide().eq($(this).index()).show();
});
$(".userListTitle").click(function () {
$(".userListTitle").css("borderBottom", "1px solid #3498db");
$(".discussTitle").css("borderBottom", "1px solid #666");
});
$(".discussTitle").click(function () {
$(".userListTitle").css("borderBottom", "1px solid #666");
$(".discussTitle").css("borderBottom", "1px solid #3498db");
$("#panel_message")[0].scrollTop=$("#panel_message")[0].scrollHeight;
})
})
}
}
ChatFace.prototype.CHAT_FACE_CHANGE = ChatFace.CHAT_FACE_CHANGE = "chat_face_change";
export default ChatFace;
\ No newline at end of file
//*
// 聊天上传图片
// */
import Emiter from "Emiter";
import Loger from "Loger";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import UIControlApe from './UIControlApe';
import ErrorApe from './ErrorApe';
import MD5 from "md5";
let loger = Loger.getLoger('PC-ChatImg');
let fileItem;
class ChatImg extends Emiter {
constructor() {
super();
this.callback=null;
this.init();
}
init(){
$("#fileImgInput").on("change", this._uploadFile.bind(this));//上传截图
}
_uploadFile(evt){
fileItem=document.getElementById('fileImgInput').files[0];
if(!fileItem){
loger.log("没有选择文件");
return;
}
// this._closeDocListHandler();
let fileStr=fileItem.name;
let fileValue=fileStr.split('.')[1];
loger.log("文件名:" + fileItem.name + "->文件类型:" + fileItem.type);
//目前最大支持50M 格式为jpg png pdf docx pptx xlsx
let fileName=fileItem.name.toLowerCase();
//判断选择的文件类型
if(fileName.lastIndexOf('.jpg')<0&&
fileName.lastIndexOf('.jpeg')<0&&
fileName.lastIndexOf('.png')<0&&
fileName.lastIndexOf('.gif')<0&&
fileName.lastIndexOf('.bmp')<0){
ErrorApe.showError(ErrorApe.TYPE_3,ClassDataProxy.localConfig.layoutImg);
return;
}
//判断文件的大小
if(fileItem.size>(5*1024*1024)){
ErrorApe.showError(ErrorApe.TYPE_3,ClassDataProxy.localConfig.chatError);
return;
}
if(!ClassDataProxy.DOCServerIP){
loger.warn("截图服务器地址无效,无法上传文件!");
ErrorApe.showError(ErrorApe.TYPE_3,ClassDataProxy.localConfig.serverError);
return
}
UIControlApe.disEnabledDocBar();
UIControlApe.disEnabledMediaBar();
//UIControlApe.disEnabledLeftBar();
//UIControlApe.disEnabledBottomBar();
//UIControlApe.hideBottomDocControlBar();
let timestamp=ClassDataProxy.creatTimestamp();
let authId=MD5(ClassDataProxy.siteId+""+timestamp);///authId String MD5(siteId+timestamp)
//console.log("authId:"+authId,"siteId:"+ClassDataProxy.siteId,"timestamp:"+timestamp);
let fd = new FormData();
fd.append("fileToUpload", fileItem);
fd.append("filename", escape(fileItem.name));
fd.append("size", fileItem.size);
fd.append("siteId", ClassDataProxy.siteId); //站点
fd.append("timestamp", String(timestamp)); //时间戳
fd.append("authId",authId); //上传时间
fd.append("classId", String(ClassDataProxy.classId)); //课堂号
/* let ipport=ClassDataProxy.DOCServerIP;
if( ClassDataProxy.DOCServerPort){
ipport=ipport+":"+ClassDataProxy.DOCServerPort;
}
let mediaUploadUrl= `http://${ipport}/DocSharing/imageUpload`;
*/
let ipport=ClassDataProxy.DOCServerIP;
if( ClassDataProxy.DOCServerPort){
ipport=ipport+":"+ClassDataProxy.DOCServerPort;
}
let mediaUploadUrl= `${ClassDataProxy.locationProtocol+ipport}/DocSharing/imageUpload`;
$.ajax({
type: "POST",
url: mediaUploadUrl,
processData: false,
contentType: false,
data: fd,
xhr:function(){
let xhr = $.ajaxSettings.xhr();
if( xhr.upload) {
xhr.upload.addEventListener("progress" ,function(evt){
let loaded = evt.loaded; //已经上传大小情况
let tot = evt.total; //附件总大小
let per = Math.floor(100*loaded/tot); //已经上传的百分比
} , false);
return xhr;
}
},
success: function (data) {
UIControlApe.enabledDocBar();
UIControlApe.enabledMediaBar();
//UIControlApe.enabledLeftBar();
//UIControlApe.enabledBottomBar();
//UIControlApe.showBottomDocControlBar();
this._uploadFileSuccess(data);
$("#fileImgInput").val('');
}.bind(this),
error: function (data) {
UIControlApe.enabledDocBar();
UIControlApe.enabledMediaBar();
loger.warn(name+"->上传文件失败", data);
ErrorApe.showError(ErrorApe.TYPE_3,name+"->"+ClassDataProxy.localConfig.serverError);
$("#fileImgInput").val('')
}
});
}
//将上传文件的信息,传递给底层
_uploadFileSuccess(msg) {
loger.log("服务器返回的截图信息->", msg);
//{"code":0,"list":[{"name":"sintel (2).mp4","id":"7","url":"http://101.200.150.192:9090/media/h5dev/201706/1478111117/76303834c69cd86f6c6212ae3019b1d0.mp4"}]}
/*
//code
0:成功
1:不是上传请求
2:编码错误
3:无法解析请求内容
4:没有上传文件,或者上传文件超过10个
5:siteId 不能为空
6:authId 错误
7:文件类型不支持
8:保存文件信息失败
10:保存文件失败*/
if(msg&&msg.code==0){
//返回的数据中是一个数组,支持多个上传,目前只处理一个上传的情况
if(!msg){
loger.warn('上传文件返回的数据中数组没有数据',msg.list);
return;
}
let fileInfo = {};
fileInfo.fileName = fileItem.name;//伴音名字
fileInfo.url = msg.url; //图片绝对地址 默认值: null
if(this.callback){
this.callback(fileInfo);
}
//console.log("fileInfo", fileInfo);
//$("#txt_message").val(fileInfo.fileName);
//ClassDataProxy.imgInfo=fileInfo;
//$("#txt_message").focus();
}else {
loger.warn("截图上传失败->", msg.code);
ErrorApe.showError(ErrorApe.TYPE_3,'截图上传失败->code:'+msg.code);
}
}
}
export default ChatImg;
\ No newline at end of file
//*
// 课堂管理模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import ClassDataProxy from "proxy/ClassDataProxy";
import $ from "jquery";
import FlashToolComponet from "libs/FlashToolComponet";
import ErrorApe from './ErrorApe';
let loger = Loger.getLoger('PC-ClassApe');
class ClassApe extends Ape {
constructor() {
super();
this.isExit = false;//是否点击了退出或结束课堂
this.curClassStuNum = 0;
this._isEndClass = false; //判断是否点击结束课堂
this._isExitClass = false;//判断是否点击退出课堂
this._isNetwork = false;//判断是否有网络
this.addEvent();
this.init();
this._setClassStatus();
//显示页面信息
this._showPageInfo();
}
init() {
//设置当前版本号
$('#pcVersion').text("v2.58.3.20170823");
//布局,未加入课堂成之前上课界面不显示
//$('.header').hide();
//$(".content ").hide();
$(".loginBg ").show();//登陆框
$(".initParamsOut ").show();//初始化界面
//默认先尝试自动登陆,初始化的按钮先隐藏
//隐藏初始化界面UI
this._hideInitUI();
//隐藏登陆界面UI
this._hideLoginUI();
//header 按钮点击事件
$('.startClass').on("click", this._startClassHandler.bind(this));
$('.pauseClass').on("click", this._pasueClassHandler.bind(this));
$('.closeClass').on("click", this._closeClassHandler.bind(this));//结束课堂(所有人都要退出)
//$('.endClassEnsure').on("click", this._closeClassEnsureHandler.bind(this));
//$('.endClassCancel').on("click", this._closeClassCancelHandler.bind(this));
$('.help').on("click", this._helpHandler.bind(this));
$('.exit').on("click", this._exitClassHandler.bind(this));//退出课堂
$('.exitClassA').on("click", this._exitClassPopupHandler.bind(this));
//$('.exitClassEnsure').on("click", this._exitClassEnsureHandler.bind(this));
//$('.exitClassCancel').on("click", this._exitClassCancelHandler.bind(this));
$(".helpHeadline .iconfont").on("click", this._closeHelpHandler.bind(this));
//$(".setHeadline .iconfont").on("click", this._closeSetHandler.bind(this));
//初始化界面按钮
$('.ensureTeaBtn').show();
$('.ensureStuBtn').show();
$('.ensureTeaBtn').on("click", this._stuInitHandler.bind(this));
$('.ensureStuBtn').on("click", this._teacherInitHandler.bind(this));
//登陆界面按钮
$('.btnLoginLi').on("click", this._loginHandler.bind(this));
let that = this;
$(".passWordInput").on("keydown", function (e) {
let curKey = e.which;
if (curKey == 13) that._loginHandler();
});
}
addEvent() {
xdysdk.on("error_event", this._classErrorHandler.bind(this));
xdysdk.on("class_init_success", this._classInitSuccessHandler.bind(this));
xdysdk.on("class_get_info_success", this._classGetInfoSuccessHandler.bind(this));
xdysdk.on("class_join_success", this._classJoinSuccessHandler.bind(this));
xdysdk.on("class_update_status", this._classUpdateHandler.bind(this));//会议状态更新
xdysdk.on("class_insert_roster", this._classInsertRosterHandler.bind(this));//会议有用户加入
xdysdk.on("class_delete_roster", this._classDeleteRosterHandler.bind(this));//会议有人离开
xdysdk.on("class_update_timer", this._classUpdateTimerHandler.bind(this));//更新会议时间显示
xdysdk.on("class_exit", this._classExitHandler.bind(this));
}
//设置文字显示国际化
_showPageInfo() {
$('#memberNum').text(ClassDataProxy.localConfig.memberNum);
$('.exitText').text(ClassDataProxy.localConfig.exitBtn);
$('.settingText').text(ClassDataProxy.localConfig.setBtn);
$('.helpText').text(ClassDataProxy.localConfig.helpBtn);
$('#endClassroom').text(ClassDataProxy.localConfig.endClassroom);
$('#pauseClassroom').text(ClassDataProxy.localConfig.pauseClassroom);
$('#startClassroom').text(ClassDataProxy.localConfig.startClassroom);
$('.btnPublishVideo').attr('title', ClassDataProxy.localConfig.openVideo);
$('.btnPublishAudio').attr('title', ClassDataProxy.localConfig.openAudio);
$('.btnOpenVideo').attr('title', ClassDataProxy.localConfig.openVideo);
$('.btnOpenAudio').attr('title', ClassDataProxy.localConfig.openAudio);
$('.btnStopPublishVideo').attr('title', ClassDataProxy.localConfig.closeVideo);
$('.btnStopPublishAudio').attr('title', ClassDataProxy.localConfig.closeAudio);
$('.btnStopPublishMedia').attr('title', ClassDataProxy.localConfig.closeMedia);
$('#showColor').attr('title', ClassDataProxy.localConfig.showColor);
$('#controlBrush').attr('title', ClassDataProxy.localConfig.controlBrush);
$('.pencil').attr('title', ClassDataProxy.localConfig.pencil);
$('.rescind').attr('title', ClassDataProxy.localConfig.rescind);
$('.clearContent').attr('title', ClassDataProxy.localConfig.delete);
$('#pptNextStep').attr('title', ClassDataProxy.localConfig.downAnimated);
$('#pptPrevStep').attr('title', ClassDataProxy.localConfig.onAnimated);
$('#fitHeight').attr('title', ClassDataProxy.localConfig.adaptiveHigh);
$('#fitWidth').attr('title', ClassDataProxy.localConfig.adaptiveWidth);
$('#fitNormal').attr('title', ClassDataProxy.localConfig.showAll);
$('#raiseBtn').attr('title', ClassDataProxy.localConfig.raiseBtn);
$('.userNameInput').attr('placeholder', ClassDataProxy.localConfig.enterUserName);
$('.passWordInput').attr('placeholder', ClassDataProxy.localConfig.enterPassword);
$('.classId').attr('placeholder', ClassDataProxy.localConfig.enterClass);
$('.userId').attr('placeholder', ClassDataProxy.localConfig.enterId);
$('#member').text(ClassDataProxy.localConfig.member);
$('#discuss').text(ClassDataProxy.localConfig.discuss);
$('#btn_send').text(ClassDataProxy.localConfig.sendMsg);
$('#docListTitle').text(ClassDataProxy.localConfig.documentList);
$('#mediaListTitle').text(ClassDataProxy.localConfig.mediaShareList);
$('.helpHeadlineTitle').text(ClassDataProxy.localConfig.help);
$('.setHeadlineTitle').text(ClassDataProxy.localConfig.setUp);
$('#camera').text(ClassDataProxy.localConfig.camera);
$('#microphone').text(ClassDataProxy.localConfig.microphone);
$('#volume').text(ClassDataProxy.localConfig.volume);
$('.setSave').text(ClassDataProxy.localConfig.preserve);
$('.setCancel').text(ClassDataProxy.localConfig.cancel);
$('.endClassHeadlineTitle').text(ClassDataProxy.localConfig.endClassroom);
$('.endClassText').text(ClassDataProxy.localConfig.endClassroomCont);
//$('.endClassEnsure').text(ClassDataProxy.localConfig.confirm);
//$('.endClassCancel').text(ClassDataProxy.localConfig.cancel);
$('.exitClassHeadlineTitle').text(ClassDataProxy.localConfig.exitBtn);
$('.exitClassText').text(ClassDataProxy.localConfig.exitCont);
//$('.exitClassEnsure').text(ClassDataProxy.localConfig.confirm);
//$('.exitClassCancel').text(ClassDataProxy.localConfig.cancel);
$('#btnLogin').text(ClassDataProxy.localConfig.register);
$('.ensureTeaBtn').text(ClassDataProxy.localConfig.teacher);
$('.ensureStuBtn').text(ClassDataProxy.localConfig.student);
$('#opening').html(ClassDataProxy.localConfig.opening);
$('#download').html(ClassDataProxy.localConfig.downloadVersion);
$('#downloading').html(ClassDataProxy.localConfig.downloading);
$('#stopShare').html(ClassDataProxy.localConfig.stopSharing);
$('.themeHeadlineTitle,.resultHeadlineTitle,.studentHeadline,.answerText').html(ClassDataProxy.localConfig.answerSheet);
$('.signHeadlineTitle,.signStudentHeadlineTitle,.signText').html(ClassDataProxy.localConfig.rollCall);
$('#docListOut').attr('title', ClassDataProxy.localConfig.selectFile);
$('#screenSharingOut').attr('title', ClassDataProxy.localConfig.screenSharing);
$('#mediaUpLoadOut').attr('title', ClassDataProxy.localConfig.updateMediaFile);
$('#mediaListOut').attr('title', ClassDataProxy.localConfig.selectMediaFile);
$('#uploadAudio').attr('title', ClassDataProxy.localConfig.uploadAudio);
$('.laserPen').attr('title', ClassDataProxy.localConfig.laserPen);
$('.sponsorSign').html(ClassDataProxy.localConfig.startName);
$('.attendance').html(ClassDataProxy.localConfig.attendance);
$('.turnResultBtn').html(ClassDataProxy.localConfig.terminationRollCall);
$('.turnStudentBtn').html(ClassDataProxy.localConfig.signIn);
$('.themeTit').html(ClassDataProxy.localConfig.cardType);
$('.gotIt').html(ClassDataProxy.localConfig.gotIt);
$('.understand').html(ClassDataProxy.localConfig.understand);
$('.yes').html(ClassDataProxy.localConfig.yes);
$('.wrong').html(ClassDataProxy.localConfig.wrong);
$('.yup').html(ClassDataProxy.localConfig.yup);
$('.nothing').html(ClassDataProxy.localConfig.nothing);
$('.answerTime').html(ClassDataProxy.localConfig.answerTime);
$('.dynamicRight').html(ClassDataProxy.localConfig.release);
$('.enterAnswer').html(ClassDataProxy.localConfig.enterAnswer);
$('.answerResult').html(ClassDataProxy.localConfig.answerResult);
$('.share').html(ClassDataProxy.localConfig.share);
$('.participation').html(ClassDataProxy.localConfig.participation);
$('.resultConceal').html(ClassDataProxy.localConfig.hideCount);
$('.resultTermination').html(ClassDataProxy.localConfig.termination);
$('.referBtn').html(ClassDataProxy.localConfig.submitMsg);
$('.abandonBtn').html(ClassDataProxy.localConfig.giveUp);
$('.mediaFileContentTxt').html(ClassDataProxy.localConfig.listedFiles);
$('.mediaFileContentMenuLableTxt').html(ClassDataProxy.localConfig.upload);
$('#musicListTitle').html(ClassDataProxy.localConfig.audioFilelist);
$('.inputCount').html(ClassDataProxy.localConfig.answerIsNotEmpty);
$('.downloadCancel').html(ClassDataProxy.localConfig.cancel);
$('#showForm').attr('title', ClassDataProxy.localConfig.selectShape);//选择形状
$('#curveBrush').attr('title', ClassDataProxy.localConfig.curveStyle);//曲线
$('#straightBrush').attr('title', ClassDataProxy.localConfig.justStyle);//直线
$('#circleBrush').attr('title', ClassDataProxy.localConfig.circleStyle);//圆形
$('#squareBrush').attr('title', ClassDataProxy.localConfig.squareStyle);//方形
//询问弹框中的确定和取消按钮
$('#choiceConfirm').html(ClassDataProxy.localConfig.confirm);
$('#choiceCancel').html(ClassDataProxy.localConfig.cancel);
//提示框
$('#nowLiveVersion').html(ClassDataProxy.localConfig.nowLiveVersion);
$('#nowPlaybackVersion').html(ClassDataProxy.localConfig.nowPlaybackVersion);
$('#browserAreaSettings').html(ClassDataProxy.localConfig.browserAreaSettings);
$('.speed360Recommend').html(ClassDataProxy.localConfig.speed360Recommend);
$('.speed360').html(ClassDataProxy.localConfig.speed360);
$('.security360').html(ClassDataProxy.localConfig.security360);
$('.security360Only').html(ClassDataProxy.localConfig.security360Only);
$('.sogouExplorer').html(ClassDataProxy.localConfig.sogouExplorer);
$('#flashVersionsLow').html(ClassDataProxy.localConfig.flashVersionsLow);
$('#flashDownload').html(ClassDataProxy.localConfig.download);
$('#flashRetry').html(ClassDataProxy.localConfig.retry);
$('.flashForbiddenMsg').html(ClassDataProxy.localConfig.flashForbiddenMsg);
$('#flashMsgContent').html(ClassDataProxy.localConfig.flashMsgContent);
$('#flashDetailSteps').html(ClassDataProxy.localConfig.flashDetailSteps);
$('#flashUpdataVersions').html(ClassDataProxy.localConfig.flashUpdataVersions);
}
_showInitClassInuptBox() {
this._showInitUI();
$(".classId ").val(ClassDataProxy.classId);
$(".userId ").val(ClassDataProxy.userId);
$(".initParamsOut ").show();
}
_showJoinClassInputBox() {
$(".userNameInput ").val(ClassDataProxy.userName);
$(".loginBg ").show();
this._showLoginUI();
if (ClassDataProxy.passwordRequired) {
$(".passWordInput ").val(ClassDataProxy.password);
} else {
$(".passWordLi ").hide();
loger.log("ClassDataProxy.passwordRequired", ClassDataProxy.passwordRequired);
}
}
//EVENT--------------------------------------------------
startClassRun() {
this._initClass();
}
//初始化课堂
_initClass() {
loger.log("initClass", ClassDataProxy.getInitClassData());
loger.log("是否是录制回放->", ClassDataProxy.isRecordPlayBack);
$(".initParams .errorTip").text(ClassDataProxy.localConfig.initClass);
$(".initParams .errorTip").show();
//隐藏初始化和登陆按钮,如果是自动登陆,这些按钮就不用显示了
this._hideInitUI();
$(".classId ").val(ClassDataProxy.classId);
$(".userId ").val(ClassDataProxy.userId);
if (ClassDataProxy.isRecordPlayBack) {
$("#mainContentBox ").css("top", "2px");
xdysdk.api("initRecordPlayback", ClassDataProxy.getInitClassData());
} else {
xdysdk.api("init", ClassDataProxy.getInitClassData());
}
}
//加入课堂
_joinClass() {
loger.log("joinClass", ClassDataProxy.getJoinClassData());
this._hideLoginUI();
$(".btnLoginLi ").hide();
$(".initParamsOut ").hide();
$(".userNameInput ").val(ClassDataProxy.userName);
$(".passWordInput ").val(ClassDataProxy.password);
$(".loginContent .errorTip").text(ClassDataProxy.localConfig.initClass);
xdysdk.api("joinClass", ClassDataProxy.getJoinClassData());
}
_setClassStatus() {
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
//设置状态显示
if (ClassDataProxy.classStatus == 1) {
$('.startClass').hide();
$('.pauseClass').show();
} else {
$('.startClass').show();
$('.pauseClass').hide();
}
}
//录制回放状态
if (ClassDataProxy.isRecordPlayBack) {
$('.classStatus').text(ClassDataProxy.localConfig.playback);
$('.classStatus').css("color", "#d95136");
$('.classStatusIcon').html('&#xe609;');
$('.classStatusIcon').css("color", "#d95136");
return;
}
//正常使用状态
if (ClassDataProxy.classStatus == 1) {
$('.classStatus').text(ClassDataProxy.localConfig.liveBroadcast);
$('.classStatus').css("color", "#d95136");
$('.classStatusIcon').html('&#xe609;');
$('.classStatusIcon').css("color", "#d95136");
} else if (ClassDataProxy.classStatus == 2) {
$('.classStatus').text(ClassDataProxy.localConfig.rest);
$('.classStatusIcon').html('&#xe60a;');
$('.classStatusIcon').css("color", "#ccc");
$('.classStatus').css("color", "#ccc");
} else {
$('.classStatus').text(ClassDataProxy.localConfig.notStart);
$('.classStatusIcon').html('&#xe62b;');
$('.classStatusIcon').css("color", "#ccc");
$('.classStatus').css("color", "#ccc");
}
}
_hideInitUI() {
loger.log("_hideInitUI");
$(".initParamsClassId ").hide();
$(".initParamsUserId ").hide();
$(".initParamsRoleBtn ").hide();
$('.initParamsBox').css('background', '');
}
_showInitUI() {
loger.log("_showInitUI");
$(".initParamsClassId ").show();
$(".initParamsUserId ").show();
$(".initParamsRoleBtn ").show();
$(".initParams .errorTip").show();
$('.initParamsBox').css('background', '#484646');
}
_hideLoginUI() {
$(".btnLoginLi ").hide();
$(".userNameLi ").hide();
$(".passWordLi ").hide();
$('.loginContentBox').css('background', '');
}
_showLoginUI() {
$(".btnLoginLi ").show();
$(".userNameLi ").show();
$(".passWordLi ").show();
$('.loginContentBox').css('background', '#484646');
}
//xdysdk事件监听处理--------------------------------------
_classErrorHandler(_data) {
loger.warn("_classErrorHandler", _data);
switch (_data.code) {
case 100:
case 101:
case 102:
case 103:
case 105:
case 106:
case 107:
case 301:
this._showInitClassInuptBox();
$(".initParams .errorTip").text("" + _data.reson);
break;
case 200:
case 201:
case 202:
case 203:
case 204:
case 205:
case 207:
this._showJoinClassInputBox();
$(".loginContent .errorTip").text("" + _data.reson);
break;
case 206:
//请输入正确密码
this._showJoinClassInputBox();
$(".loginContent .errorTip").text(ClassDataProxy.localConfig.correctPassword);
break;
case 300:
case 301:
loger.warn(_data);
break;
case 910:
ErrorApe.showWarnError("" + _data.reson)
$(".initParams .errorTip").text("" + _data.reson);
break;
case 911:
ErrorApe.showWarnError("" + _data.reson)
$(".initParams .errorTip").text("" + _data.reson);
break;
case 20000:
//已经退出就不再显示网络端口了
if (this.isExit) {
return;
}
ErrorApe.showWarnError(ClassDataProxy.localConfig.disconnected);
this._emit(ClassApe.CLASS_STOP_MEDIA_PUBLISH);
break;
default:
break;
}
}
_classInitSuccessHandler(_data) {
loger.log("课堂初始化成功", new Date().getTime(), _data);
$(".initParamsOut ").hide();
ClassDataProxy.siteId = _data.siteId;
ClassDataProxy.classType = _data.classType;
ClassDataProxy.userName = _data.userName;
ClassDataProxy.userRole = _data.userRole;//以加入成功之后的为准
ClassDataProxy.passwordRequired = _data.passwordRequired;
this._joinClass();
}
_classGetInfoSuccessHandler(_data) {
loger.log("获取课堂信息完成", new Date().getTime(), _data);
}
_classJoinSuccessHandler(_data) {
loger.log("加入课堂成功", new Date().getTime(), _data);
$(".initParamsOut ").hide();
$(".loginBg ").hide();
this._isNetwork = true;
ClassDataProxy.maxAudioChannels = _data.maxAudioChannels;
ClassDataProxy.maxVideoChannels = _data.maxVideoChannels;
ClassDataProxy.nodeId = _data.nodeId;
ClassDataProxy.classTimestamp = _data.classTimestamp || 0;
ClassDataProxy.recordPlaybackMaxTime = _data.recordPlaybackMaxTime || 0;
ClassDataProxy.classType = _data.classType || 1;
ClassDataProxy.className = _data.className || ClassDataProxy.localConfig.unknown;
ClassDataProxy.siteId = _data.siteId || ClassDataProxy.localConfig.unknown;
ClassDataProxy.userRole = _data.userRole;
ClassDataProxy.classStatus = _data.classStatus;
ClassDataProxy.DOCServerIP = _data.DOCServerIP || "";
ClassDataProxy.DOCServerPort = _data.DOCServerPort || "";
ClassDataProxy.serverTimeDistance = _data.serverAndLoacTimeDistanc;
if (!ClassDataProxy.serverTimeDistance) {
ClassDataProxy.serverTimeDistance = 0;
}
ClassDataProxy.ssTunnelAppURL = _data.ssTunnelAppURL || "";//插件地址
//console.log("ClassDataProxy",ClassDataProxy);
ClassDataProxy.currentSceneTableId = _data.currentSceneTableId || ClassDataProxy.SCENE_DOC;//记录文档区域当前显示的是哪个模块;0=文档模块,1=屏幕共享,2=媒体共享
$('.header').show();
$('.pauseClass').hide();
$(".content ").show();
//$('.classTheme').text(`[${ClassDataProxy.siteId}]-${ClassDataProxy.className}`);//这里不显示,显示在title中
$('.classTheme').hide();
if (ClassDataProxy.classTimestamp > 0) {
$('.classTimestampText').text(ClassDataProxy.timestampToDateTimeFull(ClassDataProxy.classTimestamp));
} else {
$('.classTimestampText').text("");
}
document.title = ClassDataProxy.className || "";
//设置界面元素不可选,如果不设置会影响到canvas的绘制
/* document.body.onselectstart = document.body.oncontextmenu = function () {
if ($('div').is('.message')) {
return true;
}
return false;
};*/
this._setClassStatus();
//如果不是老师,不能操作课堂按钮
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
$(".laserRed").hide();
//老师可以操作不
} else if (ClassDataProxy.userRole == ClassDataProxy.USER_INVISIBLE) {
//监课不能使用的功能 自己的设置面板 绘画区的工具栏 底部工具类 举手
$('.setting').hide();
$('.foldDrawToolOut').hide();
$('.drawTool').remove();
$("#controlBrush").hide();
$('.raiseBtn').hide();
$('.answer').hide();
$('.sign').hide();
$('.startClass').hide();
$('.pauseClass').hide();
$('.closeClass').hide();
$('.left').hide();
} else {
//其他身份按普通人处理
loger.log("隐藏控制按钮");
$('.startClass').hide();
$('.pauseClass').hide();
$('.closeClass').hide();
$('.left').hide();
$('.answer').hide();
$('.sign').hide();
}
//录制回放时的状态设置
if (ClassDataProxy.isRecordPlayBack) {
$('.exit').hide();
$('.startClass').hide();
$('.pauseClass').hide();
$('.closeClass').hide();
$('.left').hide();
$('.curClassUserNum').hide();
$('.classTimestampText').hide();
$('.setting').hide();
$('.userListTitle').hide();
$('#raiseBtn').hide();
}
this._setClassStatus();
/*
//移动端做延迟处理,PC端不做处理
setTimeout(function(){
//延迟消息处理
xdysdk.api("setMessageDelay",{"messageDelay":true});
},3000);
*/
//只有在1v1课堂时,学生可以进行画
if (ClassDataProxy.maxMediaChannels == 2 && ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL) {
$('.foldDrawToolOut').show();
$('.foldDrawTool').show();
$(".drawTool").show();
$(".drawTool").css("height", "160px");
$(".clearContent").hide();
$(".laserPen").hide();
$("#controlBrush").hide();
} else if (ClassDataProxy.maxMediaChannels !== 2 && ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL) {
$('.foldDrawToolOut').hide();
$('.foldDrawTool').hide();
$(".drawTool").hide();
$(".clearContent").hide();
$(".laserPen").hide();
$("#controlBrush").hide();
}
}
_classUpdateHandler(_data) {
loger.log('课堂状态发送改变->', _data);
ClassDataProxy.classStatus = _data.classStatus;
ClassDataProxy.classStartTime = _data.classStartTime;
ClassDataProxy.classStopTime = _data.classStopTime;
ClassDataProxy.classBeginTime = _data.classBeginTime;
ClassDataProxy.classEndTime = _data.classEndTime;
ClassDataProxy.currentSceneTableId = _data.currentSceneTableId || ClassDataProxy.SCENE_DOC;//记录文档区域当前显示的是哪个模块;0=文档模块,1=屏幕共享,2=媒体共享
this._setClassStatus();
}
_classInsertRosterHandler(_data) {
//loger.log(_data);
this.curClassStuNum++;
$(".curClassUserNumTotal").html(this.curClassStuNum);
}
_classDeleteRosterHandler(_data) {
//loger.log(_data);
this.curClassStuNum--;
if (this.curClassStuNum < 0) {
this.curClassStuNum = 0;
}
$(".curClassUserNumTotal").html(this.curClassStuNum);
}
_classUpdateTimerHandler(_data) {
ClassDataProxy.classTimestamp = _data.classTimestamp;
if (!ClassDataProxy.isRecordPlayBack) {
$('.classTimestampText').text(ClassDataProxy.timestampToDateTimeFull(ClassDataProxy.classTimestamp));
}
}
//退出课堂,关闭界面
_classExitHandler() {
loger.log("_classExitHandler");
this.isExit = true;
ClassDataProxy.classStatus = 0;
$('.classStatus').text(ClassDataProxy.localConfig.notStart);
$(".box").hide();
$('.answerAllBox').hide();
$('.signAllBox').hide();
$(".setBox").hide();
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.quitClass)
$("#h5Music").attr("src", "");
$("#h5MediaShare").attr("src", "");
}
//mouseEvent--------------------------------
_startClassHandler() {
//开始之前需要停止当前的所有音视频
setTimeout(function () {
xdysdk.api("sendStartClass");
}, 200);
}
_pasueClassHandler() {
//暂停的时候停止当前的所有音视频
setTimeout(function () {
xdysdk.api("sendPauseClass");
}, 200)
}
//询问是结束课堂(所有人都要退出)
_closeClassHandler() {
let _this = this;
ErrorApe.showError(ErrorApe.TYPE_20, ClassDataProxy.localConfig.endClassroomCont, function (_value) {
// loger.log("_closeClassHandler================",_value);
if (_value == true) {
loger.warn("确定结束课堂", _value);
_this._closeClassEnsureHandler();
} else {
loger.warn("取消结束课堂", _value);
}
ErrorApe.hide();
})
}
_closeClassEnsureHandler() {
this.isExit = true;
xdysdk.api("sendCloseClass");
}
_closeClassCancelHandler() {
ErrorApe.hide();
}
//询问是否退出课堂(自己)
_exitClassHandler() {
let _this = this;
ErrorApe.showError(ErrorApe.TYPE_20, ClassDataProxy.localConfig.exitCont, function (_value) {
if (_value == true) {
loger.warn("确定退出课堂", _value);
_this._exitClassEnsureHandler();
} else {
loger.warn("取消退出课堂", _value);
}
ErrorApe.hide();
});
}
_exitClassPopupHandler() {
ErrorApe.hide();
}
_exitClassEnsureHandler() {
// ErrorApe.hide();
this.isExit = true;
xdysdk.api("leaveClass");
this._classExitHandler();
}
_exitClassCancelHandler() {
ErrorApe.hide();
}
_helpHandler() {
$(".helpBox").show();
$(".masker").show();
}
_closeHelpHandler() {
$(".helpBox").hide();
$(".masker").hide();
}
_stuInitHandler() {
ClassDataProxy.userRole = ClassDataProxy.USER_NOTMAL;
ClassDataProxy.classId = parseInt($(".classId ")[0].value);
ClassDataProxy.userId = $(".userId ")[0].value;
this._initClass();
}
_teacherInitHandler() {
ClassDataProxy.userRole = ClassDataProxy.USER_HOST;
ClassDataProxy.classId = parseInt($(".classId ")[0].value);
ClassDataProxy.userId = $(".userId ")[0].value;
this._initClass();
}
_loginHandler() {
let userName = $('.userNameInput').val();
let userPwd = $('.passWordInput').val();
let errMsg = $(".errorTip");
if (userPwd) {
$(".loginSpinner").show();
}
if (!userName) {
errMsg.html('请输入用户名').addClass('showErr');
return false;
}
if (ClassDataProxy.passwordRequired && !userPwd) {
errMsg.html('请输入密码').addClass('showErr');
return false;
}
ClassDataProxy.userName = $(".userNameInput ")[0].value || '';
ClassDataProxy.password = $(".passWordInput ")[0].value;
this._joinClass();
}
}
ClassApe.prototype.CLASS_STOP_MEDIA_PUBLISH = ClassApe.CLASS_STOP_MEDIA_PUBLISH = "class_stop_media_publish";//停止所有媒体推流
export default ClassApe;
... ... @@ -4,9 +4,6 @@
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";
import dateUI from 'libs/laydate';
... ...
//*
// 文档模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import DynamicPPT from './DynamicPPT';
import UIControlApe from './UIControlApe';
import ErrorApe from './ErrorApe';
let loger = Loger.getLoger('PC-DocApe');
const DOC_SHOW_FULL = 0;//完整显示
const DOC_SHOW_WIDTH = 1;//按宽度显示
const DOC_SHOW_HEIGHT = 2;//按高度显示
const PPT_WIDTH = 720;//动态ppt标准宽度
const PPT_HEIGHT = 540;//动态ppt标准高度
class DocApe extends Ape {
constructor() {
super();
this.showDocDefaultDelay = 0;
this._docShowType = DOC_SHOW_FULL;//文档显示模式
this.lastV=0;
this.lastH=0;
this.curV=0;
this.curH=0;
this._docList = {};//文档数据
this._currentDocId = 0;//当前显示文档id,0就是没有文档,只显示白板
this._currentPageNum = 1;//,默认页数是1
this._pageNum = 1;//,默认总页数是1
this.currentImagePath = "";//当前显示的图片地址
this.resizeDelay;//窗口大小变化延迟处理
this.dynamicPPT;
this.addEvent();
this.init();
}
init() {
//布局
this.dynamicPPT = new DynamicPPT();
$(window).on('resize', this.onWindowResize.bind(this));
$('.docBox').on('scroll', this._changeDocScroll.bind(this));//监听文档滚动
$(".docView").hide();
$(".docView").on('load', this._onLoadImage.bind(this));
$(".docView").on('error', this._onLoadImageError.bind(this));
//UI按钮点击事件
//$("#file").on("change", this._uploadFile.bind(this));//左侧栏的上传文档
$("#docFileBtn").on("change", this._uploadFile.bind(this));//文件列表中的上传文档
$("#docListOut").on("click", this._openDocListHandler.bind(this));//打开列表
//$(".docHeadline .iconfont").on("click", this._closeDocListHandler.bind(this));
$("#closeDocList").on("click", this._closeDocListHandler.bind(this));
//botTurn
$(".nextPage").on("click", this._nextHandler.bind(this));
$(".prevPage").on("click", this._prevHandler.bind(this));
$("#totalPageNum").text(this._pageNum);
$("#currentPageNum").text(this._currentPageNum);
//显示模式
$(".fitHeight").on("click", this._fitInHandler.bind(this));
$(".fitWidth").on("click", this._fitInHandler.bind(this));
$(".fitNormal").on("click", this._fitInHandler.bind(this));
//默认文档全部显示
$('.fitNormal').css("color", "#3498db");
//显示底部控制栏的按钮,默认都隐藏
$(".nextPage").hide();
$(".prevPage").hide();
this.hideFitGroup();
;
//默认隐藏页码显示
this._hidePageInfo();
this.onWindowResize();
UIControlApe.showBottomDocControlBar();
//特定页码
$('.turn').on('click', this._particularPage.bind(this));
let that = this;
$("#pageNo").on("keydown", function (e) {
let curKey = e.which;
if (curKey == 13) that._particularPage();
});
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
$(document).keydown(function (e) {
if (e.keyCode == 37) {
that._prevHandler();
}
});
$(document).keydown(function (e) {
if (e.keyCode == 39) {
that._nextHandler();
}
});
}
$('.docBox')[0].ondragstart = function(){
return false;
}
}
addEvent() {
xdysdk.on("class_join_success", this._classJoinSuccessHandler.bind(this));
xdysdk.on("document_update", this._docUpdateHanlder.bind(this));//文档更新
xdysdk.on("document_delete", this._docDeleteHanlder.bind(this));//文档删除
}
_classJoinSuccessHandler(_data) {
if (_data.userRole == ClassDataProxy.USER_NOTMAL || ClassDataProxy.isRecordPlayBack) {
$("#docUploadOut").hide();
$("#file").hide();
$("#docListOut").hide();
$(".nextPage").hide();
$(".prevPage").hide();
this.hideFitGroup();
}
this.onWindowResize();
}
clear() {
loger.log("clear");
this._docList = {};//文档数据
this._currentDocId = 0;
this._currentPageNum = 1;
this._pageNum = 1;
this.currentImagePath = "";//清空记录的图片地址
ClassDataProxy.currentPageNum = this._currentPageNum;
ClassDataProxy.currentDocId = this._currentDocId;
this._hideDocView();
this.dynamicPPT.updataPPT(null);
}
stop() {
loger.log("stop");
this._docList = {};//文档数据
this._currentDocId = 0;
this._currentPageNum = 1;
this._pageNum = 1;
this.currentImagePath = "";//清空记录的图片地址
ClassDataProxy.currentPageNum = this._currentPageNum;
ClassDataProxy.currentDocId = this._currentDocId;
this._hideDocView();
this.dynamicPPT.updataPPT(null);
}
//舞台大小发生改变
onWindowResize() {
//loger.log("舞台大小发生改变");
clearTimeout(this.resizeDelay);
let _this = this;
this.resizeDelay = setTimeout(function () {
//loger.log("舞台大小发生改变->刷新文档显示");
clearTimeout(_this.resizeDelay);
_this._fitInDocView(_this._docShowType);
}, 400);
}
//文档区域的滚动条发生改变
_changeDocScroll(evt) {
clearTimeout(this.scrollCompleteTimer);
//如果自己是老师,需要同步自己的滚动条位置给其他人,否则不做处理
if (ClassDataProxy.userRole != ClassDataProxy.USER_HOST) {
return;
}
this.scrollCompleteTimer = setTimeout(() => {
this._updateCurrentDocScroll();
}, 400);
}
//更新当前文档的滚动条位置-老师控制-发送
_updateCurrentDocScroll() {
if (ClassDataProxy.userRole != ClassDataProxy.USER_HOST) {
return;
}
let maxScrollH = $(".docBox").prop("scrollWidth") - $(".docBox").width();
let maxScrollV = $(".docBox").prop("scrollHeight") - $(".docBox").height();
let _curV =parseInt( $(".docBox").scrollTop());
let _curH = parseInt($(".docBox").scrollLeft());
this.curV = parseInt(_curV / maxScrollV * 1000)||0;
this.curH = parseInt(_curH / maxScrollH * 1000)||0;
//loger.warn("lastV:"+this.lastV+" curV:"+this.curV+" lastH:"+this.lastH+" curH:"+this.curH);
if(Math.abs(this.curH-this.lastH)<20&&Math.abs(this.curV-this.lastV)<20){
//loger.warn("不需要同步滚动条位置");
this.lastV=this.curV;
this.lastH=this.curH;
return;
}
this.lastV=this.curV;
this.lastH=this.curH;
if (this._currentDocId > 0) {
this._sendDocumentCommand2sdk();
}
}
//更新当前文档的滚动条位置-收取
_setCurrentDocScroll(_data) {
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
return;
}
this.curV = parseInt(_data.curV);
this.curH = parseInt(_data.curH);
let maxScrollH = $(".docBox").prop("scrollWidth") - $(".docBox").width();
let maxScrollV = $(".docBox").prop("scrollHeight") - $(".docBox").height();
let leftS = parseInt(this.curV * maxScrollV * 0.001);
let topS = parseInt(this.curH * maxScrollH * 0.001);
$(".docBox").scrollTop(leftS);
$(".docBox").scrollLeft(topS);
// loger.log("更新当前文档的滚动条位置",maxScrollH,maxScrollV,leftS,topS,_data);
}
//监听文档更新消息
_docUpdateHanlder(_data) {
//loger.log("文档模块收到SDK数据");
if (_data == null) {
return;
}
this._setCurrentDocScroll(_data);
//更新文档视图区域
if (_data.visible == true) {
clearTimeout(this.showDocDefaultDelay);
this._currentDocId = _data.itemIdx;
this._currentPageNum = _data.curPageNo;
this._pageNum = _data.pageNum;
//记录文档的显示模式
//如果是录制回放模式,固定使用全部显示的模式
if (ClassDataProxy.isRecordPlayBack) {
this._docShowType = DOC_SHOW_FULL;
} else {
this._docShowType = _data.showType || DOC_SHOW_FULL;
}
this._changeDocShowBtns(this._docShowType);
ClassDataProxy.currentPageNum = this._currentPageNum;
ClassDataProxy.currentDocId = this._currentDocId;
if (this._pageNum <= 1) {
this._hidePageInfo();
} else {
this._showPageInfo();
}
this._showDocView(_data);
}
//操作数据
this._updateDocListData(_data, "add");
}
//监听文档删除消息
_docDeleteHanlder(_data) {
loger.log("_docDeleteHanlder", _data);
this._updateDocListData(_data, "delete");
}
//更新文档数据(包括更新和删除)
_updateDocListData(_data, _type) {
if (_type == "add" && _data) {
//loger.log("添加文件数据", _data);
this._docList[_data.itemIdx] = _data;
} else {
loger.log("删除文档数据", _data.itemIdx);
delete this._docList[_data.itemIdx];
if (this._currentDocId == _data.itemIdx) {
this._currentDocId = 0;
this._currentPageNum = 1;
this._pageNum = 1;
ClassDataProxy.currentPageNum = this._currentPageNum;
ClassDataProxy.currentDocId = this._currentDocId;
//当前显示的文档数据被清除,文档图片也要删除
this._hideDocView();
//如果是动态ppt,也需要删除
if (this.dynamicPPT.pptData && this.dynamicPPT.pptData.itemIdx == _data.itemIdx) {
this.dynamicPPT.updataPPT(null);
}
this._docShowType = DOC_SHOW_FULL;//文档显示模式
//标注的区域也需要设置
$(".docView").width("0");
$(".docView").height("0");
let docBoxWidh = $(".docBox")[0].clientWidth;
let docBoxHeight = $(".docBox")[0].clientHeight;
$(".docGroup").width(docBoxWidh);
$(".docGroup").height(docBoxHeight);
$(".docGroup").css("left", "0px");
$(".docGroup").css("top", "0px");
this._hidePageInfo();
this.hideFitGroup();
this._hideOverflow();
this._emit(DocApe.DOC_IMAGE_LOAD, {"width": docBoxWidh, "height": docBoxHeight});
this.onWindowResize();
}
}
//更新文件列表(列表数据更新的时候需要刷新)
this._updateDocListView();
//根据总页数显示翻页按钮
if (this._currentDocId > 0 && this._pageNum > 1 && ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
$(".nextPage").show();
$(".prevPage").show();
} else {
$(".nextPage").hide();
$(".prevPage").hide();
}
//显示当前页和总页数
$("#totalPageNum").text(this._pageNum);
$("#currentPageNum").text(this._currentPageNum);
}
//更新底部控制栏
_updateFitGroup() {
if (this._currentDocId == 0 || this._pageNum < 1 || ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL || ClassDataProxy.userRole == ClassDataProxy.USER_INVISIBLE) {
this.hideFitGroup();
} else if (this._currentDocId > 0 && ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
this.showFitGroup();
}
}
hideFitGroup() {
$(".fitHeight").hide();
$(".fitWidth").hide();
$(".fitNormal").hide();
$(".turn").hide();
$(".pageNo").hide();
}
showFitGroup() {
$(".fitHeight").show();
$(".fitWidth").show();
$(".fitNormal").show();
}
//更新文件列表显示
_updateDocListView() {
$("#docFileContent").empty();
console.log("this._docList", this._docList);
for (let i in this._docList) {
if (this._docList[i].docId) {
let listItem = this._creatListItemDiv(i, this._docList[i].fileName, this._docList[i].itemIdx);
$("#docFileContent").append(listItem);
}
}
}
//隐藏滚动条
_hideOverflow() {
$(".docBox")[0].style.overflow = "";
}
//显示滚动条 _type(显示的滚动条方向)
_showOverflow(_type) {
this._hideOverflow();
if (_type && _type == "y") {
$(".docBox")[0].style.overflowY = "scroll";
$(".docBox")[0].style.overflowX = "hidden";
} else {
$(".docBox")[0].style.overflowX = "scroll";
$(".docBox")[0].style.overflowY = "hidden";
}
}
//隐藏页码信息
_hidePageInfo() {
$(".total-page").hide();
$(".cur-page").hide();
$(".bias").hide();
$(".pageNo").hide();
$(".turn").hide();
}
//显示页码信息
_showPageInfo() {
$(".total-page").show();
$(".cur-page").show();
$(".bias").show();
$(".pageNo").show();
$(".turn").show();
}
//显示文档
_showDocView(_data) {
if (_data.fileType == "zip") {
this.dynamicPPT.updataPPT(_data);
this._hideDocView();
this.onWindowResize();
this.hideFitGroup();
//老师的需要显示翻页
if (ClassDataProxy.userRole == ClassDataProxy.USER_HOST) {
$(".turn").show();
$(".pageNo").show();
}
} else {
this.dynamicPPT.updataPPT(null);
this.currentImagePath = "";//清空记录的图片地址
this._hideDocView();
this._updateFitGroup();
let imgArr = _data.images || [];
if (imgArr && imgArr.length > 0) {
let img = imgArr[this._currentPageNum - 1];
if (img) {
//console.warn("currentImagePath:"+this.currentImagePath,"newImg:"+img);
this.currentImagePath = img;
$(".docView").attr('src', img);
if (_data.curPageNo > 0 && _data.curPageNo < _data.pageNum - 1) {
if (_data.curPageNo >= 3) {
let _arr = [_data.images[_data.curPageNo - 3], _data.images[_data.curPageNo - 2], _data.images[_data.curPageNo], _data.images[_data.curPageNo + 1]];
this._preloadimages(_arr);
} else if (_data.curPageNo < 3&&_data.curPageNo>=1) {
let _arr = [_data.images[_data.curPageNo-1],_data.images[_data.curPageNo]];
this._preloadimages(_arr);
}
}
else if(_data.curPageNo > 0 &&_data.pageNum<=3){
let _arr = _data.images;
this._preloadimages(_arr);
}
$(".docView").attr('alt', _data.fileName || "");
$(".docView").show();
}
}
}
}
_preloadimages(arr) {
var newimages = [];
var arr = (typeof arr != "object") ? [arr] : arr //确保参数总是数组
for (var i = 0; i < arr.length; i++) {
newimages[i] = new Image();
newimages[i].src = arr[i];
if (newimages[i].complete || newimages[i].width) {
loger.log('该图片已经存在于缓存之中,不会再去重新下载');
}
else {
loger.log('图片不存在缓存之中');
newimages[i].onload = function () {
loger.log('图片下载成功!');
}
}
}
}
//隐藏文档
_hideDocView(_data) {
//清除原来的设置,先获取实际大小
$(".docView").removeAttr("width");
$(".docView").removeAttr("height");
$(".docView").attr('src', "");
$(".docView").width("0");
$(".docView").height("0");
$(".docView").hide();
this.currentImagePath="";
this._hideOverflow();
if (this._pageNum <= 1) {
this._hidePageInfo();
} else {
this._showPageInfo();
}
}
//显示文档列表
_openDocListHandler() {
this._emit(DocApe.SCENE_DOC_CHANGE, ClassDataProxy.SCENE_DOC);
UIControlApe.enabledBottomBar();
UIControlApe.enabledLeftBar();
UIControlApe.showBottomDocControlBar();
$("#docModalList").show();
$(".masker").show();
}
//关闭文档列表
_closeDocListHandler() {
$("#docModalList").hide();
$(".masker").hide();
}
//下一页
_nextHandler() {
loger.log('下一页', this.dynamicPPT.isNextAnimationComplete());
if (this.dynamicPPT && !this.dynamicPPT.isNextAnimationComplete()) {
//如果动态ppt的动画没有播放完成,需要切换动画
this.dynamicPPT.pptNextAnimationHandler();
} else {
//切换页面
if (this._currentDocId > 0 && this._currentPageNum < this._pageNum) {
let paramInfo = {
"itemIdx": this._currentDocId,
"curPageNo": this._currentPageNum + 1
};
xdysdk.api("sendDocumentSwitchPage", paramInfo);
}
}
}
//上一页
_prevHandler() {
loger.log('上一页', this.dynamicPPT.isPrevAnimationComplete());
if (this.dynamicPPT && !this.dynamicPPT.isPrevAnimationComplete()) {
//如果动态ppt的动画没有播放完成,需要切换动画
this.dynamicPPT.pptPrevAnimationHandler();
} else {
//切换页面
if (this._currentDocId > 0 && this._currentPageNum > 1) {
let paramInfo = {
"itemIdx": this._currentDocId,
"curPageNo": this._currentPageNum - 1
};
xdysdk.api("sendDocumentSwitchPage", paramInfo);
}
}
}
//显示默认模式
stopAndHide() {
this._closeDocListHandler();
if (this._docShowType == DOC_SHOW_FULL) {
return;
}
this._docShowType = DOC_SHOW_FULL;
this._changeDocShowBtns(this._docShowType);
this._fitInDocView(this._docShowType);
if (this._currentDocId > 0) {
this._sendDocumentCommand2sdk();
}
}
//切换文档显示模式
_fitInHandler(evt) {
//loger.log("切换文档显示模式", evt.target.className);
switch (evt.target.id) {
case "fitWidth":
if (this._docShowType == DOC_SHOW_WIDTH) {
return;
}
this._docShowType = DOC_SHOW_WIDTH;
this._changeDocShowBtns(this._docShowType);
break;
case "fitHeight":
if (this._docShowType == DOC_SHOW_HEIGHT) {
return;
}
this._docShowType = DOC_SHOW_HEIGHT;
this._changeDocShowBtns(this._docShowType);
break;
case "fitNormal":
if (this._docShowType == DOC_SHOW_FULL) {
return;
}
this._docShowType = DOC_SHOW_FULL;
this._changeDocShowBtns(this._docShowType);
break;
default:
break;
}
this._fitInDocView(this._docShowType);
if (this._currentDocId > 0) {
this._sendDocumentCommand2sdk();
}
}
//发送文档控制消息
_sendDocumentCommand2sdk() {
xdysdk.api("sendDocumentCommand", {
"itemIdx": this._currentDocId,
"showType": this._docShowType,
"curV": this.curV,//垂直方向的滚动条进度百分比 0-100
"curH": this.curH,//水平方向的滚动条进度百分比 0-100
"scale": 100//文档缩放百分比 0-100
});
}
_changeDocShowBtns(_showType) {
switch (_showType) {
case DOC_SHOW_WIDTH:
$('.fitWidth').css("color", "#3498db");
$('.fitHeight').css("color", "#ccc");
$('.fitNormal').css("color", "#ccc");
break;
case DOC_SHOW_HEIGHT:
$('.fitHeight').css("color", "#3498db");
$('.fitWidth').css("color", "#ccc");
$('.fitNormal').css("color", "#ccc");
break;
default :
$('.fitNormal').css("color", "#3498db");
$('.fitHeight').css("color", "#ccc");
$('.fitWidth').css("color", "#ccc");
break;
}
}
//适配文档显示,type是显示的类型(width-按宽度显示;height-按高度显示;full-完整显示)
_fitInDocView(_type) {
let docView = $(".docView")[0];
//let imgUrl=docView.src;
//let imgUrl="";
//loger.log("切换文档显示模式->", _type, this.currentImagePath);
if (docView && this.currentImagePath) {
$(".docView").attr('src', this.currentImagePath);
$(".docView").show();
} else {
let docBoxWidh = $(".docBox")[0].clientWidth;
let docBoxHeight = $(".docBox")[0].clientHeight;
//没有文档的时候,就按动态ppt的标注尺寸为准
let viewW = PPT_WIDTH;
let viewH = PPT_HEIGHT;
//loger.log("舞台尺寸->", docBoxWidh, docBoxHeight);
//设置适合的尺寸模型显示
let sizeObj;
if (this._docShowType == DOC_SHOW_WIDTH) {
sizeObj = ClassDataProxy.getFitInWidth(docBoxWidh, docBoxHeight, viewW, viewH);
this._showOverflow("y");
} else if (this._docShowType == DOC_SHOW_HEIGHT) {
sizeObj = ClassDataProxy.getFitInHeight(docBoxWidh, docBoxHeight, viewW, viewH);
this._showOverflow("x");
} else {
sizeObj = ClassDataProxy.getFitInFull(docBoxWidh, docBoxHeight, viewW, viewH);
this._hideOverflow();
}
if (sizeObj) {
//loger.log("设置图片显示", sizeObj);
let docView = $(".docView");
docView.width(sizeObj.w);
docView.height(sizeObj.h);
$(".docGroup").width(sizeObj.w);
$(".docGroup").height(sizeObj.h);
$(".docGroup").css("left", "0");
$(".docGroup").css("top", "0");
//水平居中显示
if (sizeObj.w < docBoxWidh) {
let leftMargin = (docBoxWidh - sizeObj.w) * 0.5;
$(".docGroup").css("left", "" + leftMargin + "px");
}
//垂直居中
if (sizeObj.h < docBoxHeight) {
let topMargin = (docBoxHeight - sizeObj.h) * 0.5;
$(".docGroup").css("top", "" + topMargin + "px");
}
this._emit(DocApe.DOC_IMAGE_LOAD, {"width": sizeObj.w, "height": sizeObj.h});
this.dynamicPPT.setPPTSize({"width": sizeObj.w, "height": sizeObj.h});
} else {
loger.warn("文档适配失败");
}
}
}
//文档图片加载完成
_onLoadImage(evt) {
let imagW = evt.currentTarget.naturalWidth;
let imagH = evt.currentTarget.naturalHeight;
let docBoxWidh = $(".docBox")[0].clientWidth;
let docBoxHeight = $(".docBox")[0].clientHeight;
//loger.log("加载图片完成->实际尺寸->", imagW, imagH);
//loger.log("舞台尺寸->", docBoxWidh, docBoxHeight);
//设置适合的尺寸模型显示
let sizeObj;
if (this._docShowType == DOC_SHOW_WIDTH) {
sizeObj = ClassDataProxy.getFitInWidth(docBoxWidh, docBoxHeight, imagW, imagH);
this._showOverflow("y");
} else if (this._docShowType == DOC_SHOW_HEIGHT) {
sizeObj = ClassDataProxy.getFitInHeight(docBoxWidh, docBoxHeight, imagW, imagH);
this._showOverflow("x");
} else {
sizeObj = ClassDataProxy.getFitInFull(docBoxWidh, docBoxHeight, imagW, imagH);
this._hideOverflow();
}
if (sizeObj) {
// loger.log("设置图片显示", sizeObj);
let docView = $(".docView");
docView.width(sizeObj.w);
docView.height(sizeObj.h);
$(".docGroup").width(sizeObj.w);
$(".docGroup").height(sizeObj.h);
$(".docGroup").css("left", "0");
$(".docGroup").css("top", "0");
//水平居中显示
if (sizeObj.w < docBoxWidh) {
let leftMargin = (docBoxWidh - sizeObj.w) * 0.5;
//loger.warn("left-----------------",leftMargin);
$(".docGroup").css("left", "" + leftMargin + "px");
}
//垂直居中
if (sizeObj.h < docBoxHeight) {
let topMargin = (docBoxHeight - sizeObj.h) * 0.5;
$(".docGroup").css("top", "" + topMargin + "px");
}
this._emit(DocApe.DOC_IMAGE_LOAD, {"width": sizeObj.w, "height": sizeObj.h});
this.dynamicPPT.setPPTSize({"width": sizeObj.w, "height": sizeObj.h});
} else {
loger.warn("文档适配失败");
}
}
//文档图片加载失败
_onLoadImageError(evt) {
if (!ClassDataProxy.isRecordPlayBack && this.currentImagePath) {
loger.warn("文档加载失败->", evt.currentTarget.alt, this.currentImagePath);
//ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.fileLoadingErr + "->" + evt.currentTarget.alt);
}
}
//上传文件
_uploadFile(evt) {
let fileItem = document.getElementById('docFileBtn').files[0];
if (!fileItem) {
loger.log("没有选择文件");
return;
}
this._closeDocListHandler();
let fileStr = fileItem.name;
if(fileStr){
fileStr=fileStr.toLowerCase();
}
//let fileValue = fileStr.split('.')[1];
if (fileStr.lastIndexOf(".zip")>=0) {
this._uploadPPT(fileItem, evt);
}
else {
loger.log("文件名:" + fileItem.name + "->文件类型:" + fileItem.type);
//目前最大支持50M 格式为jpg png pdf docx pptx xlsx
//判断文件的大小
if (fileItem.size > 52428800) {
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.fileError);
return;
}
let fileName = fileItem.name;
if(fileName){
fileName = fileName.toLowerCase();
}
//判断选择的文件类型
if (fileName.lastIndexOf('.jpg') < 0 &&
fileName.lastIndexOf('.png') < 0 &&
fileName.lastIndexOf('.pdf') < 0 &&
fileName.lastIndexOf('.doc') < 0 &&
fileName.lastIndexOf('.ppt') < 0 &&
fileName.lastIndexOf('.xls') < 0) {
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.layoutCont);
return;
}
if (!ClassDataProxy.DOCServerIP) {
loger.warn("文档服务器地址无效,无法上传文件!");
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.serverError);
return
}
//上传时动画效果
UIControlApe.showLoadingMask();
//上传过程中 上传按钮不可点击
//$('.docUploadForbid').show();
UIControlApe.disEnabledDocBar();
UIControlApe.disEnabledMediaBar();
let fd = new FormData();
fd.append("fileToUpload", fileItem);
fd.append("siteID", ClassDataProxy.siteId); //站点
fd.append("convertTools", "msoffice"); //pptflash 仅限动态转ppt msoffice 其它类型
fd.append("meetingid", String(ClassDataProxy.classId)); //课堂号
fd.append("timestamp", String(ClassDataProxy.creatTimestamp())); //时间戳
fd.append("createUserName", String(ClassDataProxy.userName)); //上传人姓名
fd.append("createUserID", String(ClassDataProxy.nodeId)); //上传人ID
fd.append("modifyDate", ClassDataProxy.creatTimestampStr()); //上传时间
/*let ipport = ClassDataProxy.DOCServerIP;
if (ClassDataProxy.DOCServerPort) {
ipport = ipport + ":" + ClassDataProxy.DOCServerPort;
}
let docUrl = `http://${ipport}/DocSharing/fileUploadJson`;*/
let ipport=ClassDataProxy.DOCServerIP;
if( ClassDataProxy.DOCServerPort){
ipport=ipport+":"+ClassDataProxy.DOCServerPort;
}
let docUrl= `${ClassDataProxy.locationProtocol+ipport}/DocSharing/fileUploadJson`;
$.ajax({
type: "POST",
url: docUrl,
processData: false,
contentType: false,
data: fd,
xhr: function () {
let xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener("progress", function (evt) {
let loaded = evt.loaded; //已经上传大小情况
let tot = evt.total; //附件总大小
let per = Math.floor(100 * loaded / tot); //已经上传的百分比
UIControlApe.updataLoadingMaskProgress(per);
}, false);
return xhr;
}
},
success: function (data) {
//loger.log("文档服务器返回的文档数据-.", data);
UIControlApe.hideLoadingMask();
UIControlApe.enabledDocBar();
UIControlApe.enabledMediaBar();
this._uploadFileSuccess(data);
$("#docFileBtn").val('')
}.bind(this),
error: function (data) {
UIControlApe.hideLoadingMask();
UIControlApe.enabledDocBar();
UIControlApe.enabledMediaBar();
loger.warn(name + "->上传文件失败", data);
ErrorApe.showError(ErrorApe.TYPE_3, name + "->" + ClassDataProxy.localConfig.uploaDocumentErr);
$("#docFileBtn").val('')
}
});
}
}
//上传ppt的zip
_uploadPPT(fileItem, evt) {
loger.log("文件名:" + fileItem.name + "->文件类型:" + fileItem.type);
//目前最大支持50M 格式为jpg png pdf docx pptx xlsx
//判断文件的大小
if (fileItem.size > 52428800) {
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.fileError);
return;
}
let fileName = fileItem.name.toLowerCase();
//判断选择的文件类型
if (fileName.lastIndexOf('.zip') < 0) {
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.fileFormatError);
return;
}
if (!ClassDataProxy.DOCServerIP) {
loger.warn("文档服务器地址无效,无法上传文件!");
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.serverError);
return
}
//上传时动画效果
UIControlApe.showLoadingMask();
UIControlApe.disEnabledDocBar();
UIControlApe.disEnabledMediaBar();
//上传过程中 上传按钮不可点击
//$('.docUploadForbid').show();
let fd = new FormData();
fd.append("fileToUpload", fileItem);
fd.append("classId", String(ClassDataProxy.classId)); //课堂号
fd.append("siteID", ClassDataProxy.siteId); //站点
fd.append("createUserID", String(ClassDataProxy.nodeId)); //上传人ID
fd.append("createUserName", String(ClassDataProxy.userName)); //上传人姓名
/* let ipport = ClassDataProxy.DOCServerIP;
if (ClassDataProxy.DOCServerPort) {
ipport = ipport + ":" + ClassDataProxy.DOCServerPort;
}
let pptUrl = `http://${ipport}/DocSharing/zipUpload`;*/
let ipport=ClassDataProxy.DOCServerIP;
if( ClassDataProxy.DOCServerPort){
ipport=ipport+":"+ClassDataProxy.DOCServerPort;
}
let pptUrl= `${ClassDataProxy.locationProtocol+ipport}/DocSharing/zipUpload`;
$.ajax({
type: "POST",
url: pptUrl,
processData: false,
contentType: false,
data: fd,
xhr: function () {
let xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener("progress", function (evt) {
let loaded = evt.loaded; //已经上传大小情况
let tot = evt.total; //附件总大小
let per = Math.floor(100 * loaded / tot); //已经上传的百分比
UIControlApe.updataLoadingMaskProgress(per);
}, false);
return xhr;
}
},
success: function (data) {
//loger.log("文档服务器返回的文档数据-.", data);
UIControlApe.hideLoadingMask();
UIControlApe.enabledDocBar();
UIControlApe.enabledMediaBar();
this._uploadpptSuccess(data);
$("#docFileBtn").val('')
}.bind(this),
error: function (data) {
UIControlApe.hideLoadingMask();
UIControlApe.enabledDocBar();
UIControlApe.enabledMediaBar();
loger.warn(name + "->上传文件失败", data);
ErrorApe.showError(ErrorApe.TYPE_3, name + "" + ClassDataProxy.localConfig.uploaDocumentErr);
$("#docFileBtn").val('')
}
});
}
//上传的ppt的zip成功
_uploadpptSuccess(msg) {
loger.log("服务器返回的zip信息->", msg);
if (msg.docId) {
console.log("msg", msg);
$("#frame").attr("src", msg.filePath);
let fileInfo = {};
fileInfo.pageNum = msg.imgSize;// 文档的总页数
fileInfo.fileName = msg.fileName;//文档名字
fileInfo.fileType = msg.fileType; // 文档的原始类型(上传时的类型)
fileInfo.relativeUrl = msg.relativeLocation; //文档相对地址
let urlPath = msg.filePath + 'l';
urlPath = urlPath.replace('.htmll', '.html');
fileInfo.url = urlPath; //文档绝对地址 默认值: null
fileInfo.docId = msg.docId; //文档在数据库中的唯一id标识 默认值: null
fileInfo.visible = false; // 是否显示 默认值: false
loger.log("同步上传的文档消息给sdk", fileInfo);
xdysdk.api("sendDocumentUpload", fileInfo);
} else {
loger.warn("服务器返回的zip文件信息->不能同步-->docId无效", msg.docId);
ErrorApe.showError(ErrorApe.TYPE_3, name + "" + ClassDataProxy.localConfig.uploaDocumentErr);
}
}
//将上传文件的信息,传递给底层
_uploadFileSuccess(msg) {
loger.log("服务器返回的文档信息->", msg);
if (msg.docId && msg.flag == 0) {
let fileInfo = {};
fileInfo.pageNum = msg.imgSize;// 文档的总页数
fileInfo.fileName = msg.fileName;//文档名字
fileInfo.fileType = msg.fileType; // 文档的原始类型(上传时的类型)
fileInfo.relativeUrl = msg.relativeLocation; //文档相对地址
fileInfo.url = msg.filePath; //文档绝对地址 默认值: null
fileInfo.docId = msg.docId; //文档在数据库中的唯一id标识 默认值: null
fileInfo.visible = false; // 是否显示 默认值: false
fileInfo.dynamicTS = msg.dynamicTransferStatic; //是否动态转换 //文档上传后返回值中的字段dynamicTransferStatic 默认值: 0
//loger.log("同步上传的文档消息给sdk", fileInfo);
xdysdk.api("sendDocumentUpload", fileInfo);
} else {
loger.warn("服务器返回的文件信息->不能同步-->docId无效", msg.docId);
ErrorApe.showError(ErrorApe.TYPE_3, ClassDataProxy.localConfig.uploaDocumentErr);
}
}
//点击列表中切换文档
_switchDcoBtnHandler(evt) {
loger.log("_switchDcoBtnHandler---->", evt.target.id);
this._switchDcoHandler(evt.target.id)
}
//切换文档,把要显示的文档数据发送给SDK
_switchDcoHandler(_itemIdx) {
loger.log("_switchDcoHandler---->", _itemIdx);
let docItem = this._docList[_itemIdx];
if (docItem) {
let paramInfo = {
"itemIdx": parseInt(_itemIdx),
"visible": true
};
xdysdk.api("sendDocumentSwitchDoc", paramInfo);
this._closeDocListHandler();
} else {
loger.log("_switchDcoHandler---->文档不存在");
}
}
//删除文档鼠标事件
_deleteDcoHandler(evt) {
loger.log("_deleteDcoHandler---->", evt.target.id);
let docItem = this._docList[parseInt(evt.target.id)];
if (docItem) {
let paramInfo = {
"itemIdx": docItem.itemIdx,
"docId": docItem.docId,
"classId": ClassDataProxy.classId //课堂号
};
xdysdk.api("sendDocumentDelete", paramInfo);
} else {
loger.log("_deleteDcoHandler---->文档不存在");
}
}
//获取文档图片序列
_getDocFullAddress(_data) {
loger.log("获取文档显示地址---->", _data);
let paramInfo = {
"itemIdx": _data.itemIdx,
"url": _data.url
};
let result = xdysdk.api("getDocFullAddress", paramInfo);
loger.log("获取文档显示地址-->返回->", result);
if (result.code == 0) {
return result.docFullAddress.images;
}
return [];
}
_particularPage() {
let pageNo = $('#pageNo');
if (!pageNo || !pageNo.val()) {
return;
}
let page = parseInt(pageNo.val());
if (page) {
if (page > this._pageNum) {
page = this._pageNum;
}
if (page <= 0) {
page = 1;
}
pageNo.val(page);
let paramInfo = {
"itemIdx": this._currentDocId,
"curPageNo": page
};
xdysdk.api("sendDocumentSwitchPage", paramInfo);
$("#pageNo")[0].value = "";
$("#pageNo").blur();
}
}
//创建列表元素
_creatListItemDiv(_id, _fileName, _owner) {
let div = document.createElement("div");
div.id = "doc_" + _id;
//文件id
let ico = document.createElement("label");
ico.innerHTML = "&#xe639;";
ico.className = "iconfont";
div.appendChild(ico);
//文件名称
let nameDiv = document.createElement("label");
nameDiv.innerText = "" + _fileName;
nameDiv.title = "" + _fileName;
nameDiv.onclick = this._switchDcoBtnHandler.bind(this);
nameDiv.id = _id;
div.appendChild(nameDiv);
//删除按钮
let deleteBtn = document.createElement("label");
deleteBtn.type = "button";
// deleteBtn.value = "删除";
deleteBtn.id = _id;
deleteBtn.innerHTML = "&#xe673;";
deleteBtn.className = "iconfont";
deleteBtn.onclick = this._deleteDcoHandler.bind(this);
div.appendChild(deleteBtn);
return div;
}
}
DocApe.prototype.DOC_IMAGE_LOAD = DocApe.DOC_IMAGE_LOAD = "doc_image_load";
DocApe.prototype.SCENE_DOC_CHANGE = DocApe.SCENE_DOC_CHANGE = "scene_doc_change";
export default DocApe;
//*
// 白板标注工具栏
// */
import Emiter from "Emiter";
import Loger from "Loger";
import $ from "jquery";
import xdysdk from "libs/xdysdk";
import ClassDataProxy from "proxy/ClassDataProxy";
let loger = Loger.getLoger('PC-DrawTool');
class DrawTool extends Emiter {
constructor() {
super();
this.isShow = false;
ClassDataProxy.isDraw = false;
this.addEvent();
this.init();
}
init() {
//布局
$(".foldDrawTool").on("click", this._controlDrawToolVisible.bind(this));
//UI按钮点击事件
$(".toolColor").on("mouseleave", this._showColorNone.bind(this));
// $(".showColor").on("mouseleave", this._showColorNone.bind(this));
$(".showColor").on("mouseenter", this._showColorBlock.bind(this));
//形状列表显示
$(".toolForm").on("mouseleave", this._showFormNone.bind(this));
$("#showForm").on("mouseenter", this._showFormBlock.bind(this));
//点击形状按钮
$('#showForm').on('click',this._showFormBlock.bind(this));
$('#curveBrush').on('click',this._formHandler.bind(this));
$('#straightBrush').on('click',this._formHandler.bind(this));
$('#squareBrush').on('click',this._formHandler.bind(this));
$('#circleBrush').on('click',this._formHandler.bind(this));
$('#customBrush').on('click',this._formHandler.bind(this));
$(".showColor").on("click", this._showColorBlock.bind(this));
$(".redColor").on("click", this._colorHandler.bind(this));
$(".blueColor").on("click", this._colorHandler.bind(this));
$(".purpleColor").on("click", this._colorHandler.bind(this));
$(".yellowColor").on("click", this._colorHandler.bind(this));
$(".pencil").on("click", this._pencilHandler.bind(this));
$(".rescind").on("click", this._rescindHandler.bind(this));//撤销
$(".clearContent").on("click", this._clearHandler.bind(this));//删除
//点击其他区域后颜色板隐藏
// $(".middle").on("click",this._hideColorTool.bind(this));
$(".left").on("click",this._hideColorTool.bind(this));
$(".header").on("click",this._hideColorTool.bind(this));
$(".right").on("click",this._hideColorTool.bind(this));
$(".docBox").on("click",this._hideColorTool.bind(this));
//老是断控制学生端画笔
$('#controlBrush').on('click',this._controlBrushHandler.bind(this));
}
addEvent() {
xdysdk.on("class_join_success", this._classJoinSuccessHandler.bind(this));
xdysdk.on("class_insert_roster", this._insertRosterHandler.bind(this)); //人员进入
xdysdk.on("class_update_status", this._classUpdateHandler.bind(this));//会议状态更新
}
_classJoinSuccessHandler(_data) {
if (_data.userRole == ClassDataProxy.USER_NOTMAL) {
// $(".foldDrawTool").hide();
// $(".drawTool").hide();
this.isShow = true;
} else {
$(".foldDrawTool").show();
$(".drawTool").show();
this.isShow = true;
}
}
_insertRosterHandler(_data){
if(_data){
if(ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL){
if(!ClassDataProxy.isEnableDraw){
//隐藏学生端画笔
this._hideBrushSwitch();
}
}
}
}
_classUpdateHandler(_data){
if(_data){
//控制学生端画笔是否可以绘画
ClassDataProxy.isEnableDraw = _data.isEnableDraw || false;
this._checkBrushSwitch();
}
}
_checkBrushSwitch(){
this._brushSwitchHandler();
}
//老是断控制学生端画笔
_controlBrushHandler(evt){
if(ClassDataProxy.isEnableDraw == true){
ClassDataProxy.isEnableDraw = false;
xdysdk.api("changeDrawStatus",{"isEnableDraw":false});
}else{
ClassDataProxy.isEnableDraw = true;
xdysdk.api("changeDrawStatus",{"isEnableDraw":true})
}
}
//学生端画笔开关
_brushSwitchHandler(){
if(ClassDataProxy.isEnableDraw == true){
if(ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL){
//显示学生端画笔
this._showBrushSwitch();
}
//更改老师端状态
if(ClassDataProxy.userRole == ClassDataProxy.USER_HOST){
$('.controlBrush').addClass('controlBrushClick');
}
}else{
//隐藏学生端画笔
if(ClassDataProxy.userRole == ClassDataProxy.USER_NOTMAL){
this._hideBrushSwitch();
//学生端是否可以画图
ClassDataProxy.isDraw = false;
}
//更改老师端状态
if(ClassDataProxy.userRole == ClassDataProxy.USER_HOST){
$('.controlBrush').removeClass('controlBrushClick');
}
}
}
//显示学生端画笔
_showBrushSwitch(){
$('.foldDrawToolOut').show();
$('.foldDrawTool').show();
$(".drawTool").show();
$(".drawTool").css("height", "160px");
}
//隐藏学生端画笔
_hideBrushSwitch(){
$('.foldDrawToolOut').hide();
$('.foldDrawTool').hide();
$(".drawTool").hide();
}
_pencilHandler() {
if(ClassDataProxy.isLaser==true){
ClassDataProxy.isLaser=false;
let paramInfo = {
"pointGroup": [],//有多个坐标点组成
"duration":0 //多长时间发一次数据
};
xdysdk.api("sendInsertCursor", paramInfo);
$(".canvasContent").css("cursor", "default");
}
$(".laserBoard").css("z-index","-1");
$(".toolColor").css("display", "none");
ClassDataProxy.isDraw = !ClassDataProxy.isDraw;
this._emit(DrawTool.DRAW_TOOL_CHANGE, {"action": "pencil", "isDraw": ClassDataProxy.isDraw});
if (ClassDataProxy.isDraw) {
$(".canvasContent").css({"cursor":"url(images/tool/penciling.png),crosshair"});
} else {
$(".canvasContent").css("cursor", "default");
}
}
_rescindHandler() {
$(".toolColor").css("display", "none");
this._emit(DrawTool.DRAW_TOOL_CHANGE, {"action": "rescind"});
}
_clearHandler() {
$(".toolColor").css("display", "none");
this._emit(DrawTool.DRAW_TOOL_CHANGE, {"action": "clear"});
}
_colorHandler(evt) {
$(".toolColor").css("display","none");
loger.log(evt.target.id, evt.target.title);
let color = evt.target.title;
this._emit(DrawTool.DRAW_TOOL_CHANGE, {"action": "changeColor", "color": color});
let showColor = document.getElementById('showColor');
switch (evt.target.id) {
case "redColor":
showColor.style.background = 'url("images/colorRed.png") no-repeat';
$(".showColor").unbind("click");
this._showColorNone();
this._showFormNone();
break;
case "blueColor":
showColor.style.background = 'url("images/colorBlue.png") no-repeat';
$(".showColor").unbind("click");
this._showColorNone();
this._showFormNone();
break;
case "purpleColor":
showColor.style.background = 'url("images/colorPurple.png") no-repeat';
$(".showColor").unbind("click");
this._showColorNone();
this._showFormNone();
break;
case "yellowColor":
showColor.style.background = 'url("images/colorYellow.png") no-repeat';
$(".showColor").unbind("click");
this._showColorNone();
this._showFormNone();
break;
default:
break
}
}
_formHandler(){
$(".toolForm").css("display","none");
$("#showForm").unbind("click");
loger.log('点击隐藏形状工具列表');
}
_showColorBlock() {
$(".toolColor").css("display", "block");
$(".toolColor").css("z-index", 0);
$(".toolForm").css("display", "none");
$(".toolForm").css("z-index", 0);
}
_showColorNone() {
$(".toolColor").css("display", "none");
$(".toolColor").css("z-index", 0);
}
_showFormBlock(){
$(".toolForm").css("display", "block");
$(".toolForm").css("z-index", 2);
$(".toolColor").css("display", "none");
$(".toolColor").css("z-index", 0);
}
_showFormNone(){
$(".toolForm").css("display", "none");
$(".toolForm").css("z-index", 0);
}
_controlDrawToolVisible() {
// if(ClassDataProxy.isEnableDraw == true){
if (this.isShow) {
$(".drawTool").hide();
$(".arrowTop").hide();
$(".arrowBottom").show();
} else {
$(".drawTool").show();
$(".arrowTop").show();
$(".arrowBottom").hide();
}
this.isShow = !this.isShow;
// }
}
_hideColorTool(){
$(".toolColor").css("display", "none");
$(".toolForm").css("display", "none");
}
}
DrawTool.prototype.DRAW_TOOL_CHANGE = DrawTool.DRAW_TOOL_CHANGE = "draw_tool_change";
export default DrawTool;
\ No newline at end of file
/*
*
* 动态PPT 尺寸1:(高:宽 540/864 =250/400 = 0.625) 尺寸2: 720 540 4;3
*
* */
import Emiter from "Emiter";
import Loger from "Loger";
import $ from "jquery";
import xdysdk from "libs/xdysdk";
import ClassDataProxy from "proxy/ClassDataProxy";
let loger = Loger.getLoger('PC-DynamicPPT');
window.ispringPresentationConnector ={};
window.pptPlayer;
class DynamicPPT extends Emiter {
constructor() {
super();
this.currentAnimationStep=1;//默人动画页数是1
this.animationStepCount=1;//默认动画总页数时1
this.currenSlideIndex=0;//当前显示的页码 从0开始
this.pptiframeSrc='';//当前页地址,ip地址换成允许跨域的ip
this.pptData=null;
this.changePageTimer=0;
this.addEvent();
}
addEvent(){
//监听动态ppt加载
$("#framePPT").on('load', this._onLoadPPT.bind(this));
$("#framePPT").on('error', this._onLoadPPTError.bind(this));
//上一步下一步动画
$(".pptNextStep").hide();
$(".pptPrevStep").hide();
$(".pptNextStep").on("click", this.pptNextAnimationHandler.bind(this));
$(".pptPrevStep").on("click", this.pptPrevAnimationHandler.bind(this));
}
//更新ppt,显示和删除都用这个接口 _data为null的时候就是删除
updataPPT(_data){
console.log('更新ppt数据',_data);
if(_data){
this.pptData=_data;
//有数据,并且是可见,需要更新操作数据
if (_data.visible == true) {
this.showPPT();
//获取数据中的html地址,然后转换为允许跨域访问的地址
let iframeSrc =_data.html||"";
//替换IP地址,解决跨域问题,后续服务器会解决跨域,不需要再替换
/* iframeSrc=iframeSrc.replace('http://','');
let index=iframeSrc.indexOf('/');
let iframeLastSrc=ifreamDocIp+iframeSrc.substr(index);*/
//如果是本地测试就用本地文件地址,否则就用线上地址
let url = encodeURI(window.location.href);
let index=url.indexOf('localhost:');
if(index<0){
index=url.indexOf('127.0.0.1');
}
if(index>=0){
iframeSrc='./ppt0516/index.html';
loger.warn('使用本地的动态ppt测试',iframeSrc);
}
if(!iframeSrc){
loger.warn('ppt地址转换失败');
return;
}
if(this.pptiframeSrc==iframeSrc){
//文档已经存在
this.changePage();
}else {
//文档不存在
this._loadIframSrc(iframeSrc);
}
}else {
this.hidePPT();
}
}else {
//没有数据,清除
this.pptData=null;
this.hidePPT();
this.clearPPT();
}
}
//显示ppt
showPPT(){
//loger.log("显示ppt");
$("#framePPT").show();
}
//隐藏ppt
hidePPT(){
// loger.log("隐藏ppt");
$("#framePPT").hide();
$(".pptPrevStep").hide();
$(".pptNextStep").hide();
$("#framePPT").attr('src', "");
}
//设置大小
setPPTSize(sizeObj){
//if(sizeObj) {
// loger.log("设置ppt显示大小", sizeObj);
//}
}
//清除ppt数据
clearPPT(){
//loger.log("清除ppt数据");
clearTimeout( this.changePageTimer);
this.pptData=null;
this.pptiframeSrc='';
this.currentAnimationStep=1;
this.animationStepCount=1;
this.currenSlideIndex=0;
window.ispringPresentationConnector ={};
window.pptPlayer=null;
}
// 加载动态ppt地址
_loadIframSrc(_iframeLastSrc){
let isFirstLoad=true;//每次更地址都会重置,如果是重加载,加载完成后需要切换页面
let _this=this;
window.ispringPresentationConnector.register = function (player){
window.pptPlayer=player;
console.log('ispringPresentationConnector');
window.pptPlayer.view().playbackController().slideChangeEvent().addHandler(function(slideIndex) {
console.log( "动态ppt当前index: " + (slideIndex ));
_this.currenSlideIndex=slideIndex;
_this.animationStepCount=window.pptPlayer.view().playbackController().currentSlide().animationSteps().count();
//第一次加载完成的时候切换一次
if(isFirstLoad){
isFirstLoad=false;
_this.changePage(1000);
}
});
window.pptPlayer.view().playbackController().stepChangeEvent().addHandler(function(stepIndex){
_this.currentAnimationStep=stepIndex+1||1;
_this.animationStepCount=window.pptPlayer.view().playbackController().currentSlide().animationSteps().count();
console.log("动态ppt当前 step: " + stepIndex,' this.currentAnimationStep:'+ _this.currentAnimationStep);
});
window.pptPlayer.view().playbackController().clock.tickEvent().addHandler(function(theClock){
var ts = theClock.timestamp();
window.console.log("Tick. Slide:", ts.slideIndex(), "; step: ", ts.stepIndex(), "; timeOffset: ", ts.timeOffset());
});
}
//加完监听之后开始加载网页
this.pptiframeSrc=_iframeLastSrc;
console.log("pptiframeSrc",this.pptiframeSrc);
$("#framePPT").attr("src",this.pptiframeSrc);
}
changePage(_deley){
console.log("切换PPT页码---->",this.pptData);
if(!this.pptData||!window.pptPlayer){
console.warn("切换PPT页码-->_data数据不存在");
return;
}
if(this.pptData.curPageNo!=(this.currenSlideIndex+1)){
clearTimeout( this.changePageTimer);
if(_deley){
let _this=this;
this.changePageTimer=setTimeout(function(){
console.log(_deley,"延迟切换PPT页码---->",_this.pptData.curPageNo);
this.currentAnimationStep=1;//默人动画页数是1
this.animationStepCount=1;//默认动画总页数时1
window.pptPlayer.view().playbackController().gotoSlide((_this.pptData.curPageNo-1),false);
setTimeout(function () {
let curAnimationStep=_this.pptData.animationStep;
for(let i=0;i<(curAnimationStep-1);i++){
window.pptPlayer.view().playbackController().gotoNextStep();
}
},1000);
},_deley)
}else {
console.log("切换PPT页码---->",this.pptData.curPageNo);
this.currentAnimationStep=1;//默人动画页数是1
this.animationStepCount=1;//默认动画总页数时1
window.pptPlayer.view().playbackController().gotoSlide((this.pptData.curPageNo-1),false);
}
}else {
//页数切换完成,切换动画步骤
this._changeAnimationStep();
}
}
_changeAnimationStep(){
console.log("切换动画步数---->",this.currentAnimationStep,'-->',this.pptData.animationStep);
if(!this.pptData||!window.pptPlayer){
console.warn("切换PPT动画步骤-->_data数据不存在");
return;
}
if(this.animationStepCount<2){
console.log("当前页码的动画步数为->"+this.animationStepCount);
return;
}
if(this.pptData.animationStep>this.currentAnimationStep){
console.log("切换动画步数---->下一步")
// this.currentAnimationStep = this.pptData.animationStep;
for(let i=this.currentAnimationStep;i<this.pptData.animationStep;i++){
try{
window.pptPlayer.view().playbackController().gotoNextStep();
}catch (err){
console.warn("切换动画步数---->下一步-失败",err);
}
}
}else if(this.pptData.animationStep<this.currentAnimationStep){
console.log("切换动画步数---->上一步");
window.pptPlayer.view().playbackController().gotoPreviousStep();
for(let i=this.pptData.animationStep;i<this.currentAnimationStep;i++){
try{
window.pptPlayer.view().playbackController().gotoPreviousStep();
}catch (err){
console.warn("切换动画步数---->上一步-失败",err);
}
}
}else {
console.log("切换动画步数---->完成");
}
}
//ppt加载完成
_onLoadPPT(evt) {
console.log("ppt加载完成---->");
}
//ppt加载失败
_onLoadPPTError(evt){
console.warn("ppt加载失败---->",evt);
}
isNextAnimationComplete(){
if(this.animationStepCount>1&&this.animationStepCount!=this.currentAnimationStep){
this.currentAnimationStep = this.pptData.animationStep;
console.warn("还有动画需要操作-.不能翻页");
return false;
}
console.warn("没有动画需要操作-.可以翻页");
return true;
}
isPrevAnimationComplete(){
if(this.animationStepCount>1&&this.currentAnimationStep>2){
console.warn("还有动画需要操作-.不能翻页");
return false;
}
console.warn("没有动画需要操作-.可以翻页");
return true;
}
//下一步动画
pptNextAnimationHandler(){
if(!this.pptData||!window.pptPlayer){
console.warn("下一步动画---->数据无效");
return;
}
xdysdk.api("sendDocumentSwitchAnimation",{"step":1});
}
//上一步动画
pptPrevAnimationHandler(){
if(!this.pptData||!window.pptPlayer){
console.warn("下一步动画---->数据无效");
return;
}
xdysdk.api("sendDocumentSwitchAnimation",{"step":-1});
}
}
DynamicPPT.prototype.SET_PPT_CHANGE = DynamicPPT.SET_PPT_CHANGE = "set_ppt_change";
export default DynamicPPT;
... ... @@ -4,7 +4,6 @@
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
let loger = Loger.getLoger('PC-ErrorApe');
... ...
... ... @@ -4,12 +4,9 @@
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";
import MessageTypes from "../MessageTypes";
const classifyList = `<div class="classifyList {_classifyListR}" id="{_id}">
<img class="curriculumListImg" src="{_msgImg}" alt="">
<p class="curriculumListTit">{_classroomTitle}</p>
... ... @@ -44,7 +41,6 @@ class HomeApe extends Ape {
isLocalStorage(){
if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_0 || ClassDataProxy.userType == ClassDataProxy.USER_TYPE_8){
this.detailPage();
console.log('学生',111111111)
}
}
_judgeListPlace(){
... ... @@ -57,13 +53,12 @@ class HomeApe extends Ape {
}
}
_lanclassBtnHandler(evt){
loger.log('首页',ClassDataProxy.userType)
$(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){
if( ClassDataProxy.userType== ClassDataProxy.USER_TYPE_8 || ClassDataProxy.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});
}else if(ClassDataProxy.userType == ClassDataProxy.USER_TYPE_1){
this._emit(MessageTypes.HOME_SKIP,{userType:ClassDataProxy.userType});
}
}
detailPage(){
... ... @@ -110,6 +105,7 @@ class HomeApe extends Ape {
studentClick(){
$('#slideshow').show();
$('#defaultBox').show();
$('.curriculumBox').show();
$('#classifyListBox').hide();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
... ... @@ -117,6 +113,7 @@ class HomeApe extends Ape {
teacher(){
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#classifyListBox').show();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
... ...
... ... @@ -4,9 +4,6 @@
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";
let loger = Loger.getLoger('PC-LanclassApe');
... ... @@ -47,6 +44,7 @@ class LanclassApe extends Ape {
$('#classifyListContent').find('.classifyList').eq(i==3).addClass('classifyListR');
}
_lanclassBtnHandler(evt){
loger.log('直播',ClassDataProxy.userType)
let _ele = $(evt.target);
if(_ele.attr('data')){
$('.header_listMsg').eq(_ele.attr('data')).addClass('header_listMsgCheck').siblings().removeClass('header_listMsgCheck');
... ... @@ -54,6 +52,7 @@ class LanclassApe extends Ape {
$(evt.target).addClass('header_listMsgCheck').siblings().removeClass('header_listMsgCheck');
$('#slideshow').hide();
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#classifyListBox').show();
$('#teacherDetailBox').hide();
$('#lanclassBox').hide();
... ...
//*
// 激光笔模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
// import DrawTool from "./DrawTool";
let loger = Loger.getLoger('PC-LaserPen');
// let _drawTool;
class LaserPen extends Ape {
constructor() {
super();
ClassDataProxy.isLaser = false;
this.laserPenInfo;
this.laserBoardContent;
this.laserBoardWidth=0;
this.laserBoardHeight=0;
this.scroolTop = 0;
this.scroolLeft = 0;
this.laserBoardTop = 0;
this.laserBoardLeft = 0;
this.laserGrou=[];
this.init();
this.addEvent();
}
init(){
this.laserBoardContent = $(".laserBoard");
// _drawTool=new DrawTool();
}
addEvent(){
$(".laserBoard").on('mousemove', this._laserMoveHandler.bind(this));
xdysdk.on("cursor_update", this._laserUpdateHanlder.bind(this));
$(".laserPen").on("click", this._laserPenHandler.bind(this));//激光笔
}
setCanvasSize(_data) {
if (this.laserBoardContent) {
//文档的尺寸已经更改,需要更新laserBoard大小
this.laserBoardWidth = _data.width;
this.laserBoardHeight = _data.height;
this.laserBoardContent[0].width = this.laserBoardWidth;
this.laserBoardContent[0].height = this.laserBoardHeight;
this.laserBoardTop = this.laserBoardContent.offset().top - this.scroolTop;
this.laserBoardLeft = this.laserBoardContent.offset().left - this.scroolLeft;
this._startLaserDraw(this.laserreceiveData);
}
}
_laserUpdateHanlder(_data){
if(_data.duration!==0){
if(ClassDataProxy.userRole==ClassDataProxy.USER_NOTMAL||ClassDataProxy.userRole==ClassDataProxy.USER_INVISIBLE){
$(".laserBoard").css("z-index","1");
$(".laserRed").show();
//console.log("1111111111",$(".laserBoard").css("z-index")==1);
//console.log("2222222222",ClassDataProxy.isDraw==true);
//console.log("zzzzzzzzzz",$(".laserBoard").css("z-index")==1&&ClassDataProxy.isDraw==true);
if( $(".laserBoard").css("z-index")==1&&ClassDataProxy.isDraw==true){
$(".pencil").click(function () {
$(".laserBoard").css("z-index","-1");
ClassDataProxy.isDraw=true
$(".canvasContent").css("cursor","url(images/tool/penciling.png),crosshair");
// _drawTool._pencilHandler();
})
}
}
// console.log("接收激光笔数据===",_data);
let duration=(_data.duration)*1000;
// clearTimeout(durId);
let that=this;
let laserannotaionItems = _data.pointGroup;
//清除重绘制数据
that.laserreceiveData = [];
//本地储存一份数据
if (laserannotaionItems && laserannotaionItems.length > 0) {
for (let i = 0; i < laserannotaionItems.length; i++) {
that.laserreceiveData.push(laserannotaionItems[i]);
}
}
//绘制全部数据
that._startLaserDraw(laserannotaionItems);
}
else if (_data.duration==0){
$(".laserBoard").css("z-index","-1");
$(".laserRed").hide();
}
}
_startLaserDraw(_data){
if (_data && _data.length > 0) {
for (let i = 0; i < _data.length; i++) {
let item = _data[i];
this._drawLaser(item);
}
}
}
_drawLaser(_data){
let pointGroup = _data;
if (pointGroup) {
let point = this.xyFromPer(pointGroup.w, pointGroup.h);
// $(".laserRed").show();
$(".laserRed").css({
left:point.x,
top:point.y
})
}
}
_laserPenHandler(){
if(ClassDataProxy.isDraw==true){
ClassDataProxy.isDraw=false;
}
$(".toolColor").css("display", "none");
$(".laserBoard").css("z-index","1");
ClassDataProxy.isLaser = !ClassDataProxy.isLaser;
if (ClassDataProxy.isLaser) {
// $(".laserRed").show();
$(".laserBoard").css({"cursor":"url(images/tool/pen.png),crosshair"});
} else {
$(".laserBoard").css("cursor", "default");
$(".canvasContent").css("cursor", "default");
let paramInfo = {
"pointGroup": [],//有多个坐标点组成
"duration":0 //多长时间发一次数据
};
xdysdk.api("sendInsertCursor", paramInfo);
}
this.laserPenInfo={
"action": "laserPen", "isLaser": ClassDataProxy.isLaser
};
this._laserPenChangeHandler(this.laserPenInfo);
}
_laserPenChangeHandler(_data){
switch (_data.action) {
case "laserPen":
//激光笔
ClassDataProxy.isLaser = _data.isLaser;
break;
default :
break
}
}
_laserMoveHandler(evt){
this.laserGrou=[];
if (ClassDataProxy.isLaser){
let toX = evt.clientX - this.laserBoardLeft;
let toY = evt.clientY - this.laserBoardTop;
this.laserGrou.push(this.xyToPer(Math.round(toX), Math.round(toY)));
let that=this;
that._sendLaser();
}
}
_sendLaser(){
if (this.laserGrou.length >= 1) {
let paramInfo = {
"pointGroup": this.laserGrou,//有多个坐标点组成
"duration":3 //多长时间发一次数据
};
xdysdk.api("sendInsertCursor", paramInfo);
this.laserGrou=[];
}
}
//把X Y坐标转换为相对laserBoard宽度的百分比
xyToPer(x, y) {
let recordPencilObject = {};
recordPencilObject.w = parseInt(x / this.laserBoardWidth * 10000) / 100;
recordPencilObject.h = parseInt(y / this.laserBoardWidth * 10000) / 100;
//loger.log("xyToPer",recordPencilObject);
return recordPencilObject;
}
xyFromPer(w, h) {
let xyObj = {};
xyObj.x = Math.round((w * this.laserBoardWidth) / 100) ;//加0.5偏移 平滑
xyObj.y = Math.round((h * this.laserBoardWidth ) / 100);
//loger.log("xyFromPer",xyObj);
return xyObj;
}
}
LaserPen.prototype.LASER_PEN_CHANGE = LaserPen.LASER_PEN_CHANGE = "laser_pen_change";
export default LaserPen;
\ No newline at end of file
... ... @@ -4,9 +4,6 @@
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";
... ... @@ -73,10 +70,10 @@ class ListDetailsApe extends Ape {
_classDateContent(_data){
let _dataList = _data.meetingInfo[0];
if(_dataList.meetingType == 1){
console.log('互动课堂')
loger.log('互动课堂')
this._lanclassRender(_dataList);
}else if(_dataList.meetingType == 2){
console.log('直播课堂')
loger.log('直播课堂')
this._liveRender(_dataList);
}else{
this._lanclassRender(_dataList);
... ... @@ -86,6 +83,7 @@ class ListDetailsApe extends Ape {
//互动课堂
_lanclassRender(_dataList){
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#teacherDetailBox').show();
$('#teacherDetailInfoImg').attr('src','images/u293.png');//老师授课标题图片
... ... @@ -106,6 +104,7 @@ class ListDetailsApe extends Ape {
//直播课堂
_liveRender(_dataList){
$('#defaultBox').hide();
$('.curriculumBox').hide();
$('#lanclassBox').show();
$('#lanclassContentCover').attr('src','images/u373.png');//老师授课标题图片
... ...
... ... @@ -4,9 +4,6 @@
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";
let loger = Loger.getLoger('PC-LanclassApe');
... ... @@ -47,6 +44,7 @@ class LanclassApe extends Ape {
$('#classifyListContent').find('.classifyList').eq(i==3).addClass('classifyListR');
}
_lanclassBtnHandler(evt){
loger.log('互动',ClassDataProxy.userType)
let _ele = $(evt.target);
if(_ele.attr('data')){
$('.header_listMsg').eq(_ele.attr('data')).addClass('header_listMsgCheck').siblings().removeClass('header_listMsgCheck');
... ...
... ... @@ -4,9 +4,6 @@
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";
import MessageTypes from "../MessageTypes";
... ... @@ -123,6 +120,7 @@ class LoginOrRegister extends Ape {
$('#loginPassWord').val('');
$('#slideshow').show();
$('#defaultBox').show();
$('.curriculumBox').show();
$('#header_list').show();
$('#header_seek').show();
$('#androidDownload').show();
... ... @@ -287,6 +285,7 @@ class LoginOrRegister extends Ape {
url: _url,
data: signInfo,
success:function(_data){
loger.log('登录返回数据',_data)
if(_data || _data.code == 200){
ClassDataProxy.userType = ClassDataProxy.USER_TYPE_1;
//ClassDataProxy.userType= _data.returnData.data.userType;
... ...
//*
// 媒体控制栏
// */
import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import TimerCounterTool from "libs/TimerCounterTool";
let loger = Loger.getLoger('PC-MediaControlBarApe');
const SOUND_BTN_WIDTH=66;
const TIME_TEXT_WIDTH=90;
class MediaControlBarApe extends Ape {
constructor() {
super();
this.playStatus = "";
this.isShowVolumeBar = false;//
this.isProgressMouseDown = false;//进度条是否按下
this.isProVolMouseDown = false;//音量控制条是否已经按钮
this.isOpenUpdateStatusInfo = false;//是否开同步信息
this.video = null;//需要控制的播放器
this.controlCallback = null;
this.totalTime = 0;
this.duration=0;//媒体文件的总时间长
this.mediaVolume = 60;//当前音量
this.seekPercent = 0;//当前进度
this.seekTime = 0;//
this.updateCounter = 0;//定时更新数据的计数器
this.updateStatusDelay = 5;//每5秒更新一次数据
this.timerCounter = new TimerCounterTool();//计时器
this.timerCounter.addTimerCallBack(this.timerCounterUptate.bind(this), 1);//计时器监听 每秒更新一次
this.init();
this.addEvent();
this.onWindowResize();//默认刷新一次界面布局
}
init() {
this.stop();
this.updatePlayProgressBar();
this.updaterVolumeProgressBar()
}
addEvent() {
//监听舞台
$(window).on('resize', this.onWindowResize.bind(this));
$("#mediaShareVolumePlay").on("click", this._openVolumeControl.bind(this));//打开音量控制
//音量控制
$('#mediaShareVoice_btn').on('mousedown', this._changeVolume.bind(this));//音量进度条
//暂停播放伴音按钮
$("#mediaShareProgressPause").on("click", this._clickPause.bind(this));
//继续播放伴音按钮
$("#mediaShareProgressPlay").on("click", this._clickPlay.bind(this));
//进度条控制
$('#mediaShareProgress_btn').on('mousedown', this._changeProgressBar.bind(this));
//给整个进度条可以点击seek
$('#mediaShareProgress_bg').on('mousedown', this._clickProgressBarBg.bind(this));
$('#mediaShareProgress_color').on('mousedown', this._clickProgressBarBg.bind(this));
}
//计时器-------------------
//开启计时器
startTimerCounter() {
loger.log("开启计时器")
this.updateCounter = 0;
this.stopTimerCounter();
if (this.timerCounter) {
this.timerCounter.startTimer();
}
}
//停止计时器
stopTimerCounter() {
loger.log("停止计时器")
this.updateCounter = 0;
if (this.timerCounter) {
this.timerCounter.stopTimer();
}
}
timerCounterUptate() {
if (this.video && !this.isProgressMouseDown) {
this.totalTime = this.video.duration || this.duration;
this.seekTime = this.video.currentTime || 0;
this.seekPercent = parseInt(this.seekTime / this.totalTime * 100);
//console.log("totalTime", this.totalTime)
//console.log("seekTime", this.seekTime)
//console.log("seekPercent", this.seekPercent)
this.updatePlayProgressBar();
}
if (this.seekTime >= this.totalTime&&this.seekTime!=1) {
if (this.totalTime > 0) {
this.sendCallBack(MediaControlBarApe.STOP)
}
this.stopTimerCounter();
this.stop();
}
//定时更新同步数据
this.updateCounter++;
if (this.updateCounter >= this.updateStatusDelay) {
this.updateCounter = 0;
loger.warn("定时同步更新媒体共享的状态")
this.sendCallBack(this.playStatus);
}
}
//外部接口调用------------------------------
play(_seek) {
loger.log("play");
this.playStatus = MediaControlBarApe.PLAY;
this.showPauseUI();
this.showBox();
this.startTimerCounter();
}
pause() {
loger.log("pause");
this.playStatus = MediaControlBarApe.PAUSE;
this.showPlayUI();
this.showBox();
this.stopTimerCounter();
}
stop() {
loger.log("stop");
this.seekPercent = 0;
this.seekTime = 0;
this.totalTime = 0;
this.playStatus = MediaControlBarApe.STOP;
this._hideMediaSharePlayProgressVoiceBox();
this.updatePlayProgressBar();
this.showPlayUI();
this.hideBox();
this.stopTimerCounter();
}
seek(_seek) {
loger.log("seek");
this.showBox();
this.seekTime = _seek || 0;
this.seekPercent = parseInt(this.seekTime / this.totalTime * 100);
this.updateVideoProgress();
this._hideMediaSharePlayProgressVoiceBox();
}
changeVolume(_volume) {
loger.log("changeVolume");
this.showBox();
this.mediaVolume = _volume || 0;
this.updaterVolumeProgressBar();
}
//-UI
showPlayUI() {
$("#mediaShareProgressPause").hide();
$("#mediaShareProgressPlay").show();
}
showPauseUI() {
$("#mediaShareProgressPause").show();
$("#mediaShareProgressPlay").hide();
}
showBox() {
$("#h5MediaShareControls").show();
}
hideBox() {
$("#h5MediaShareControls").hide();
}
//------------------------------------
//播放按钮
_clickPlay() {
loger.log("播放按钮点击===>");
this.updateCounter = 0;
this.playStatus = MediaControlBarApe.PLAY;
this._hideMediaSharePlayProgressVoiceBox();
this.showPauseUI();
this.startTimerCounter();
this.sendCallBack(MediaControlBarApe.PLAY);
}
//暂停播放
_clickPause() {
loger.log("暂停播放按钮点击===>");
this.updateCounter = 0;
this.playStatus = MediaControlBarApe.PAUSE;
this._hideMediaSharePlayProgressVoiceBox();
this.showPlayUI();
this.stopTimerCounter();
this.sendCallBack(MediaControlBarApe.PAUSE);
}
//打开音量控制条
_openVolumeControl() {
if (this.isShowVolumeBar == true) {
this._hideMediaSharePlayProgressVoiceBox();
} else {
this._showMediaSharePlayProgressVoiceBox();
}
}
//音量进度条-----------------------------------------
//音量控制鼠标按下
_changeVolume(evt) {
this.updateCounter = 0;
this.isProVolMouseDown = true;
document.onmousemove = this._mouseMoveMediaVoiceHandler.bind(this);
document.onmouseup = this._mouseUpMediaVoiceHandler.bind(this);
return false;
}
//音量条移动
_mouseMoveMediaVoiceHandler(evt) {
let per = this._moveVolMethod(evt);
this.mediaVolume = per;
this.updaterVolumeProgressBar();
}
_mouseUpMediaVoiceHandler(evt) {
if (this.isProVolMouseDown) {
if (this.playStatus == MediaControlBarApe.PLAY) {
this.sendCallBack(MediaControlBarApe.PLAY)
} else if (this.playStatus == MediaControlBarApe.PAUSE) {
this.sendCallBack(MediaControlBarApe.PAUSE)
} else {
this.sendCallBack(MediaControlBarApe.STOP)
}
}
this.isProVolMouseDown = false;
document.onmousemove = null;
document.onmouseup = null
}
//音量移动函数
_moveVolMethod(evt) {
let windowY = (evt || window.event).clientY;
let _width = $('#mediaShareVoice_bg')
let top = _width.offset().top;
let _percentage = _width.innerHeight();
let prevX = parseInt(windowY - top);
if (prevX < 0)prevX = 0;
if (prevX > _percentage)prevX = _percentage;
let per = Math.floor(100 * prevX / _percentage);
per = 100 - per;
return per;
}
updaterVolumeProgressBar() {
let _color = $('#mediaShareVoice_color');
let _btn = $('#mediaShareVoice_btn');
let perChange = this.mediaVolume / 100;
if (this.video) {
this.video.volume = perChange;//设置音量
}
//let curSeek = document.getElementById("h5MediaShare").currentTime;
_btn.css('top', 100 - this.mediaVolume + '%');
_color.css('height', (this.mediaVolume) + '%');
}
_showMediaSharePlayProgressVoiceBox() {
this.isShowVolumeBar = true;
$(".mediaSharePlayProgressVoiceBox").show();
}
_hideMediaSharePlayProgressVoiceBox() {
this.isShowVolumeBar = false;
$(".mediaSharePlayProgressVoiceBox").hide();
}
//播放进度条控制-------------------------------------
_changeProgressBar(evt) {
this._hideMediaSharePlayProgressVoiceBox();
this.isProgressMouseDown = true;
document.onmousemove = this._mouseMoveMediaProgressHandler.bind(this);
document.onmouseup = this._mouseUpMediaaHandler.bind(this);
return false;
}
_clickProgressBarBg(evt) {
this.isProgressMouseDown=true;
let per = this._moveMethod(evt);
this.seekPercent = per;
this.updatePlayProgressBar();
this. _mouseUpMediaaHandler(evt);
}
//鼠标在进度条上移动
_mouseMoveMediaProgressHandler(evt) {
let per = this._moveMethod(evt);
this.seekPercent = per;
this.updatePlayProgressBar();
//console.log("进度条移动百分比", this.seekPercent);
}
updatePlayProgressBar() {
let _color = $('#mediaShareProgress_color');
let _btn = $('#mediaShareProgress_btn');
_btn.css('left', this.seekPercent + '%');
_color.css('width', this.seekPercent + '%');
let curTimeStr=this.timerCounterLayOut(this.seekTime);
let totalTimeStr=this.timerCounterLayOut(this.totalTime);
$("#mediaShareTimestamp").html(curTimeStr+"/"+totalTimeStr);
}
updateVideoProgress() {
if (this.video) {
try{
this.video.currentTime = this.seekTime;//设置音量
}catch (err){
loger.warn("无法设置video的currentTime");
}
}
}
//鼠标进度条抬起
_mouseUpMediaaHandler(evt) {
if (this.isProgressMouseDown) {
this.seekTime = parseInt(this.seekPercent * this.totalTime * 0.01);
if (this.playStatus == MediaControlBarApe.PLAY) {
this.sendCallBack(MediaControlBarApe.PLAY)
} else if (this.playStatus == MediaControlBarApe.PAUSE) {
this.sendCallBack(MediaControlBarApe.PAUSE)
} else {
this.sendCallBack(MediaControlBarApe.STOP)
}
this.updateVideoProgress();
}
this.isProgressMouseDown = false;
document.onmousemove = null;
document.onmouseup = null
}
//进度条移动函数
_moveMethod(evt) {
let windowX = (evt || window.event).clientX;
let _width = $('#mediaShareProgress_bg')
let left = _width.offset().left;
let _percentage = _width.innerWidth();
let prevX = parseInt(windowX - left);
if (prevX < 0)prevX = 0;
if (prevX > _percentage)prevX = _percentage;
let per = Math.floor(100 * prevX / _percentage);
return per;
}
timerCounterLayOut(timestamp) {
let minute = 0,
second = 0;
minute = Math.floor(timestamp / 60);
second = Math.floor(timestamp - minute * 60)
let timeValue = ((minute < 10) ? "0" : "") + minute;
timeValue += ((second < 10) ? ":0" : ":") + second;
return timeValue;
}
//舞台大小发生改变
onWindowResize() {
//loger.log("舞台大小发生改变");
let boxWidth = $(".h5MediaShareControls").width();
//进度条的宽度是盒子的总宽度减去 声音按钮和时间显示区域的宽度
$(".mediaSharePlayProgressBox").width((boxWidth - SOUND_BTN_WIDTH-TIME_TEXT_WIDTH) + "px")
}
//调用回调函数通知外部
sendCallBack(_action, _data) {
if (!this.isOpenUpdateStatusInfo) {
return
}
if (this.controlCallback) {
this.controlCallback({
action: _action,
data: {
seek: this.seekTime,
mediaVolume: this.mediaVolume
}
})
}
}
}
MediaControlBarApe.prototype.STOP = MediaControlBarApe.STOP = "stop";//0
MediaControlBarApe.prototype.PLAY = MediaControlBarApe.PLAY = "play";//1
MediaControlBarApe.prototype.PAUSE = MediaControlBarApe.PAUSE = "pause";//2
MediaControlBarApe.prototype.SEEK = MediaControlBarApe.SEEK = "seek";//3
MediaControlBarApe.prototype.CHANGE_VOLUME = MediaControlBarApe.CHANGE_VOLUME = "change_volume";//4
export default MediaControlBarApe;