'use strict'; let watermark = {}; watermark.set = (path) => { let id = '1.23452384164.123412415'; // #ifdef H5 if (document.getElementById(id) !== null) { document.body.removeChild(document.getElementById(id)); } let div = document.createElement('div'); div.id = id; div.style.pointerEvents = 'none'; div.style.top = '100vw'; div.style.left = '100vh'; div.style.fontSize = '50px'; div.style.position = 'fixed'; div.style.zIndex = '100000'; div.style.zoom = '0.6'; //设置缩放 div.style.opacity = '0.5'; //设置透明度 div.style.background = 'url(' + path + ') center no-repeat'; div.innerText = '货物优测试' document.body.appendChild(div); return id; // #endif // #ifdef APP-PLUS if (plus.nativeObj.View.getViewById(id) !== null) { plus.nativeObj.View.getViewById(id).close(); } uni.getSystemInfo({ success: function(res) { //水印排列行数 let row = Math.floor(res.windowHeight / uni.upx2px(500)); let tarArr = []; for (let i = 0; i < row; i++) { for (let j = 0; j < 1; j++) { tarArr.push({ tag: 'img', src: path, position: { top: (uni.upx2px(500) * i) + 'px', left: (uni.upx2px(500) * j) + 'px', width: uni.upx2px(500) + 'px', height: uni.upx2px(500) + 'px' } }); } } var watermarkView = new plus.nativeObj.View(id, { top: '70px', left: '0px', right: '0px', bottom: '50px' }, tarArr); //拦截View控件的触屏事件,将事件穿透给下一层view watermarkView.interceptTouchEvent(false); watermarkView.show(); } }); // #endif } export default watermark;