Commit 67b35959 by gao_yingdong

水印

parent b314c267
......@@ -43,12 +43,12 @@ const LoadingCons = Vue.extend(Nsloading);
Vue.prototype.$util = Util;
window.util = Util;
Vue.use(VueWechatTitle);
let userInfo = window.sessionStorage.getItem("userInfo") || "";
if (userInfo) {
userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"))
let info = `${userInfo.realname} ${userInfo.identitycard}`
Watermark.set(userInfo.realname, userInfo.userName, userInfo.identitycard, userInfo.ip)
}
// let userInfo = window.sessionStorage.getItem("userInfo") || "";
// if (userInfo) {
// userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"))
// let info = `${userInfo.realname} ${userInfo.identitycard}`
// Watermark.set(userInfo.realname, userInfo.userName, userInfo.identitycard, userInfo.ip)
// }
Vue.directive("nsLoading", {
bind(el, binding) {
......
......@@ -7,6 +7,9 @@ import indexRoutes from "./modules/index";
import rightContentRoutes from "./modules/rightContent";
import zdryglRoutes from "./modules/zdrygl";
import specialRoutes from "./modules/specialData";
import moment from 'moment'
import Watermark from '@/utils/watermark';
import Watermark1 from '@/utils/watermark1';
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
......@@ -62,5 +65,25 @@ const router = new VueRouter({
// }
// next();
// });
router.afterEach((to) => {
var userInfo = JSON.parse(sessionStorage.userInfo);
// 身份证 和 姓名
let one = userInfo.identitycard.replace(
/^(.{10})(?:\d+)(.{4})$/,
"$1****$2"
) + ' ' + userInfo.realname
// 当前登录时间
let two = moment().format('YYYY-MM-DD HH:mm:ss')
// 1p 和 系统名
let three = (userInfo.ip == undefined || userInfo.ip == null) ? '' : userInfo.ip + ' ' + '全国刑侦类案标注子系统'
// 公安厅名称
if (to.path != '/login' && to.path != '/home' && to.path != '/kshData') {
Watermark.set(one, two, three, userInfo.unitname == null ? '' : userInfo.unitname, "")
} else if (to.path == '/home' || to.path == '/kshData') {
Watermark1.set(one, two, three, userInfo.unitname == null ? '' : userInfo.unitname, "")
} else {
Watermark.set('', '', '', '', "")
}
});
export default router;
let watermark = {}
let setWatermark = (str,str3,str4,str5) => {
let setWatermark = (str1, str2, str3, str4, str5) => {
let id = '1.23452384164.123412415'
if (document.getElementById(id) !== null) {
......@@ -8,44 +10,46 @@ let setWatermark = (str,str3,str4,str5) => {
}
let can = document.createElement('canvas')
can.width = 300
can.height = 230
can.width = 600
can.height = 400
let cans = can.getContext('2d')
cans.rotate(-20 * Math.PI / 180)
cans.font = '13px Vedana'
cans.fillStyle = 'rgba(0, 0, 0, 0.1)'
cans.font = '16px Vedana'
cans.fillStyle = 'rgba(0, 0, 0, 0.3)'
// cans.fillStyle = 'red'
cans.textAlign = 'left'
cans.textBaseline = 'Middle'
cans.fillText(str, can.width / 3, can.height / 2)
cans.fillText(str3, can.width / 3, can.height / 1.73)
cans.fillText(str4, can.width / 3, can.height / 1.55)
cans.fillText(str5, can.width / 3, can.height / 1.38)
cans.fillText(str1, can.width / 5, can.height / 2)
cans.fillText(str2, can.width / 5, can.height / 1.7)
cans.fillText(str3, can.width / 5, can.height / 1.5)
cans.fillText(str4, can.width / 5, can.height / 1.35)
cans.fillText(str5, can.width / 5, can.height / 1.23)
let div = document.createElement('div')
div.id = id
div.style.pointerEvents = 'none'
div.style.top = '70px'
div.style.left = '50px'
div.style.top = '10px'
div.style.left = '10px'
div.style.position = 'fixed'
div.style.zIndex = '100000'
div.style.width = document.documentElement.clientWidth - 125 + 'px'
div.style.height = document.documentElement.clientHeight - 125 + 'px'
div.style.width = document.documentElement.clientWidth - 10 + 'px'
div.style.height = document.documentElement.clientHeight - 10 + 'px'
div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
document.body.appendChild(div)
return id
}
// 该方法只允许调用一次
watermark.set = (str,str3,str4,str5) => {
let id = setWatermark(str,str3,str4,str5)
watermark.set = (str1, str2, str3, str4, str5) => {
let id = setWatermark(str1, str2, str3, str4, str5)
setInterval(() => {
if (document.getElementById(id) === null) {
id = setWatermark(str,str3,str4,str5)
id = setWatermark(str1, str2, str3, str4, str5)
}
}, 500)
window.onresize = () => {
setWatermark(str,str3,str4,str5)
setWatermark(str1, str2, str3, str4, str5)
}
}
export default watermark
let watermark = {}
let setWatermark = (str1,str2,str3,str4,str5) => {
let id = '1.23452384164.123412415'
if (document.getElementById(id) !== null) {
document.body.removeChild(document.getElementById(id))
}
let can = document.createElement('canvas')
can.width = 600
can.height = 400
let cans = can.getContext('2d')
cans.rotate(-20 * Math.PI / 180)
cans.font = '16px Vedana'
cans.fillStyle = 'rgba(255, 255, 255, 0.3)'
// cans.fillStyle = 'red'
cans.textAlign = 'left'
cans.textBaseline = 'Middle'
cans.fillText(str1, can.width / 5, can.height / 2)
cans.fillText(str2, can.width / 5, can.height / 1.7)
cans.fillText(str3, can.width / 5, can.height / 1.5)
cans.fillText(str4, can.width / 5, can.height / 1.35)
cans.fillText(str5, can.width / 5, can.height / 1.23)
let div = document.createElement('div')
div.id = id
div.style.pointerEvents = 'none'
div.style.top = '10px'
div.style.left = '10px'
div.style.position = 'fixed'
div.style.zIndex = '100000'
div.style.width = document.documentElement.clientWidth - 10 + 'px'
div.style.height = document.documentElement.clientHeight - 10 + 'px'
div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
document.body.appendChild(div)
return id
}
// 该方法只允许调用一次
watermark.set = (str1,str2,str3,str4,str5) => {
let id = setWatermark(str1,str2,str3,str4,str5)
setInterval(() => {
if (document.getElementById(id) === null) {
id = setWatermark(str1,str2,str3,str4,str5)
}
}, 500)
window.onresize = () => {
setWatermark(str1,str2,str3,str4,str5)
}
}
export default watermark
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment