codeToFile.html 5.0 KB

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