|
|
@ -11,11 +11,11 @@ const exts = { |
|
|
|
doc: 'doc,docx,txt,xls,xlsx,csv,xml,ppt,pptx' |
|
|
|
doc: 'doc,docx,txt,xls,xlsx,csv,xml,ppt,pptx' |
|
|
|
} |
|
|
|
} |
|
|
|
// 各个站点首页的路径
|
|
|
|
// 各个站点首页的路径
|
|
|
|
const indexPath = ['/home', '/sfel', '/estate/index', '/iasf'] |
|
|
|
const indexPath = ['/home', '/sfel', '/estate/index'] |
|
|
|
const util = { |
|
|
|
const util = { |
|
|
|
local: _local, |
|
|
|
local: _local, |
|
|
|
//返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss"
|
|
|
|
//返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss"
|
|
|
|
formatDate(fmt, date) { |
|
|
|
formatDate (fmt, date) { |
|
|
|
var date = date ? date : new Date(); |
|
|
|
var date = date ? date : new Date(); |
|
|
|
var o = { |
|
|
|
var o = { |
|
|
|
"M+": date.getMonth() + 1, //月份
|
|
|
|
"M+": date.getMonth() + 1, //月份
|
|
|
@ -37,31 +37,31 @@ const util = { |
|
|
|
return fmt; |
|
|
|
return fmt; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 传入文件后缀判断是否是视频
|
|
|
|
// 传入文件后缀判断是否是视频
|
|
|
|
isVideo(ext) { |
|
|
|
isVideo (ext) { |
|
|
|
if (exts.video.includes(ext)) return true; |
|
|
|
if (exts.video.includes(ext)) return true; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 传入文件后缀判断是否是音频
|
|
|
|
// 传入文件后缀判断是否是音频
|
|
|
|
isAudio(ext) { |
|
|
|
isAudio (ext) { |
|
|
|
if (exts.audio.includes(ext)) return true; |
|
|
|
if (exts.audio.includes(ext)) return true; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 传入文件后缀判断是否是图片
|
|
|
|
// 传入文件后缀判断是否是图片
|
|
|
|
isImg(ext) { |
|
|
|
isImg (ext) { |
|
|
|
if (exts.img.includes(ext)) return true; |
|
|
|
if (exts.img.includes(ext)) return true; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 传入文件后缀判断是否是pdf以外的文档
|
|
|
|
// 传入文件后缀判断是否是pdf以外的文档
|
|
|
|
isDoc(ext) { |
|
|
|
isDoc (ext) { |
|
|
|
if (exts.doc.includes(ext)) return true; |
|
|
|
if (exts.doc.includes(ext)) return true; |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 传入文件名和路径,下载图片视频,支持跨域,a标签加download不支持跨域
|
|
|
|
// 传入文件名和路径,下载图片视频,支持跨域,a标签加download不支持跨域
|
|
|
|
downloadFile(fileName, url) { |
|
|
|
downloadFile (fileName, url) { |
|
|
|
var x = new XMLHttpRequest(); |
|
|
|
var x = new XMLHttpRequest(); |
|
|
|
x.open("GET", url, true); |
|
|
|
x.open("GET", url, true); |
|
|
|
x.responseType = "blob"; |
|
|
|
x.responseType = "blob"; |
|
|
|
x.onload = function(e) { |
|
|
|
x.onload = function (e) { |
|
|
|
var url = window.URL.createObjectURL(x.response); |
|
|
|
var url = window.URL.createObjectURL(x.response); |
|
|
|
var a = document.createElement("a"); |
|
|
|
var a = document.createElement("a"); |
|
|
|
a.href = url; |
|
|
|
a.href = url; |
|
|
@ -71,7 +71,7 @@ const util = { |
|
|
|
x.send(); |
|
|
|
x.send(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 传入文件名和数据,下载文件
|
|
|
|
// 传入文件名和数据,下载文件
|
|
|
|
downloadFileDirect(fileName,data) { |
|
|
|
downloadFileDirect (fileName, data) { |
|
|
|
if ('download' in document.createElement('a')) { // 非IE下载
|
|
|
|
if ('download' in document.createElement('a')) { // 非IE下载
|
|
|
|
const elink = document.createElement('a') |
|
|
|
const elink = document.createElement('a') |
|
|
|
elink.download = fileName |
|
|
|
elink.download = fileName |
|
|
@ -86,7 +86,7 @@ const util = { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 成功提示
|
|
|
|
// 成功提示
|
|
|
|
successMsg(message, duration = 3000) { |
|
|
|
successMsg (message, duration = 3000) { |
|
|
|
Message.closeAll(); |
|
|
|
Message.closeAll(); |
|
|
|
return Message.success({ |
|
|
|
return Message.success({ |
|
|
|
message, |
|
|
|
message, |
|
|
@ -95,7 +95,7 @@ const util = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 警告提示
|
|
|
|
// 警告提示
|
|
|
|
warningMsg(message, duration = 3000) { |
|
|
|
warningMsg (message, duration = 3000) { |
|
|
|
Message.closeAll(); |
|
|
|
Message.closeAll(); |
|
|
|
return Message.warning({ |
|
|
|
return Message.warning({ |
|
|
|
message, |
|
|
|
message, |
|
|
@ -104,7 +104,7 @@ const util = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 错误提示
|
|
|
|
// 错误提示
|
|
|
|
errorMsg(message, duration = 3000) { |
|
|
|
errorMsg (message, duration = 3000) { |
|
|
|
Message.closeAll(); |
|
|
|
Message.closeAll(); |
|
|
|
return Message.error({ |
|
|
|
return Message.error({ |
|
|
|
message, |
|
|
|
message, |
|
|
@ -113,10 +113,10 @@ const util = { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 去掉html里的标签及空格
|
|
|
|
// 去掉html里的标签及空格
|
|
|
|
removeTag(list, prop = 'mainBody') { |
|
|
|
removeTag (list, prop = 'mainBody') { |
|
|
|
list.map(e => { |
|
|
|
list.map(e => { |
|
|
|
// 有摘要取摘要,没有摘要就去掉正文里的标签空格(也可以通过正则去除html标签,不过富文本里会有插入IE注释的情况下,直接创建一个元素取text比较简单)
|
|
|
|
// 有摘要取摘要,没有摘要就去掉正文里的标签空格(也可以通过正则去除html标签,不过富文本里会有插入IE注释的情况下,直接创建一个元素取text比较简单)
|
|
|
|
const text = e.summary || e[prop].replace(/(<p class="img-des">[^>]+<\/p>)|(( )+)/g , '') |
|
|
|
const text = e.summary || e[prop].replace(/(<p class="img-des">[^>]+<\/p>)|(( )+)/g, '') |
|
|
|
const el = document.createElement('div') |
|
|
|
const el = document.createElement('div') |
|
|
|
el.innerHTML = text |
|
|
|
el.innerHTML = text |
|
|
|
// e.mainBody = e.summary || e[prop].replace(/(<p class="img-des">[^>]+<\/p>)|(<\!--[^-->]+-->)|(<[^>]+>)|(( )+)/g , '')
|
|
|
|
// e.mainBody = e.summary || e[prop].replace(/(<p class="img-des">[^>]+<\/p>)|(<\!--[^-->]+-->)|(<[^>]+>)|(( )+)/g , '')
|
|
|
@ -126,28 +126,28 @@ const util = { |
|
|
|
return list |
|
|
|
return list |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 获取url里的参数
|
|
|
|
// 获取url里的参数
|
|
|
|
getQuery(name) { |
|
|
|
getQuery (name) { |
|
|
|
let url = window.location.href |
|
|
|
let url = window.location.href |
|
|
|
let param = new Object() |
|
|
|
let param = new Object() |
|
|
|
if (url.indexOf("?") != -1) { |
|
|
|
if (url.indexOf("?") != -1) { |
|
|
|
let str = url.split('?')[1] |
|
|
|
let str = url.split('?')[1] |
|
|
|
let strs = str.split("&") |
|
|
|
let strs = str.split("&") |
|
|
|
for(var i = 0; i < strs.length; i ++) { |
|
|
|
for (var i = 0; i < strs.length; i++) { |
|
|
|
param[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]) |
|
|
|
param[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return param[name] || null |
|
|
|
return param[name] || null |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 是否是各个站点的首页,首页的导航样式不一样,所以要单独判断
|
|
|
|
// 是否是各个站点的首页,首页的导航样式不一样,所以要单独判断
|
|
|
|
isIndex() { |
|
|
|
isIndex () { |
|
|
|
return indexPath.includes(Router.app.$route.path) |
|
|
|
return indexPath.includes(Router.app.$route.path) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 传入站点id,判断是否英文
|
|
|
|
// 传入站点id,判断是否英文
|
|
|
|
isEn(id) { |
|
|
|
isEn (id) { |
|
|
|
return Setting.enIds.includes(+id) |
|
|
|
return Setting.enIds.includes(+id) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// rsa加密(这里无需加密,但是全部页面的请求都有调这个方法,因此直接返回即可)
|
|
|
|
// rsa加密(这里无需加密,但是全部页面的请求都有调这个方法,因此直接返回即可)
|
|
|
|
rsa(data) { |
|
|
|
rsa (data) { |
|
|
|
return data |
|
|
|
return data |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|