codeToFile.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. .logo-margin{
  10. margin: -60pt 0 0 30pt;
  11. position: absolute;
  12. }
  13. .img-div{
  14. width: 100%;
  15. height: 233pt;
  16. background-color: #AAB7CB ;
  17. position: relative;
  18. margin-top: 95px;
  19. }
  20. .title-div{
  21. width:100%;
  22. height:50px;
  23. margin:60px 0 60px 30pt
  24. }
  25. .title-font{
  26. font-size: 40pt;
  27. height:50px;
  28. line-height: 50px;
  29. vertical-align: auto;
  30. text-align: left;
  31. color: #FFFFFF;
  32. font-weight: bold
  33. }
  34. .margin-style{
  35. margin:0 30pt 20pt 30pt
  36. }
  37. .div-border{
  38. width: 100%;
  39. height: 150px;
  40. border-radius: 8pt;
  41. border: #cccccc solid 1px;
  42. display: flex;
  43. justify-content: left;
  44. margin-bottom: 20px;
  45. }
  46. .img-style{
  47. width: 90px;
  48. height: 90px;
  49. margin: 28px 0 0 20px;
  50. }
  51. .content-style{
  52. font-size: 30px;
  53. color: #333333;
  54. margin: 30px 20px 0 20px;
  55. }
  56. .content-div{
  57. width: 85%;
  58. height: 500pt;
  59. min-height: 500pt;
  60. background-color: #FFFFFF ;
  61. opacity: 0.3;
  62. margin: auto;
  63. max-height: 500pt;
  64. overflow: auto;
  65. border: 1px solid #707070;
  66. border-radius: 10pt;
  67. }
  68. </style>
  69. </head>
  70. <body style="background-color: #003399 ">
  71. <div class="img-div" id="backgroundDiv">
  72. <img src="./img/logo.png" width="164pt" height="164pt" class="logo-margin">
  73. </div>
  74. <div class="title-div">
  75. <img src="./img/datum.png" width="84pt" height="84pt" class="logo-margin" style="margin-top: -10px">
  76. <div class="title-font" style="margin-left: 160px">产品技术资料</div>
  77. </div>
  78. <div class="content-div" style="margin-top: 30pt">
  79. <div class="margin-style" id="dataContainer"></div>
  80. </div>
  81. <div style="margin-top: 50pt;background-color: #FFFFFF;opacity: 0.3;height: 150pt;width: 100%">
  82. <div style="margin: auto;font-size: 50pt;color: #e31d1d;height: 150pt;text-align: center;">
  83. 品牌官网·点击跳转
  84. </div>
  85. </div>
  86. <script>
  87. window.onload = async function(){
  88. var loc=location.href;
  89. var n1=loc.length;
  90. var n2=loc.indexOf('=');
  91. var code=loc.slice(n2+1,n1)
  92. let that = this
  93. console.log(code)
  94. let param = {
  95. "id": 2025082515112802,
  96. "content": {
  97. "code": code
  98. },
  99. }
  100. var str = window.location.href;
  101. var index = str.indexOf('/');
  102. var num = 0;
  103. var strNew = ''
  104. while(index !== -1) {
  105. num++;
  106. index = str.indexOf('/',index + 1);
  107. if (num++ === 3) {
  108. this.url = str.slice(0, index) + '/yosweb/codeToFile.html'
  109. strNew = str.slice(0, index)
  110. }
  111. }
  112. console.log(strNew)
  113. var urlNew = strNew + '/yos/rest/index'
  114. console.log(urlNew)
  115. axios.post(urlNew, param)
  116. .then(function (response) {
  117. response.data.data.forEach((item,index) => {
  118. item.attinfos.forEach((data,rowindex) => {
  119. const div = document.createElement('div');
  120. div.className = 'div-border';
  121. let iconSrc = '';
  122. if (data.postfix == 'doc' || data.postfix == 'DOC' || data.postfix == 'docx' || data.postfix == 'DOCX') {
  123. iconSrc = './img/word.svg';
  124. } else if (data.postfix == 'pdf' || data.postfix == 'PDF') {
  125. iconSrc = './img/pdfType.svg';
  126. } else if (data.postfix == 'png' || data.postfix == 'PNG' || data.postfix == 'JPG' || data.postfix == 'jpg') {
  127. iconSrc = './img/pngType.svg';
  128. }else if (data.postfix == 'ppt' || data.postfix == 'PPT') {
  129. iconSrc = './img/ppt.svg';
  130. }else if (data.postfix == 'mp3' || data.postfix == 'MP3' || data.postfix == 'MP4' || data.postfix == 'mp4'
  131. || data.postfix == 'mov' || data.postfix == 'MOV') {
  132. iconSrc = './img/mov.svg';
  133. }else if (data.postfix == 'EXCEL' || data.postfix == 'excel' || data.postfix == 'xlsx' || data.postfix == 'XLSX') {
  134. iconSrc = './img/excel.svg';
  135. } else {
  136. iconSrc = './img/default.svg';
  137. }
  138. let remarks = data.document.split('.')[0]
  139. div.innerHTML = `
  140. <div class="div-border" >
  141. <img src="${iconSrc}" class="img-style">
  142. <div class="content-style">${data.document.split('.')[0]}</div>
  143. </div>
  144. `;
  145. dataContainer.appendChild(div);
  146. div.addEventListener('click', function() {
  147. console.log(data.url)
  148. downloadFile(data.url)
  149. });
  150. })
  151. })
  152. })
  153. .catch(function (error) {
  154. console.log(error);
  155. });
  156. }
  157. function downloadFile(fileUrl, fileType){
  158. const link = document.createElement('a');
  159. link.href = fileUrl
  160. document.body.appendChild(link);
  161. link.click();
  162. document.body.removeChild(link);
  163. }
  164. </script>
  165. </body>
  166. </html>