codeToFile.html 5.4 KB

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