123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>商品资料页</title>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
- <style>
- .img-margin{
- margin: 60pt 0 30pt 30pt;
- }
- .title-div{
- width:100%;
- height:50px;
- margin:0 0 20pt 30pt
- }
- .title-font{
- font-size: 40pt;
- height:50px;
- line-height: 50px;
- vertical-align: auto;
- text-align: left;
- color: #333333;
- font-weight: bold
- }
- .margin-style{
- margin:0 30pt 20pt 30pt
- }
- .div-border{
- width: 100%;
- height: 150px;
- border-radius: 8pt;
- border: #cccccc solid 1px;
- display: flex;
- justify-content: left;
- margin-bottom: 20px;
- }
- .img-style{
- width: 90px;
- height: 90px;
- margin: 28px 0 0 20px;
- }
- .content-style{
- font-size: 30px;
- color: #333333;
- margin: 30px 20px 0 20px;
- }
- </style>
- </head>
- <body>
- <img src="./img/bnBag.png" width="85%" height="180px" class="img-margin">
- <div class="title-div">
- <div class="title-font" >产品技术资料</div>
- </div>
- <div class="margin-style" id="dataContainer"></div>
- <script>
- window.onload = async function(){
- var loc=location.href;
- var n1=loc.length;
- var n2=loc.indexOf('=');
- var code=loc.slice(n2+1,n1)
- let that = this
- console.log(code)
- let param = {
- "id": 2025082515112802,
- "content": {
- "code": code
- },
- }
- var str = window.location.href;
- var index = str.indexOf('/');
- var num = 0;
- var strNew = ''
- while(index !== -1) {
- num++;
- index = str.indexOf('/',index + 1);
- if (num++ === 3) {
- this.url = str.slice(0, index) + '/yosweb/codeToFile.html'
- strNew = str.slice(0, index)
- }
- }
- console.log(strNew)
- var urlNew = strNew + '/yos/rest/index'
- console.log(urlNew)
- axios.post(urlNew, param)
- .then(function (response) {
- console.log(response)
- console.log(response.data.data.length)
- response.data.data.forEach(item => {
- const div = document.createElement('div');
- div.className = 'div-border';
- let iconSrc = '';
- if (item.attinfos[0].postfix == 'word' || item.attinfos[0].postfix == 'Word') {
- iconSrc = './img/word.svg';
- } else if (item.attinfos[0].postfix == 'pdf' || item.attinfos[0].postfix == 'PDF') {
- iconSrc = './img/pdfType.svg';
- } else if (item.attinfos[0].postfix == 'png' || item.attinfos[0].postfix == 'PNG' || item.attinfos[0].postfix == 'JPG' || item.attinfos[0].postfix == 'jpg') {
- iconSrc = './img/pngType.svg';
- }else if (item.attinfos[0].postfix == 'ppt' || item.attinfos[0].postfix == 'PPT') {
- iconSrc = './img/ppt.svg';
- }else if (item.attinfos[0].postfix == 'mp3' || item.attinfos[0].postfix == 'MP3' || item.attinfos[0].postfix == 'MP4' || item.attinfos[0].postfix == 'mp4'
- || item.attinfos[0].postfix == 'mov' || item.attinfos[0].postfix == 'MOV') {
- iconSrc = './img/mov.svg';
- }else if (item.attinfos[0].postfix == 'EXCEL' || item.attinfos[0].postfix == 'excel' || item.attinfos[0].postfix == 'xlsx' || item.attinfos[0].postfix == 'XLSX') {
- iconSrc = './img/excel.svg';
- } else {
- iconSrc = './img/default.svg';
- }
- div.innerHTML = `
- <div class="div-border" >
- <img src="${iconSrc}" class="img-style">
- <div class="content-style">${item.remarks}</div>
- </div>
- `;
- dataContainer.appendChild(div);
- div.addEventListener('click', function() {
- console.log(item.attinfos[0].url)
- downloadFile(item.attinfos[0].url)
- });
- })
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- function downloadFile(fileUrl, fileType){
- const link = document.createElement('a');
- link.href = fileUrl
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- }
- </script>
- </body>
- </html>
|