修改PDF样式

This commit is contained in:
2025-09-05 15:33:06 +08:00
parent c59a113add
commit a4de210c79
3 changed files with 16 additions and 8 deletions
@@ -73,7 +73,7 @@
if (item != "" && (item.indexOf(".mp4") > -1 || item.indexOf(".MP4") > -1)) {
html += "<video src='" + item + "' class='layui-upload-img' style='width: 50px;height: 50px;margin-right: 5px;' onclick='delImage(\"" + index + "\")'/>";
} else if (item != "" && (item.indexOf(".PDF") > -1 || item.indexOf(".pdf") > -1)) {
html += "<img src='https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/priceImages/20250905/PDF.png' class='layui-upload-img' style='width: 40px;height: 40px;margin-right: 5px;' onclick='viewImage(\"" + item + "\")'/>";
html += "<img src='https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/priceImages/20250905/PDF.png' class='layui-upload-img' style='width: 40px;height: 40px;margin-right: 5px;' onclick='delImage(\"" + item + "\")'/>";
} else if (item != "") {
html += "<img src='" + item + "' class='layui-upload-img' style='width: 50px;height: 50px;margin-right: 5px;' onclick='delImage(\"" + index + "\")'/>";
}
@@ -70,12 +70,16 @@
</style>
<script type="text/javascript">
function viewImage(item) {
let width = "400px";
let length = "400px";
let html = "<div style='width: 100%;height: 100%;display: flex;align-items: center;justify-content: center'>";
if (item != "" && (item.indexOf(".mp4") > -1 || item.indexOf(".MP4") > -1)) {
html += "<video src='" + item + "' class='layui-upload-img' controls style='width: 400px;height: 400px;margin-right: 5px;'/>";
} else if (item != "" && (item.indexOf(".PDF") > -1 || item.indexOf(".pdf") > -1)) {
let pdfUrl = "/js/pdf/web/viewer.html?file=" + item.replace("https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/", "http://imagediy.lingtao8.com/");
html += "<iframe src='" + pdfUrl + "' style='width: 400px;height: 400px;margin-right: 5px;'/>";
let pdfUrl = "/js/pdf/web/viewer.html?file=" + item;
width = "800px";
length = "700px";
html += "<iframe src='" + pdfUrl + "' style='width: " + width + ";height: " + length + ";margin-right: 5px;'/>";
} else if (item != "") {
html += "<img src='" + item + "' class='layui-upload-img' style='width: 400px;height: 400px;margin-right: 5px;'/>";
}
@@ -85,7 +89,7 @@
title: false,
closeBtn: 0,
offset: 'auto',
area: ['400px', '400px'],
area: [width, length],
skin: 'layui-layer-nobg', //没有背景色
shadeClose: true,
content: html
@@ -235,7 +239,7 @@
if (item != "" && (item.indexOf(".mp4") > -1 || item.indexOf(".MP4") > -1)) {
html += "<video src='" + item + "' class='layui-upload-img' style='width: 50px;height: 50px;margin-right: 5px;' onclick='delImage(\"" + index + "\")'/>";
} else if (item != "" && (item.indexOf(".PDF") > -1 || item.indexOf(".pdf") > -1)) {
html += "<img src='https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/priceImages/20250905/PDF.png' class='layui-upload-img' style='width: 40px;height: 40px;margin-right: 5px;' onclick='viewImage(\"" + item + "\")'/>";
html += "<img src='https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/priceImages/20250905/PDF.png' class='layui-upload-img' style='width: 40px;height: 40px;margin-right: 5px;' onclick='delImage(\"" + index + "\")'/>";
} else if (item != "") {
html += "<img src='" + item + "' class='layui-upload-img' style='width: 50px;height: 50px;margin-right: 5px;' onclick='delImage(\"" + index + "\")'/>";
}
@@ -58,12 +58,16 @@
</style>
<script type="text/javascript">
function viewImage(item) {
let width = "400px";
let length = "400px";
let html = "<div style='width: 100%;height: 100%;display: flex;align-items: center;justify-content: center'>";
if (item != "" && (item.indexOf(".mp4") > -1 || item.indexOf(".MP4") > -1)) {
html += "<video src='" + item + "' class='layui-upload-img' controls style='width: 400px;height: 400px;margin-right: 5px;'/>";
} else if (item != "" && (item.indexOf(".PDF") > -1 || item.indexOf(".pdf") > -1)) {
let pdfUrl = "/js/pdf/web/viewer.html?file=" + item.replace("https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/", "http://imagediy.lingtao8.com/");
html += "<iframe src='" + pdfUrl + "' style='width: 400px;height: 400px;margin-right: 5px;'/>";
let pdfUrl = "/js/pdf/web/viewer.html?file=" + item;
width = "800px";
length = "700px";
html += "<iframe src='" + pdfUrl + "' style='width: " + width + ";height: " + length + ";margin-right: 5px;'/>";
} else if (item != "") {
html += "<img src='" + item + "' class='layui-upload-img' style='width: 400px;height: 400px;margin-right: 5px;'/>";
}
@@ -73,7 +77,7 @@
title: false,
closeBtn: 0,
offset: 'auto',
area: ['400px', '400px'],
area: [width, length],
skin: 'layui-layer-nobg', //没有背景色
shadeClose: true,
content: html