SrtToTxt
This commit is contained in:
955
学生学习页面_files/attachment_click_util.js.下载
Normal file
955
学生学习页面_files/attachment_click_util.js.下载
Normal file
@@ -0,0 +1,955 @@
|
||||
|
||||
/**
|
||||
* 处理附件点击事件
|
||||
*/
|
||||
RichtextAttachmentClickUtils = {
|
||||
clickEvent : function(){},
|
||||
customAttachmentType : '', // 自己处理点击事件的附件类型
|
||||
customClickEvent: function(){}, // 自己处理点击事件的方法
|
||||
}
|
||||
//获取js当前路径
|
||||
RichtextAttachmentClickUtils.mctx = function () {
|
||||
var jsPath = document.currentScript && document.currentScript.src ? document.currentScript.src : function () {
|
||||
var js = document.scripts
|
||||
, last = js.length - 1
|
||||
, src;
|
||||
for (var i = last; i > 0; i--) {
|
||||
if (js[i].readyState === 'interactive') {
|
||||
src = js[i].src;
|
||||
break;
|
||||
}
|
||||
if (js[i].src.indexOf('attachment_click_util.js') > -1) {
|
||||
src = js[i].src;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return src || js[last].src;
|
||||
}();
|
||||
return jsPath.substring(0, jsPath.indexOf('/res/'));
|
||||
}();
|
||||
var AttachmentType = {
|
||||
Topic:1,//话题
|
||||
Note:2,//笔记
|
||||
Special:3,//专题
|
||||
Newspaper:4,//报纸
|
||||
SpecialDomain:5,//专题域
|
||||
Periodical:6,//期刊
|
||||
Group:7,//小组
|
||||
Notice:8,//通知
|
||||
Notifications:30,//通知提醒
|
||||
Message:9,//消息
|
||||
Notebook:10,//笔记文件夹
|
||||
StudyFolder:11,//书房文件夹
|
||||
Courses:{ //15课程相关
|
||||
Value:15,
|
||||
subType:{
|
||||
test : 42, // 测验
|
||||
score : 23, // 评分
|
||||
vote : 14, // 投票/问卷
|
||||
signin:2,//签到
|
||||
liveVideo:0//直播
|
||||
}
|
||||
},
|
||||
ResourcesDomain:16,//资源域
|
||||
CourseChapter:17,//课程章节
|
||||
CloudDisk:18,//云盘
|
||||
RedPacket:19,//红包
|
||||
UserInfo:20,//人员信息
|
||||
Course:21,//课程
|
||||
BookRoom:22,//书房
|
||||
GroupChat:23,//群聊
|
||||
DownloadApp:24,//APP下载
|
||||
Web:25,//网页
|
||||
Voice:26,//录音
|
||||
Video:29,//录制视频
|
||||
Link:31, //外链
|
||||
mapLocation:33,//地图
|
||||
CloudFolder:38, // 云盘文件夹
|
||||
microCourse:41, //速课
|
||||
courseqrCode:44,//班级课程,(从新建课程和新建班级完成页面转发的)
|
||||
TopicFolder:47, // 话题文件夹
|
||||
GroupDatafolder:48, // 资料文件夹
|
||||
localFolder:49, // 本地文件夹
|
||||
CourseVideo:54,//课程视频打点
|
||||
};
|
||||
|
||||
var host = window.location.href;
|
||||
if (host) {
|
||||
host = host.toLocaleLowerCase();
|
||||
}
|
||||
//是否是分享页,分享页点击附件时是打开分享页地址,课程那边在微信里面使用时也走分享页逻辑
|
||||
var isShare = host.indexOf("sharewh") != -1 || host.indexOf("mobilewx.chaoxing.com") != -1;
|
||||
// 是否是投屏页
|
||||
var isScreen = window.location.pathname.indexOf("screen") != -1;
|
||||
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
var isAndroid = ua.indexOf('android') > -1 || ua.indexOf('adr') > -1; //android终端
|
||||
var isIOS = ua.indexOf('iphone') >= 0 || ua.indexOf('ipad') >= 0 || ua.indexOf('ipod') >= 0; //ios终端
|
||||
var isHarmony = navigator.userAgent.indexOf('harmony') > -1 //鸿蒙终端
|
||||
// 是否在学习通里面
|
||||
var isXXT = ua && ua.indexOf("chaoxingstudy")!=-1 && ua.indexOf('_pc_') == -1;
|
||||
// 是否在手机端
|
||||
var isPhone = isAndroid || isIOS || isHarmony;
|
||||
// 是否是微信端
|
||||
var isWeiXin = ua.match(/MicroMessenger/i) == 'micromessenger';
|
||||
var isIosQQ = ( /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent) && /\sQQ/i.test(navigator.userAgent));
|
||||
var isAndroidQQ = ( /(Android)/i.test(navigator.userAgent) && /MQQBrowser/i.test(navigator.userAgent) && /\sQQ/i.test((navigator.userAgent).split('MQQBrowser')));
|
||||
var isQQ = isIosQQ || isAndroidQQ;
|
||||
|
||||
// 2话题;3笔记;4 通知;6小组;7专题 这几种类型走接口获取分享页地址
|
||||
var strJson = {};
|
||||
strJson[AttachmentType.Topic] = 2;
|
||||
strJson[AttachmentType.Note] = 3;
|
||||
strJson[AttachmentType.Notice] = 4;
|
||||
strJson[AttachmentType.Group] = 6;
|
||||
// strJson[AttachmentType.Special] = 7;
|
||||
|
||||
// 获取客户端版本号
|
||||
RichtextAttachmentClickUtils.getClientVersion = function(){
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if(ua.indexOf("chaoxingstudy") > -1){
|
||||
ua = ua.substring(ua.indexOf("chaoxingstudy"));
|
||||
ua = ua.substring(ua.indexOf("_")+1);
|
||||
ua = ua.substring(ua.indexOf("_")+1);
|
||||
ua = ua.substring(0,ua.indexOf("_"));
|
||||
return ua;
|
||||
}
|
||||
return '0';
|
||||
}
|
||||
//获取客户端API版本号
|
||||
RichtextAttachmentClickUtils.getClientApiVersion = function () {
|
||||
var userAgent = navigator.userAgent;
|
||||
if (userAgent.indexOf("ChaoXingStudy_") == -1) {
|
||||
return 0;
|
||||
}
|
||||
var versionArray = userAgent.match(".*ChaoXingStudy_(\\d+)_(\\d+[^_]*)_([^_]*)_([^_]*)_([^ ]*)?( \\([^)]*\\))?.*_(.*[-]?\\w+).*");
|
||||
if (!!versionArray && versionArray != "undefined" && versionArray.length > 6) {
|
||||
var ApiVersion = versionArray[5].split("_")[1];
|
||||
return parseInt(ApiVersion);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* 获取附件 isOriginal 是否走原来的逻辑获取地址 0:不是 1:是
|
||||
*/
|
||||
RichtextAttachmentClickUtils.clickEvent = function(attachment, operationType, isOriginal) {
|
||||
if (!attachment) {
|
||||
return;
|
||||
}
|
||||
var open_url = "";
|
||||
var attachmentType = attachment.attachmentType;
|
||||
if (undefined == attachmentType || attachmentType == "") {
|
||||
return;
|
||||
}
|
||||
attachmentType = parseInt(attachmentType);
|
||||
if (typeof RichtextAttachmentClickUtils.customAttachmentType != 'undefined'
|
||||
&& RichtextAttachmentClickUtils.customAttachmentType
|
||||
&& typeof RichtextAttachmentClickUtils.customClickEvent == 'function') {
|
||||
var attTypeArr = RichtextAttachmentClickUtils.customAttachmentType.split(',');
|
||||
if (attTypeArr && attTypeArr.length > 0) {
|
||||
var isContains = false;
|
||||
$.each(attTypeArr, function(idx, val) {
|
||||
if (parseInt(val) == attachmentType) {
|
||||
// 定义了自己处理的附件,直接调用的对应的方法
|
||||
RichtextAttachmentClickUtils.customClickEvent(attachment, attachmentType);
|
||||
isContains = true;
|
||||
return false;
|
||||
}
|
||||
})
|
||||
if (isContains) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof RichTextUitl != "undefined" && RichTextUitl.intranetMode) {
|
||||
var url = '';
|
||||
if (attachmentType == AttachmentType.CloudDisk
|
||||
&& attachment.att_clouddisk && !attachment.att_clouddisk.fileId
|
||||
&& attachment.att_clouddisk.downPath) {
|
||||
// 有一些镜像数据是从线上迁移到本地的,线上的云盘附件里面有fileId,如果有这个,就走线上的下载逻辑
|
||||
url = attachment.att_clouddisk.downPath;
|
||||
}else if (attachmentType == AttachmentType.Web) {
|
||||
url = attachment.att_web.url;
|
||||
}
|
||||
if (url) {
|
||||
if(isPhone){
|
||||
$('body').append('<a style="display:none;" id="open_attachment" target="_blank" href="'+url+'"></a>');
|
||||
var el=document.getElementById('open_attachment');
|
||||
el.click();//触发打开事件
|
||||
$(el).remove();
|
||||
}else{
|
||||
window.location.href = url;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (operationType == 'preview') {
|
||||
// 云盘文件的预览
|
||||
if (attachment && attachment.att_clouddisk && attachment.att_clouddisk.fileId) {
|
||||
var url = "https://previewyd.chaoxing.com/res/view/view.html?opentype=full&objectid="
|
||||
+ attachment.att_clouddisk.fileId;
|
||||
if(window.obj && window.obj.mirrorDomain && window.obj.mirrorDomain.previewDomainHttps){
|
||||
url = window.obj.mirrorDomain.previewDomainHttps + "/res/view/view.html?opentype=full&objectid="
|
||||
+ attachment.att_clouddisk.fileId;
|
||||
}
|
||||
if(!RichTextUitl.isGetVideoDataFromCenter){
|
||||
resid = attachment.att_clouddisk.resid
|
||||
url += '&resid=' + resid;
|
||||
}
|
||||
if(isPhone) {
|
||||
$('body').append('<a style="display:none;" id="open_attachment" target="_blank" href="' + url + '"></a>');
|
||||
var el = document.getElementById('open_attachment');
|
||||
el.click();//触发打开事件
|
||||
$(el).remove();
|
||||
}else{
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
//可预览可下载文件
|
||||
var isFile = attachment.attachmentType == 18 && (attachment.att_clouddisk.suffix.indexOf('doc') > -1 || attachment.att_clouddisk.suffix.indexOf('xls') > -1 || attachment.att_clouddisk.suffix.indexOf('pdf') > -1);
|
||||
|
||||
if (isXXT && RichtextAttachmentClickUtils.getClientApiVersion() >= 38 && window.self == window.top) {
|
||||
// 4.357 才有 CLIENT_OPEN_ATTACHMENT 协议
|
||||
// 非分享页,且是在学习通里面打开的,通过客户端协议展示附件,现在改为分享页在学习通里面打开时也使用协议
|
||||
// 门户那边反馈有视频在学习通里面查看时会提示文件不存在,查询发现是视频附件里面的resid对应的数据已经不存在了
|
||||
// 可能是用户把文件传到云盘后又删除了文件,由于门户都是定制域名,为了先解决播放问题,
|
||||
// 添加判断课程域名的才使用协议,门户的使用网页播放,网页播放是用的objectid查的,可以正常查到数据
|
||||
if (window.location.host.indexOf('mobilelearn') > -1 || window.location.host.indexOf('sharewh') > -1
|
||||
|| attachment.attachmentType != 29) {
|
||||
try {
|
||||
jsBridge.postNotification('CLIENT_OPEN_ATTACHMENT', attachment);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
} else {
|
||||
attachment.att_video.name = attachment.att_video.fileTitle;
|
||||
attachment.att_video.fileId = attachment.att_video.objectId2;
|
||||
AttachmentListener.mediaPlay('video', attachment.att_video);
|
||||
}
|
||||
return;
|
||||
} else if(isXXT && window.top != window.self) {
|
||||
// 学习通里面iframe嵌套的,用顶层协议打开
|
||||
try {
|
||||
if(top.jsBridge){
|
||||
top.jsBridge.postNotification('CLIENT_OPEN_ATTACHMENT', attachment);
|
||||
return;
|
||||
}
|
||||
}catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 2话题;3笔记;4 通知;6小组;7专题 这几种类型走接口获取分享页地址
|
||||
if (strJson[attachmentType] && isShare && !isOriginal){
|
||||
getAttShareUrl(strJson[attachmentType],attachmentType,attachment);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (attachmentType) {
|
||||
case AttachmentType.Topic:
|
||||
//话题
|
||||
var att_topic=attachment.att_topic;
|
||||
var att_topic_id = att_topic.id;
|
||||
if($.trim(att_topic.shareUrl||"")!=""){//尝试获取加密的话题id
|
||||
var reg4GetDesNoteId = new RegExp("//sharewh.chaoxing.com/share/topic/([^/]+)/getTopic", "ig");
|
||||
var regResultArr = reg4GetDesNoteId.exec(att_topic.shareUrl||"");
|
||||
att_topic_id = regResultArr && regResultArr.length>1?regResultArr[1]:att_topic_id;
|
||||
}
|
||||
if(isShare){
|
||||
open_url = att_topic.shareUrl.replace('sharewh.chaoxing.com', 'sharewh3.xuexi365.com');
|
||||
}else if(isScreen){
|
||||
// 投屏页,打开对应的话题投屏页面
|
||||
open_url = "https://groupyd.chaoxing.com/screen/screenProjection/topic/"+ att_topic.uuid +"/detail";
|
||||
} else {
|
||||
// open_url = "http://group.yd.chaoxing.com/pc/topic/bbs/"+ att_topic.att_group.bbsId +"/"+att_topic_id+"/replysList";
|
||||
open_url = "https://groupweb.chaoxing.com/pc/topic/jumpToTopicDetail?bbsid="+ att_topic.att_group.bbsId +"&uuid=" + att_topic.uuid;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Note:
|
||||
//笔记
|
||||
var att_note = attachment.att_note;
|
||||
var att_note_url = 'https://noteyd.chaoxing.com/pc/' + att_note.cid;
|
||||
if(isShare){
|
||||
open_url = att_note.shareUrl.replace('sharewh.chaoxing.com', 'sharewh3.xuexi365.com');
|
||||
} else if(isScreen){
|
||||
// 投屏页,打开对应的笔记投屏页面
|
||||
open_url = "https://noteyd.chaoxing.com/screen/note_note/noteDetail/" + att_note.cid;
|
||||
} else{
|
||||
open_url = att_note_url;
|
||||
}
|
||||
if(typeof Notice_Detail != 'undefined' && typeof Notice_Detail.openNoticeCard == 'function'){
|
||||
Notice_Detail.openNoticeCard(att_note.title, att_note_url);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Notebook:
|
||||
// 笔记本
|
||||
var att_notebook = attachment.att_notebook;
|
||||
if (att_notebook.cid) {
|
||||
open_url = 'https://noteyd.chaoxing.com/pc/note_notebook/otherNotebooksLatest/'+att_notebook.cid;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Special:
|
||||
//专题
|
||||
var att_subject = attachment.att_subject;
|
||||
var category = att_subject.category;
|
||||
if(category == "0"){//专题
|
||||
var subjectLink = att_subject.subjectLink;//链接
|
||||
var courseId = subjectLink.substring(subjectLink.lastIndexOf("/")+1);
|
||||
var askCharIndex = courseId.indexOf("?");
|
||||
if (askCharIndex >-1) {
|
||||
courseId = courseId.substring(0,askCharIndex);
|
||||
}
|
||||
if(isShare){
|
||||
if (isPhone) {
|
||||
open_url = subjectLink;
|
||||
} else {
|
||||
open_url = "http://mooc1.chaoxing.com/course/"+ courseId +".html";
|
||||
}
|
||||
}else{
|
||||
if (isScreen) {
|
||||
open_url = 'http://special.chaoxing.com/special/screen/'+courseId;
|
||||
} else {
|
||||
open_url = 'http://mooc1.chaoxing.com/course/'+courseId+'.html';
|
||||
}
|
||||
}
|
||||
}else if(category == "1"){//专题章节
|
||||
//专题章节
|
||||
var chapterLink = att_subject.chapterLink;//章节链接
|
||||
var askCharIndex = chapterLink.indexOf("?");
|
||||
var openUrl = "";
|
||||
if(chapterLink.indexOf("http://group.yd.chaoxing.com")!=-1){
|
||||
//一键专题对应的专题章节
|
||||
openUrl = chapterLink;
|
||||
} else if (chapterLink.indexOf('courseId') == -1) {
|
||||
// 不包含 courseId, 直接使用 chapterLink
|
||||
openUrl = chapterLink;
|
||||
} else{
|
||||
var courseId = '';
|
||||
var chapterId = '';
|
||||
if (askCharIndex > -1) {
|
||||
// 专题中的某一章,为一个具体的章节
|
||||
courseId = chapterLink.split("?")[1].split("&")[0].split("=")[1];
|
||||
chapterId = chapterLink.substring(chapterLink.lastIndexOf("/")+1,askCharIndex);
|
||||
} else {
|
||||
// 套专题中的某一章,是一个单独的专题
|
||||
courseId = chapterLink.substring(chapterLink.lastIndexOf("/")+1);
|
||||
}
|
||||
if (chapterId) {
|
||||
if (isScreen) {
|
||||
openUrl = 'http://special.chaoxing.com/special/screen/tocard/'+ chapterId +'?courseId='+ courseId;
|
||||
} else {
|
||||
openUrl = 'http://mooc1-3.chaoxing.com/nodedetailcontroller/visitnodedetail?courseId='+courseId+'&knowledgeId='+chapterId+'&courseType=0';
|
||||
}
|
||||
} else {
|
||||
if (isScreen) {
|
||||
openUrl = 'http://special.chaoxing.com/special/screen/'+courseId;
|
||||
} else {
|
||||
openUrl = 'http://mooc1.chaoxing.com/course/'+courseId+'.html';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if(isShare && isPhone){
|
||||
openUrl = chapterLink;
|
||||
}
|
||||
open_url = openUrl;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Newspaper:
|
||||
//报纸
|
||||
var done = false;
|
||||
var att_subject = attachment.att_subject;
|
||||
var category = att_subject.category;
|
||||
if(category == "0"){
|
||||
//报纸
|
||||
var open_url = att_subject.subjectLink;//链接
|
||||
var paperId = subjectLogo.substring(subjectLogo.lastIndexOf("/")+1);
|
||||
if (!isScreen && paperId&&$.trim(paperId||"")!=""){
|
||||
open_url = "http://apps.ananas.chaoxing.com/paper/"+paperId.substring(0,paperId.indexOf("."));
|
||||
}
|
||||
} else if (category=="1") {
|
||||
//报纸章节
|
||||
var open_url = att_subject.chapterLink;//章节链接
|
||||
if (!isScreen) {
|
||||
var transferKey = att_subject.transferKey || '';
|
||||
// transferKey 结构: "300000006_320700000014-100059093733"
|
||||
var paperId = transferKey.substring(transferKey.indexOf('_')+1, transferKey.indexOf('-'));
|
||||
var chapterId = transferKey.substring(transferKey.indexOf('-')+1, transferKey.length);
|
||||
if (paperId && chapterId) {
|
||||
var currentDate = getNowFormatDate('.');
|
||||
open_url = 'http://apps.ananas.chaoxing.com/paper/content/'+ currentDate +'/'+ paperId +'/'+ chapterId +'/0';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Group:
|
||||
//小组
|
||||
var att_group = attachment.att_group || "";
|
||||
if (att_group != "") {
|
||||
if(isShare){
|
||||
open_url = att_group.shareUrl;
|
||||
}else{
|
||||
var bbsId = att_group.bbsId || "";
|
||||
if (bbsId != "") {
|
||||
open_url = "https://groupweb.chaoxing.com/pc/topic/topiclist/index?bbsid=" + bbsId;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Notice:
|
||||
//通知
|
||||
var att_notice = attachment.att_notice;
|
||||
var noticeId = att_notice.idCode;
|
||||
if (isShare){
|
||||
if (!att_notice.shareUrl) {
|
||||
open_url = "//sharewh.chaoxing.com/share/notice?sn="+ noticeId +"&sharebacktype=4&s_noticeId="+noticeId;
|
||||
} else {
|
||||
open_url = att_notice.shareUrl.replace('sharewh.chaoxing.com', 'sharewh3.xuexi365.com');;
|
||||
}
|
||||
} else if (isScreen){
|
||||
open_url = 'https://notice.chaoxing.com/screen/screenProjection/notice/detail?idCode='+noticeId;
|
||||
} else {
|
||||
open_url = 'http://notice.chaoxing.com/pc/notice/'+noticeId+'/detail';
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Notifications:
|
||||
//通知提醒
|
||||
var att_notice = attachment.att_mission;
|
||||
var noticeId = att_notice.aid || 0;
|
||||
if(isShare){
|
||||
openUrl = att_notice.shareUrl;
|
||||
}else{
|
||||
open_url = 'https://notice.chaoxing.com/pc/notice/'+noticeId+'/detail';
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Courses.Value://课程附件
|
||||
var att_course = attachment.att_chat_course||{};
|
||||
if(att_course && att_course.type>-1){//格式完好,分类处理,没有处理的显示默认提示
|
||||
switch (att_course.atype) {
|
||||
|
||||
case AttachmentType.Courses.subType.liveVideo:
|
||||
//直播
|
||||
var att_livevideo = att_course;
|
||||
if(!att_livevideo.description||!att_livevideo.description.liveId){
|
||||
break;
|
||||
}
|
||||
var liveId = att_livevideo.description.liveId || '';
|
||||
open_url = "https://zhibo.chaoxing.com/"+liveId;
|
||||
break;
|
||||
case AttachmentType.Courses.subType.signin:
|
||||
// 签到
|
||||
if(att_course.id){
|
||||
if (isScreen) {
|
||||
open_url = 'https://mobilelearn.chaoxing.com/widget/sign/pcTeaSignController/showSignInfoForQunliao?activeId='+att_course.id;
|
||||
} else {
|
||||
open_url = 'https://mobilelearn.chaoxing.com/widget/sign/group/pcStuSignGroupController/preSign?activeId='+att_course.id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Courses.subType.test:
|
||||
// 测验
|
||||
if (isScreen) {
|
||||
open_url = 'https://mobilelearn.chaoxing.com/widget/newvotescreen/goPCNewStatisticScreen?activeId='+att_course.id;
|
||||
} else {
|
||||
open_url = 'https://mobilelearn.chaoxing.com/widget/pcvote/goPCVoteStatistic?quessequence=1&activePrimaryId='+ att_course.id;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Courses.subType.score:
|
||||
// 评分
|
||||
if((att_course.id||0)>0){
|
||||
open_url = 'https://mobilelearn.chaoxing.com/widget/score/pc/queryGrade?activeId='+att_course.id;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Courses.subType.vote:
|
||||
// 投票/问卷
|
||||
if ((att_course.id||0)>0){
|
||||
if (isScreen) {
|
||||
open_url = 'https://mobilelearn.chaoxing.com/widget/newvotescreen/goPCNewStatisticScreen?activeId=' +att_course.id;
|
||||
} else {
|
||||
open_url = 'https://mobilelearn.chaoxing.com/widget/pcgroup/goPCGroupVotePage?activeId='+att_course.id+'&quessequence=1';
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
open_url = att_course.url;
|
||||
}
|
||||
if (!att_course.atype) {
|
||||
// 没有 atype,则根据type判断
|
||||
if (att_course.type == 4) {
|
||||
// 直播
|
||||
var att_livevideo = att_course;
|
||||
if(!att_livevideo.description||!att_livevideo.description.liveId){
|
||||
break;
|
||||
}
|
||||
var liveId = att_livevideo.description.liveId || '';
|
||||
open_url = "https://zhibo.chaoxing.com/"+liveId;
|
||||
}
|
||||
}
|
||||
if(isShare && isPhone && att_course.atype != AttachmentType.Courses.subType.liveVideo){
|
||||
open_url = att_course.url;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AttachmentType.CourseChapter:
|
||||
// 课程章节
|
||||
var att_course_chapter = attachment.att_course;
|
||||
if (isScreen) {
|
||||
var forwardCourse = attachment.att_course.forwardCourse;
|
||||
var courseId = '';
|
||||
var chapterId = '';
|
||||
try {
|
||||
courseId = forwardCourse.course.data[0].id;
|
||||
chapterId = forwardCourse.chapterid;
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
if (courseId && chapterId) {
|
||||
openChapterScreenUrl(courseId,chapterId);
|
||||
} else {
|
||||
open_url = att_course_chapter.knowledgeUrl || '';
|
||||
}
|
||||
} else {
|
||||
open_url = att_course_chapter.knowledgeUrl || '';
|
||||
}
|
||||
break;
|
||||
case AttachmentType.CloudDisk:
|
||||
// 云盘、音视频的播放有单独的逻辑处理,这里统一走下载逻辑
|
||||
var isVideo = false;
|
||||
var att_cloud = attachment.att_clouddisk;
|
||||
if(att_cloud&&att_cloud.fileId){
|
||||
if(isShare && isVideo) {
|
||||
// 分享页面下视频类型附件直接播放
|
||||
open_url = "https://sharewh3.xuexi365.com/share/"+ att_cloud.fileId +"/playVideo?url="+encodeURIComponent(window.location.href);
|
||||
}
|
||||
if((isWeiXin || isQQ || isXXT) && isPhone){
|
||||
// 微信、QQ、学习通里不支持下载,提示用户通过中间页去浏览器里面访问
|
||||
// var id = att_cloud.resid || att_cloud.objectId;
|
||||
if(!RichTextUitl.intranetMode){
|
||||
url = window.location.protocol + '//noteyd.chaoxing.com/res/plugin/mnote/attachInterface.html?fileId='+att_cloud.fileId+'&fileName=' + encodeURIComponent(att_cloud.name)
|
||||
+'&allowDownload=true&fileSize='+att_cloud.fileSize + '&originUrl=' + encodeURIComponent(window.location.href);
|
||||
if(isXXT && window.top != window.self && window.top.location){
|
||||
window.top.location.href = RichTextUitl.convertUrl(url)
|
||||
}else {
|
||||
window.location.href = RichTextUitl.convertUrl(url)
|
||||
}
|
||||
}else{
|
||||
//镜像
|
||||
var url = RichTextUitl.prefix + 'attachment/attachInterface.html?fileId='+att_cloud.fileId+
|
||||
'&fileName=' + encodeURIComponent(att_cloud.name) + '&isIntranetMode=' + RichTextUitl.intranetMode
|
||||
+ '&allowDownload=true&fileSize=' + att_cloud.fileSize
|
||||
+ '&originUrl=' + encodeURIComponent(window.location.href);
|
||||
if(att_cloud.previewUrl){
|
||||
url += '&previewUrl='+att_cloud.previewUrl;
|
||||
}
|
||||
if(att_cloud.downloadUrl){
|
||||
url += '&downloadUrl='+att_cloud.downloadUrl;
|
||||
}
|
||||
window.location.href = url;
|
||||
}
|
||||
} else {
|
||||
YunFileUtil.downloadYunFile(attachment, att_cloud.fileId);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Video:
|
||||
//视频
|
||||
var att_video = attachment.att_video;
|
||||
if(att_video&&att_video.objectId2){
|
||||
if(isShare) {
|
||||
// 分享页面下直接播放
|
||||
open_url = "https://sharewh3.xuexi365.com/share/"+ att_video.objectId2 +"/playVideo?url="+encodeURIComponent(window.location.href);
|
||||
} else {
|
||||
YunFileUtil.downloadYunFile(attachment, att_video.objectId2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Voice:
|
||||
var att_voice = attachment.att_voice;
|
||||
if(att_voice&&att_voice.objectId2){
|
||||
YunFileUtil.downloadYunFile(attachment, att_video.objectId2);
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Web:
|
||||
var att_web=attachment.att_web;
|
||||
open_url = att_web.url;
|
||||
//题目编辑器打开教师批阅附件,调用课程那边的方法去打开附件
|
||||
if(att_web.data1 && att_web.data2 && typeof 'openTeacherCommentAttach' != 'undefined'){
|
||||
openTeacherCommentAttach(att_web.data1,att_web.data2);
|
||||
return;
|
||||
}
|
||||
openLinkUrl(open_url)
|
||||
return
|
||||
break;
|
||||
case AttachmentType.Link:
|
||||
var att_linker=attachment.att_linker;
|
||||
open_url = att_linker.url;
|
||||
break;
|
||||
case AttachmentType.microCourse:
|
||||
var att_micro_course=attachment.att_micro_course;
|
||||
open_url = att_micro_course.url;
|
||||
break;
|
||||
case AttachmentType.mapLocation:
|
||||
var att_map_location=attachment.att_map_location;
|
||||
//open_url = 'http://map.baidu.com/?newmap=1&ie=utf-8&s=s%26wd%3D'+att_map_location.name;
|
||||
open_url = 'https://api.map.baidu.com/geocoder?title='+att_map_location.name+'&content='+att_map_location.address+'&location='+att_map_location.latitude+','+att_map_location.longitude+'&coord_type=bd09ll&output=html&src=webapp.baidu.openAPIdemo';
|
||||
break;
|
||||
case AttachmentType.StudyFolder:
|
||||
// 收藏文件夹
|
||||
var att_folder = attachment.att_resource;
|
||||
var creatorId = att_folder.content.puid || "";
|
||||
var name = att_folder.content.folderName;//文件夹名称
|
||||
var cfid = att_folder.content.cfid;//书房文件夹cfid
|
||||
if(cfid && name){
|
||||
open_url = 'http://pc.chaoxing.com/subscribe/getSubscribeByUidFolder?cfid='+cfid+'&puid='+creatorId+'&type=mobile';
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Periodical:
|
||||
// 期刊
|
||||
var att_subject = attachment.att_subject;
|
||||
if(att_subject && att_subject.settings) {
|
||||
//category=0时用subjectLogo(0是期刊),category=1时用chapterLogo(1是期刊章节)
|
||||
let category = att_subject.category;
|
||||
if(category == 0){
|
||||
if (att_subject.subjectLink) {
|
||||
open_url = att_subject.subjectLink
|
||||
}
|
||||
}else if (category == 1){
|
||||
if (att_subject.chapterLink) {
|
||||
open_url = att_subject.chapterLink
|
||||
}
|
||||
}
|
||||
var aid;
|
||||
if(att_subject.settings.aid) {
|
||||
aid = att_subject.settings.aid;
|
||||
} else if(att_subject.settings.sourceConfig && att_subject.settings.sourceConfig.aidEncKey){
|
||||
aid = att_subject.settings.sourceConfig.aidEncKey;
|
||||
}
|
||||
if (!open_url) {
|
||||
open_url = "http://m.chaoxing.com/mqk/list?mags="+ aid +"&from=space";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AttachmentType.CloudFolder:
|
||||
// 云盘文件夹
|
||||
var att_cloudFolder = attachment.att_cloudFolder;
|
||||
if (!att_cloudFolder) {
|
||||
break;
|
||||
}
|
||||
var resid = att_cloudFolder.resid;
|
||||
var sharerPuid = att_cloudFolder.puid;
|
||||
if(att_cloudFolder.encryptedId){
|
||||
//调接口获取地址
|
||||
$.ajax({
|
||||
url: RichtextAttachmentClickUtils.mctx + '/pc/resource/getCloudFolderDetailUrl?resid=' + att_cloudFolder.encryptedId + '&folderPuid=' + sharerPuid,
|
||||
type: 'GET',
|
||||
async: false,
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.result == 1 && res.data && res.data.cloudFolderDetailUrl) {
|
||||
open_url = res.data.cloudFolderDetailUrl;
|
||||
}else if(att_cloudFolder.shareInfo && att_cloudFolder.shareInfo.weburl){
|
||||
open_url = att_cloudFolder.shareInfo.weburl;
|
||||
}
|
||||
}
|
||||
})
|
||||
}else if(att_cloudFolder.shareInfo && att_cloudFolder.shareInfo.weburl) {
|
||||
open_url = att_cloudFolder.shareInfo.weburl;
|
||||
}
|
||||
if(!open_url){
|
||||
RichTextUitl.showTips('暂不支持打开')
|
||||
}
|
||||
break;
|
||||
case AttachmentType.courseqrCode:
|
||||
var info = attachment.att_class_qrcode_info;
|
||||
open_url = 'http://mooc1.chaoxing.com/addcourse/pcqrcodemiddleview?inviteCode=' + info.invitecode;
|
||||
break;
|
||||
case AttachmentType.TopicFolder:
|
||||
// 话题文件夹
|
||||
var att_folder = attachment.att_topicfolder;
|
||||
var folder_uuid = att_folder.folder_uuid || '';//文件夹uuid
|
||||
var bbsid = att_folder.groupInfo.bbsId||'';//小组bbsid
|
||||
if(folder_uuid && bbsid) {
|
||||
//open_url = "http://group.yd.chaoxing.com/pc/topic/"+bbsid+"/topicList?isAttachment=1&folder_uuid="+folder_uuid;
|
||||
open_url = "https://groupweb.chaoxing.com/pc/topic/topiclist/index?bbsid="+ bbsid +"&folder_uuid="+folder_uuid;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.GroupDatafolder:
|
||||
// 小组资料文件夹
|
||||
var att_folder = attachment.att_datafolder;
|
||||
var folderId = att_folder.folderId || '';//文件夹标识
|
||||
var bbsid = att_folder.groupInfo.bbsId||'';//小组bbsid
|
||||
if(folderId && bbsid) {
|
||||
// open_url = "http://group.yd.chaoxing.com/pc/resource/"+bbsid+"/resourceList?isAttachment=1&folderId="+folderId;
|
||||
open_url = "https://groupweb.chaoxing.com/pc/resource/jumpToResourceList?bbsid="+bbsid+"&folderId="+folderId;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.localFolder:
|
||||
// 本地文件夹
|
||||
var att_folder = attachment.att_localFolder;
|
||||
var cloudArray = new Array();
|
||||
if (att_folder.resids && att_folder.resids.length > 0) {
|
||||
$.each(att_folder.resids, function (idx, val){
|
||||
cloudArray.push({'puid':att_folder.puid, 'resid':val});
|
||||
})
|
||||
}
|
||||
open_url = 'https://ypdownload.chaoxing.com/download/downloadFilePackage?_token='
|
||||
+ RichTextUitl.yunToken + '&puid='+ RichTextUitl.puid
|
||||
+'&fileArray=' + encodeURIComponent(JSON.stringify(cloudArray))
|
||||
+ '&downloadFileName=' + encodeURIComponent(att_folder.name);
|
||||
break;
|
||||
case AttachmentType.CourseVideo:
|
||||
//课程视频打点
|
||||
var att_course_video = attachment.att_course_video;
|
||||
open_url = att_course_video.transferLink + '&host=' + window.location.hostname;
|
||||
break;
|
||||
case AttachmentType.GroupChat:
|
||||
// 群聊
|
||||
var att_chat = attachment.att_chat_group;
|
||||
var groupId = att_chat.groupId || '';
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if(groupId && ua.indexOf("chaoxingstudy") != -1 && ua.indexOf('_pc_') != -1 && typeof jsBridge != 'undefined'){
|
||||
jsBridge.postNotification('CLIENT_OPEN_CHAT', {"groupId": groupId});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// if($.trim(append_className) == ''){
|
||||
// //直接返回
|
||||
// return open_url;
|
||||
// }
|
||||
if($.trim(open_url) != ''){
|
||||
$("#open_attachment").remove();
|
||||
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if(isShare && ua && ua.indexOf("chaoxingstudy")!=-1 && ua.indexOf('_pc_') == -1){
|
||||
// 在客户端打开时通过openurl协议打开,pc客户端不走协议
|
||||
// if(window.parent) {
|
||||
// window.parent.postMessage({'url': open_url, 'msgType':'openUrl'}, 'https://sharewh.chaoxing.com')
|
||||
// return;
|
||||
// }
|
||||
if (typeof AppUtils != 'undefined') {
|
||||
AppUtils.openUrl({
|
||||
toolbarType:1,
|
||||
loadType: 1,
|
||||
webUrl:open_url
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (open_url && open_url.indexOf('note') > -1 || open_url.indexOf('notice') > -1
|
||||
// || open_url.indexOf('group') > -1 || open_url.indexOf('mobilelearn') > -1) {
|
||||
// 笔记,通知,小组,课堂活动可能做了域名隐射,将地址换成对应的域名
|
||||
if(typeof RichTextUitl != "undefined"){
|
||||
open_url = RichTextUitl.convertUrl(open_url);
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
openLinkUrl(open_url)
|
||||
}
|
||||
};
|
||||
|
||||
//打开url
|
||||
function openLinkUrl(open_url) {
|
||||
var target_val = '_blank';
|
||||
if(isScreen) {
|
||||
// 投屏页通过协议打开网页链接
|
||||
var content = {"openInCurrent":0,"opt":1,"urls":[open_url],"type":2}
|
||||
var data = {"cmd":"resourceToScreen","content":content};
|
||||
var body={'body':JSON.stringify(data)};
|
||||
parent.parent.postMessage(JSON.stringify({'cmd':'resourceToScreen','body':body}),'*');
|
||||
} else if(isIOS) {
|
||||
//IOS分享页打开新窗口有问题,只能在当前页面打开
|
||||
try {
|
||||
//记录要跳转的地址,用于话题打点记录链接使用
|
||||
RichTextUitl.open_url = open_url;
|
||||
if(window.top.location.href){
|
||||
window.top.location.href = open_url;
|
||||
}else{
|
||||
window.location.href = open_url;
|
||||
}
|
||||
}catch (e) {
|
||||
window.location.href = open_url;
|
||||
}
|
||||
|
||||
} else {
|
||||
$('body').append('<a style="display:none;" id="open_attachment" target="'+target_val+'" href="'+open_url+'"></a>');
|
||||
var el=document.getElementById('open_attachment');
|
||||
//el.target = '_new'; //指定在新窗口打开
|
||||
el.click();//触发打开事件
|
||||
$(el).remove()
|
||||
}
|
||||
}
|
||||
|
||||
function getNowFormatDate() {
|
||||
var date = new Date();
|
||||
var year = date.getFullYear();
|
||||
var month = date.getMonth() + 1;
|
||||
var strDate = date.getDate();
|
||||
if (month >= 1 && month <= 9) {
|
||||
month = "0" + month;
|
||||
}
|
||||
if (strDate >= 0 && strDate <= 9) {
|
||||
strDate = "0" + strDate;
|
||||
}
|
||||
if(!seperator) {
|
||||
seperator = '-';
|
||||
}
|
||||
var currentdate = year + seperator + month + seperator + strDate;
|
||||
return currentdate;
|
||||
}
|
||||
|
||||
var openChapterScreenUrl = function(courseId, chapterId) {
|
||||
if (!courseId || !chapterId) {
|
||||
return '';
|
||||
}
|
||||
$.ajax({
|
||||
url : 'https://noteyd.chaoxing.com/screen/note_note/getChapterScreenUrl',
|
||||
data : {courseId:courseId, chapterId:chapterId, num:1},
|
||||
type : "get",
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success : function(resultData) {
|
||||
if (!resultData || (resultData.status && !resultData.msg))
|
||||
return;
|
||||
var content = {"openInCurrent":0,"opt":1,"urls":[resultData.msg],"type":2}
|
||||
var data = {"cmd":"resourceToScreen","content":content};
|
||||
var body={'body':JSON.stringify(data)};
|
||||
parent.parent.postMessage(JSON.stringify({'cmd':'resourceToScreen','body':body}),'*');
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 获取附件分享页地址
|
||||
* @param type 附件类型 2话题;3笔记;4 通知;6小组;
|
||||
* @param attachmentType
|
||||
* @param attachment
|
||||
*/
|
||||
var getAttShareUrl = function(type, attachmentType, attachment) {
|
||||
var dataId;
|
||||
var dataId2;
|
||||
var sourcePuid = 0;
|
||||
|
||||
switch (attachmentType) {
|
||||
case AttachmentType.Topic:
|
||||
//话题
|
||||
var att_topic = attachment.att_topic;
|
||||
dataId = att_topic.uuid;
|
||||
dataId2 = att_topic.att_group.bbsId;
|
||||
sourcePuid = att_topic.creatorPId;
|
||||
break;
|
||||
case AttachmentType.Note:
|
||||
//笔记
|
||||
var att_note = attachment.att_note;
|
||||
dataId = att_note.cid;
|
||||
sourcePuid = att_note.createrPuid;
|
||||
break;
|
||||
case AttachmentType.Group:
|
||||
//小组
|
||||
var att_group = attachment.att_group || "";
|
||||
if (att_group != "") {
|
||||
dataId = att_group.bbsId;
|
||||
}
|
||||
break;
|
||||
case AttachmentType.Notice:
|
||||
//通知
|
||||
var att_notice = attachment.att_notice;
|
||||
dataId = att_notice.idCode;
|
||||
sourcePuid = att_notice.createrPuid;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//调接口获取附件分享页地址
|
||||
$.ajax({
|
||||
url : 'https://noteyd.chaoxing.com/screen/note_note/getShareUrl',
|
||||
data : {
|
||||
type: type,
|
||||
dataId: dataId,
|
||||
dataId2: dataId2,
|
||||
sourcePuid: sourcePuid
|
||||
},
|
||||
type : "get",
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success : function(resultData) {
|
||||
if (!resultData || !resultData.result || !resultData.msg){
|
||||
//调接口失败还走原来的逻辑,避免出现附件点击没反应的情况
|
||||
RichtextAttachmentClickUtils.clickEvent(attachment, '', 1);
|
||||
return;
|
||||
}
|
||||
var open_url = resultData.msg.shareUrl;
|
||||
openAttShareUrl(open_url);
|
||||
},
|
||||
error : function() {
|
||||
//调接口失败还走原来的逻辑,避免出现附件点击没反应的情况
|
||||
RichtextAttachmentClickUtils.clickEvent(attachment, '', 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 打开附件分享页地址
|
||||
* @param courseId
|
||||
* @param chapterId
|
||||
*/
|
||||
var openAttShareUrl = function(open_url) {
|
||||
if($.trim(open_url) != ''){
|
||||
$("#open_attachment").remove();
|
||||
var target_val = '_blank';
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if(isShare && ua && ua.indexOf("chaoxingstudy")!=-1 && ua.indexOf('_pc_') == -1){
|
||||
if (typeof AppUtils != 'undefined') {
|
||||
AppUtils.openUrl({
|
||||
toolbarType:1,
|
||||
loadType: 1,
|
||||
webUrl:open_url
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (open_url && open_url.indexOf('note') > -1 || open_url.indexOf('notice') > -1
|
||||
// || open_url.indexOf('group') > -1 || open_url.indexOf('mobilelearn') > -1) {
|
||||
// 笔记,通知,小组,课堂活动可能做了域名隐射,将地址换成对应的域名
|
||||
open_url = RichTextUitl.convertUrl(open_url);
|
||||
// }
|
||||
if(isScreen) {
|
||||
// 投屏页通过协议打开网页链接
|
||||
var content = {"openInCurrent":0,"opt":1,"urls":[open_url],"type":2}
|
||||
var data = {"cmd":"resourceToScreen","content":content};
|
||||
var body={'body':JSON.stringify(data)};
|
||||
parent.parent.postMessage(JSON.stringify({'cmd':'resourceToScreen','body':body}),'*');
|
||||
} else if(isIOS) {
|
||||
//IOS分享页打开新窗口有问题,只能在当前页面打开
|
||||
if(window.top.location.href){
|
||||
window.top.location.href = open_url;
|
||||
}else{
|
||||
window.location.href = open_url;
|
||||
}
|
||||
}else{
|
||||
$('body').append('<a style="display:none;" id="open_attachment" target="'+target_val+'" href="'+open_url+'" rel="noopener noreferrer"></a>');
|
||||
var el=document.getElementById('open_attachment');
|
||||
//el.target = '_new'; //指定在新窗口打开
|
||||
el.click();//触发打开事件
|
||||
$(el).remove()
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user