|
@@ -4,10 +4,24 @@ const {
|
|
|
throttle,
|
|
|
imageUrlPrefix,
|
|
|
config,
|
|
|
- getUrlArgObject
|
|
|
+ getUrlArgObject,
|
|
|
+ isIe8
|
|
|
} = require('./promise.js');
|
|
|
const $ = require("jquery");
|
|
|
+let TxtICon = require('./../images/txtIcon.png')
|
|
|
+let VedioIcon = require('./../images/vedioIcon.png')
|
|
|
+let currentIcon = require('./../images/icon_current.png')
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+if(isIe8()) {
|
|
|
+ let reg = /undefined/g
|
|
|
+ TxtICon = TxtICon.replace(reg, '')
|
|
|
+ VedioIcon = VedioIcon.replace(reg, '')
|
|
|
+ currentIcon = currentIcon.replace(reg, '')
|
|
|
+}
|
|
|
+
|
|
|
+const isLocal = window.location.hostname.indexOf('localhost') !=-1;
|
|
|
function getInfomation() {
|
|
|
var param = {
|
|
|
"type": getUrlArgObject('type'),
|
|
@@ -20,6 +34,12 @@ function getInfomation() {
|
|
|
param.type = 12;
|
|
|
param.name = uname;
|
|
|
}
|
|
|
+ if (param.type == 82) {
|
|
|
+ param.position = "8";
|
|
|
+ }
|
|
|
+ if (param.type == 83) {
|
|
|
+ param.position = "9";
|
|
|
+ }
|
|
|
|
|
|
post(config.information, param).then((res) => {
|
|
|
const data = res.data.data
|
|
@@ -29,36 +49,69 @@ function getInfomation() {
|
|
|
var item = '';
|
|
|
if (!data) {
|
|
|
$("h1").html("暂时没有数据");
|
|
|
+ adjustHeight()
|
|
|
$(".anchors").css("display", "none");
|
|
|
return;
|
|
|
}
|
|
|
var list = data.details;
|
|
|
- $("h1").html(showName);
|
|
|
+
|
|
|
// $("h1").css({
|
|
|
// "color": "#267FD7",
|
|
|
// "borderBottom": "4px solid #E9E9E9",
|
|
|
// "padding": "0px 60px 50px 0px"
|
|
|
// });
|
|
|
- for (var i = 0; i < list.length; i++) {
|
|
|
- item = list[i];
|
|
|
- item.content = item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
|
|
|
- anchors = '<li><i></i><a href="#' + item.title +
|
|
|
- '">' + item.title + '</a></li><li class="anchor-line"></li>';
|
|
|
- str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> <span></div> <h2 class="titleH2" id="' + item.title +
|
|
|
- '">'
|
|
|
- if (getUrlArgObject('type') == 8) {
|
|
|
- str += '【' + item.title + '】'
|
|
|
- } else {
|
|
|
- str += item.title
|
|
|
+ if(param.type == 82 || param.type == 83){
|
|
|
+ for (var i = 0; i < list.length; i++) {
|
|
|
+ item = list[i];
|
|
|
+ let contentObj = JSON.parse(item.content)
|
|
|
+ // anchors = '<li><i></i><a href="#' + item.title +
|
|
|
+ // '">' + item.title + '</a></li><li class="anchor-line"></li>';
|
|
|
+ // str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> <span></div> <h2 class="titleH2" id="' + item.title +
|
|
|
+ // '">'
|
|
|
+ // if (getUrlArgObject('type') == 8) {
|
|
|
+ // str += '【' + item.title + '】'
|
|
|
+ // } else {
|
|
|
+ // str += item.title
|
|
|
+ // }
|
|
|
+ // str += '</h2></div>' +
|
|
|
+ // '<div><pre>' + item.content + '</pre><div></div>';
|
|
|
+ // str = `<div class="infoWrapper">${str}</div>`
|
|
|
+ // $(".infos").append(str);
|
|
|
+ $(".anchors").css("display","none");
|
|
|
+ // $(".anchors ul").append(anchors);
|
|
|
+ str = `<div class="downBox">
|
|
|
+ <p class="txtBox"><img style="top:${param.type == '82' ? '11px':'7px'}" class="downImg" src="${param.type == '82' ? TxtICon:VedioIcon}">${item.title}</p>
|
|
|
+ <p class="sizeBox">文件大小${contentObj.size}</p>
|
|
|
+ <div class="BtnBox"><span class="download" data-url="${contentObj.url}" data-title="${contentObj.name}">下载</span></div>
|
|
|
+ </div>`
|
|
|
}
|
|
|
- str += '</h2></div>' +
|
|
|
- '<div><pre>' + item.content + '</pre><div></div>';
|
|
|
- str = `<div class="infoWrapper">${str}</div>`
|
|
|
$(".infos").append(str);
|
|
|
- $(".anchors ul").append(anchors);
|
|
|
+ downLoadFile()
|
|
|
+ }else{
|
|
|
+ $("h1").html(showName);
|
|
|
+ for (var i = 0; i < list.length; i++) {
|
|
|
+ item = list[i];
|
|
|
+ item.content = item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
|
|
|
+ anchors = '<li><i></i><a href="#'+item.title.trim()+'">' + item.title + '</a></li><li class="anchor-line"></li>';
|
|
|
+ str = '<div class="infoBox"><div class="title"> <div class= "circleBox"><span class="circle"> </span></div> <h2 class="titleH2" id="' + item.title.trim() +
|
|
|
+ '">'
|
|
|
+ if (getUrlArgObject('type') == 8) {
|
|
|
+ str += '【' + item.title + '】'
|
|
|
+ } else {
|
|
|
+ str += item.title
|
|
|
+ }
|
|
|
+ str += '</h2></div>' +
|
|
|
+ '<div class="contentWrapper"><pre>' + item.content + '</pre><div></div>';
|
|
|
+ str = `<div class="infoWrapper">${str}</div>`
|
|
|
+ $(".infos").append(str);
|
|
|
+ $(".anchors ul").append(anchors);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
addLinkClickEvent();
|
|
|
adjustHeight();
|
|
|
+ adjustWidth()
|
|
|
$('.content img').bind('contextmenu', function(){
|
|
|
return false
|
|
|
})
|
|
@@ -66,10 +119,11 @@ function getInfomation() {
|
|
|
var scrollTop = $('.infos').scrollTop()
|
|
|
var divHeight = 0;
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
- divHeight = divHeight + parseInt($('#' + list[i].title).css('height')) + parseInt($('#' + list[i].title).parent().next().css('height')) + 40
|
|
|
+ divHeight = divHeight + parseInt($('#' + list[i].title.trim()).css('height')) + parseInt($('#' + list[i].title.trim()).parent().next().css('height')) + 30
|
|
|
if (divHeight > scrollTop) {
|
|
|
- var anchor = 2 * i;
|
|
|
+ var anchor = 2 * (i);
|
|
|
$('.anchors ul').children().eq(anchor).addClass('active').siblings().removeClass('active');
|
|
|
+ setBackground()
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -80,17 +134,159 @@ function getInfomation() {
|
|
|
getInfomation();
|
|
|
|
|
|
function addLinkClickEvent() {
|
|
|
- $("li:first").addClass("active");
|
|
|
- $("li>a").on("click", function () {
|
|
|
+ $(".anchors ul li:first").addClass("active");
|
|
|
+ setBackground()
|
|
|
+ $(".anchors ul li>a").on("click", function () {
|
|
|
$(".active").removeClass('active');
|
|
|
$(this).parent().addClass("active");
|
|
|
+ setBackground()
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+function setBackground(){
|
|
|
+ $(".anchors i").css({
|
|
|
+ background:"#E0E2E3"
|
|
|
+ })
|
|
|
+ $(".anchors .active i").css({
|
|
|
+ background:`url(${currentIcon}) center center no-repeat`
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function downLoadFile() {
|
|
|
+ $(".download").on("click", function(){
|
|
|
+ const downUrl = $(this).attr('data-url')
|
|
|
+ const url = isLocal ?'http://192.168.2.236:82'+downUrl + '?download=1' : 'http://'+window.location.hostname+':82'+downUrl + '?download=1'
|
|
|
+ const downTitle = $(this).attr('data-title')
|
|
|
+ // download(url, downTitle)
|
|
|
+ downLoadFileIe(url, downTitle)
|
|
|
+ })
|
|
|
+
|
|
|
+ // var $form = $('<form method="GET"></form>');
|
|
|
+ // $form.attr('action', url);
|
|
|
+ // $form.appendTo($('body'));
|
|
|
+ // $form.submit();
|
|
|
+
|
|
|
+// const ele = document.createElement('a');
|
|
|
+// ele.setAttribute('download' , 'download');//用于设置下载文件的文件名
|
|
|
+
|
|
|
+// ele.setAttribute('href',url); //设置下载文件的url地址
|
|
|
+
|
|
|
+
|
|
|
+// ele.click();
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+// function getBlob(url,cb) {
|
|
|
+// var xhr = new XMLHttpRequest();
|
|
|
+// xhr.open('GET', url, true);
|
|
|
+// xhr.responseType = 'blob';
|
|
|
+// xhr.onload = function() {
|
|
|
+// if (xhr.status === 200) {
|
|
|
+// cb(xhr.response);
|
|
|
+// }
|
|
|
+// };
|
|
|
+// xhr.send();
|
|
|
+// }
|
|
|
+// function saveAs(blob, filename) {
|
|
|
+// if (window.navigator.msSaveOrOpenBlob) {
|
|
|
+// navigator.msSaveBlob(blob, filename);
|
|
|
+// } else {
|
|
|
+// var link = document.createElement('a');
|
|
|
+// var body = document.querySelector('body');
|
|
|
+
|
|
|
+// link.href = window.URL.createObjectURL(blob);
|
|
|
+// link.download = filename;
|
|
|
+
|
|
|
+// // fix Firefox
|
|
|
+// link.style.display = 'none';
|
|
|
+// body.appendChild(link);
|
|
|
+
|
|
|
+// link.click();
|
|
|
+// body.removeChild(link);
|
|
|
+
|
|
|
+// window.URL.revokeObjectURL(link.href);
|
|
|
+// };
|
|
|
+// }
|
|
|
+// function download(url, filename){
|
|
|
+// getBlob(url, function(blob) {
|
|
|
+// saveAs(blob, filename);
|
|
|
+// });
|
|
|
+// }
|
|
|
+function adjustWidth() {
|
|
|
+ var wt = window.innerWidth || document.documentElement.clientWidth;
|
|
|
+ $(".titleH2").width(wt- 0.2*wt -33 - 200 - 17 - 20 + 'px')
|
|
|
+ $(".contentWrapper").width(wt- 0.2*wt -33 - 200 - 17 -15 + 'px')
|
|
|
+}
|
|
|
+
|
|
|
function adjustHeight() {
|
|
|
- var ht = window.innerHeight;
|
|
|
- $(".content").height(ht - 145 + "px");
|
|
|
+ var ht = window.innerHeight || document.documentElement.clientHeight;
|
|
|
+ $(".content").height(ht - 145+32 + "px");
|
|
|
+ if(getUrlArgObject('type') == 82 || getUrlArgObject('type') == 83){
|
|
|
+ $(".content").height(ht - 105+32 + "px");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
$(window).on('resize', function(){
|
|
|
adjustHeight()
|
|
|
+ adjustWidth()
|
|
|
})
|
|
|
|
|
|
+$('img').on("mouuseenter",function(){
|
|
|
+ return false
|
|
|
+})
|
|
|
+function downLoadFileIe (url, name) {
|
|
|
+ if (!!window.ActiveXObject || "ActiveXObject" in window) {
|
|
|
+ //ie
|
|
|
+ var oPow = window.open(url, "", "width = 1, height = 1, top = 5000, left = 5000 ");
|
|
|
+ var isOpen = true; //判断window.open是否被禁用
|
|
|
+ try {
|
|
|
+ if (oPow == null) {
|
|
|
+ isOpen = false
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ isOpen = false
|
|
|
+ }
|
|
|
+ if (isOpen) {
|
|
|
+ //没禁用window.open采用window.open下载
|
|
|
+ // while (oPow.document.readyState !== "complete") {
|
|
|
+ // if (oPow.document.readyState === "complete") break;
|
|
|
+ // }
|
|
|
+ oPow.document.execCommand("SaveAs", true, name);
|
|
|
+ oPow.close();
|
|
|
+ } else {
|
|
|
+ //禁用了window.open采用iframe下载
|
|
|
+ var oIrame = document.createElement('iframe');
|
|
|
+ oIrame.style.width = "0px";
|
|
|
+ oIrame.style.height = "0px";
|
|
|
+ oIrame.style.opacity = 1;
|
|
|
+ document.body.appendChild(oIrame)
|
|
|
+ oIrame.src = url;
|
|
|
+ var IfDoc = oIrame.contentDocument || oIrame.document;
|
|
|
+ oIrame.onreadystatechange = function () { // IE下的节点都有onreadystatechange这个事件
|
|
|
+ if (oIrame.readyState == "complete") {
|
|
|
+ // oIrame.execCommand("SaveAs", true, name)
|
|
|
+ document.body.removeChild(oIrame)
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (typeof url == 'object' && url instanceof Blob) {
|
|
|
+ url = URL.createObjectURL(url); // 创建blob地址
|
|
|
+ }
|
|
|
+ var aLink = document.createElement('a');
|
|
|
+ aLink.href = url;
|
|
|
+ aLink.download = name || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
|
|
|
+ var event;
|
|
|
+ if (window.MouseEvent) {
|
|
|
+ event = new MouseEvent('click');
|
|
|
+ } else {
|
|
|
+ if (document.createEvent) {
|
|
|
+ event = document.createEvent('MouseEvents');
|
|
|
+ event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ aLink.dispatchEvent(event);
|
|
|
+ }
|
|
|
+}
|