codeToFile.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. var strNew = ''
  74. while(index !== -1) {
  75. num++;
  76. index = str.indexOf('/',index + 1);
  77. if (num++ === 3) {
  78. this.url = str.slice(0, index) + '/yosweb/codeToFile.html'
  79. strNew = str.slice(0, index)
  80. }
  81. }
  82. console.log(strNew)
  83. var urlNew = strNew + '/yos/rest/index'
  84. console.log(urlNew)
  85. axios.post(urlNew, param)
  86. .then(function (response) {
  87. console.log(response)
  88. console.log(response.data.data.length)
  89. response.data.data.forEach(item => {
  90. const div = document.createElement('div');
  91. div.className = 'div-border';
  92. let iconSrc = '';
  93. if (item.attinfos[0].postfix == 'word' || item.attinfos[0].postfix == 'Word') {
  94. iconSrc = './img/word.svg';
  95. } else if (item.attinfos[0].postfix == 'pdf' || item.attinfos[0].postfix == 'PDF') {
  96. iconSrc = './img/pdfType.svg';
  97. } else if (item.attinfos[0].postfix == 'png' || item.attinfos[0].postfix == 'PNG' || item.attinfos[0].postfix == 'JPG' || item.attinfos[0].postfix == 'jpg') {
  98. iconSrc = './img/pngType.svg';
  99. }else if (item.attinfos[0].postfix == 'ppt' || item.attinfos[0].postfix == 'PPT') {
  100. iconSrc = './img/ppt.svg';
  101. }else if (item.attinfos[0].postfix == 'mp3' || item.attinfos[0].postfix == 'MP3' || item.attinfos[0].postfix == 'MP4' || item.attinfos[0].postfix == 'mp4'
  102. || item.attinfos[0].postfix == 'mov' || item.attinfos[0].postfix == 'MOV') {
  103. iconSrc = './img/mov.svg';
  104. }else if (item.attinfos[0].postfix == 'EXCEL' || item.attinfos[0].postfix == 'excel' || item.attinfos[0].postfix == 'xlsx' || item.attinfos[0].postfix == 'XLSX') {
  105. iconSrc = './img/excel.svg';
  106. } else {
  107. iconSrc = './img/default.svg';
  108. }
  109. div.innerHTML = `
  110. <div class="div-border" >
  111. <img src="${iconSrc}" class="img-style">
  112. <div class="content-style">${item.remarks}</div>
  113. </div>
  114. `;
  115. dataContainer.appendChild(div);
  116. div.addEventListener('click', function() {
  117. console.log(item.attinfos[0].url)
  118. downloadFile(item.attinfos[0].url)
  119. });
  120. })
  121. })
  122. .catch(function (error) {
  123. console.log(error);
  124. });
  125. }
  126. function downloadFile(fileUrl, fileType){
  127. const link = document.createElement('a');
  128. link.href = fileUrl
  129. document.body.appendChild(link);
  130. link.click();
  131. document.body.removeChild(link);
  132. }
  133. </script>
  134. </body>
  135. </html>