/**放大*/ function viewImg(item) { layer.photos({ shade: 0.5, footer: false, photos: { "title": "图片预览", "start": 0, "data": [ { "pid": 1, "src": imgUrl + item.originalFilePath + "?token=" + tokens, } ] }, }); } /**原图下载*/ function imgDownLoad(item, type) { let path = type === 1 ? item.originalFilePath : item.watermarkFilePath; let obj = { imgPath: path, } let loadingMsg = layer.msg("照片下载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); let url = dataUrl + "/common/download/downloadImage?token=" + tokens + "&encryptedData=" + encodeURIComponent(encryptCBC(JSON.stringify(obj))); let xhr = new XMLHttpRequest(); xhr.open("get", url, true); xhr.responseType = "blob"; // 转换流 xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8') xhr.onload = function () { layer.close(loadingMsg); if (this.status === 200) { let blob = this.response; var a = document.createElement("a"); var url = window.URL.createObjectURL(blob); a.href = url; a.download = path.substring(path.lastIndexOf('/') + 1, path.length); // 文件名 } else { layer.msg("照片下载发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000}); } a.click(); window.URL.revokeObjectURL(url); }; xhr.send(); }