codeToFile.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>商品资料页</title>
  6. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  7. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  8. <style>
  9. .img-margin{
  10. margin: 60pt 0 30pt 30pt;
  11. }
  12. .title-div{
  13. width:100%;
  14. height:50px;
  15. margin:0 0 20pt 30pt
  16. }
  17. .title-font{
  18. font-size: 40pt;
  19. height:50px;
  20. line-height: 50px;
  21. vertical-align: auto;
  22. text-align: left;
  23. color: #333333;
  24. font-weight: bold
  25. }
  26. .margin-style{
  27. margin:0 30pt 20pt 30pt
  28. }
  29. .div-border{
  30. width: 100%;
  31. height: 150px;
  32. border-radius: 8pt;
  33. border: #cccccc solid 1px;
  34. display: flex;
  35. justify-content: left;
  36. margin-bottom: 20px;
  37. }
  38. .img-style{
  39. width: 90px;
  40. height: 90px;
  41. margin: 28px 0 0 20px;
  42. }
  43. .content-style{
  44. font-size: 30px;
  45. color: #333333;
  46. margin: 30px 20px 0 20px;
  47. }
  48. </style>
  49. </head>
  50. <body>
  51. <img src="./img/bnBag.png" width="85%" height="180px" class="img-margin">
  52. <div class="title-div">
  53. <div class="title-font" >产品技术资料</div>
  54. </div>
  55. <div class="margin-style" id="dataContainer"></div>
  56. <script>
  57. window.onload = async function(){
  58. var loc=location.href;
  59. var n1=loc.length;
  60. var n2=loc.indexOf('=');
  61. var code=loc.slice(n2+1,n1)
  62. let that = this
  63. console.log(code)
  64. let param = {
  65. "id": 2025082515112802,
  66. "content": {
  67. "code": code
  68. },
  69. }
  70. var str = window.location.href;
  71. var index = str.indexOf('/');
  72. var num = 0;
  73. while(index !== -1) {
  74. num++;
  75. index = str.indexOf('/',index + 1);
  76. if (num++ === 3) {
  77. this.url = str.slice(0, index) + '/yosweb/codeToFile.html'
  78. }
  79. }
  80. console.log(str.slice(0, index))
  81. var urlNew = str.slice(0, index) + '/yos/rest/index'
  82. console.log(urlNew)
  83. axios.post(urlNew, param)
  84. .then(function (response) {
  85. console.log(response)
  86. console.log(response.data.data.length)
  87. response.data.data.forEach(item => {
  88. const div = document.createElement('div');
  89. div.className = 'div-border';
  90. let iconSrc = '';
  91. if (item.attinfos[0].postfix == 'word' || item.attinfos[0].postfix == 'Word') {
  92. iconSrc = './img/word.svg';
  93. } else if (item.attinfos[0].postfix == 'pdf' || item.attinfos[0].postfix == 'PDF') {
  94. iconSrc = './img/pdfType.svg';
  95. } else if (item.attinfos[0].postfix == 'png' || item.attinfos[0].postfix == 'PNG' || item.attinfos[0].postfix == 'JPG' || item.attinfos[0].postfix == 'jpg') {
  96. iconSrc = './img/pngType.svg';
  97. }else if (item.attinfos[0].postfix == 'ppt' || item.attinfos[0].postfix == 'PPT') {
  98. iconSrc = './img/ppt.svg';
  99. }else if (item.attinfos[0].postfix == 'mp3' || item.attinfos[0].postfix == 'MP3' || item.attinfos[0].postfix == 'MP4' || item.attinfos[0].postfix == 'mp4'
  100. || item.attinfos[0].postfix == 'mov' || item.attinfos[0].postfix == 'MOV') {
  101. iconSrc = './img/mov.svg';
  102. }else if (item.attinfos[0].postfix == 'EXCEL' || item.attinfos[0].postfix == 'excel' || item.attinfos[0].postfix == 'xlsx' || item.attinfos[0].postfix == 'XLSX') {
  103. iconSrc = './img/excel.svg';
  104. } else {
  105. iconSrc = './img/default.svg';
  106. }
  107. div.innerHTML = `
  108. <div class="div-border" >
  109. <img src="${iconSrc}" class="img-style">
  110. <div class="content-style">${item.remarks}</div>
  111. </div>
  112. `;
  113. dataContainer.appendChild(div);
  114. div.addEventListener('click', function() {
  115. console.log(item.attinfos[0].url)
  116. downloadFile(item.attinfos[0].url)
  117. });
  118. })
  119. })
  120. .catch(function (error) {
  121. console.log(error);
  122. });
  123. }
  124. function downloadFile(fileUrl, fileType){
  125. const link = document.createElement('a');
  126. link.href = fileUrl
  127. document.body.appendChild(link);
  128. link.click();
  129. document.body.removeChild(link);
  130. }
  131. </script>
  132. </body>
  133. </html>