printPreview.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5. <meta http-equiv="pragma" content="no-cache" />
  6. <meta http-equiv="content-type" content="no-cache, must-revalidate" />
  7. <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT" />
  8. <title></title>
  9. <script>document.write("<link href='AFrontEnd/css/special.css?time=" + new Date().getTime() + "' rel='stylesheet'>");</script>
  10. <script src="AFrontEnd/js/jquery/jquery-1.8.3.min.js"></script>
  11. <script src="apiurljs.js"></script>
  12. </head>
  13. <body>
  14. <button class="sp-btn-blue sp-pull-right" onclick="window.open(ipChange(url))">下载</button>
  15. <button class="sp-btn-blue sp-pull-right pc" style="display:none" onclick="javascript: window.close();">
  16. 关 闭
  17. </button>
  18. <button class="sp-btn-blue sp-pull-right pad" style="display:none" onclick="javascript: history.go(-1);">
  19. 关 闭
  20. </button>
  21. <iframe id="printPreview"></iframe>
  22. <script>
  23. if (localStorage.getItem("tjJxtGoldenlinkWork-deviceType") != "pad") {
  24. $(".pc").show()
  25. } else {
  26. $(".pad").show()
  27. }
  28. function ipChange(ip) {
  29. return window.location.origin + ip.slice(7).slice(ip.slice(7).indexOf("/"))
  30. }
  31. var params = "?" + location.search
  32. var url = params.match(new RegExp("[\?\&]url=([^\&]+)", "i"))[1];
  33. if (url.indexOf("doc") != -1) {
  34. set_convertType = 0;
  35. } else if (url.indexOf("pdf") != -1) {
  36. set_convertType = 20;
  37. } else if (url.indexOf("ofd") != -1) {
  38. set_convertType = 570;
  39. } else {
  40. set_convertType = 0;
  41. }
  42. $.ajax({
  43. url: apiurljs.login.split("glwork")[0] + "fcscloud/composite/httpfile",
  44. type: "post",
  45. dataType: 'json',
  46. contentType: "application/x-www-form-urlencoded",
  47. data: {
  48. convertType: set_convertType,
  49. fileUrl: url,
  50. isPrint: 1,
  51. isDownload: 1
  52. },
  53. success: function (res) {
  54. if (res.errorcode === 0) {
  55. let rst = res.data;
  56. console.log("原输出地址:" + rst.viewUrl)
  57. $("#printPreview").css("width", $(window).width()).css("height", $(window).height())
  58. $("#printPreview").attr("src", ipChange(rst.viewUrl))
  59. console.log("IP替换地址:" + ipChange(rst.viewUrl))
  60. if (ipChange(rst.viewUrl).indexOf(window.location.origin) == -1) {
  61. console.log("请您清除浏览器缓存后重试!")
  62. }
  63. } else {
  64. console.log(res.message);
  65. }
  66. }
  67. })
  68. </script>
  69. </body>
  70. </html>