Browse Source

二维码管理显示样式调整

qymljy 2 months ago
parent
commit
80dcf41d20
2 changed files with 161 additions and 24 deletions
  1. 26 24
      public/codeToFile.html
  2. 135 0
      public/codeToFileCopy.html

+ 26 - 24
public/codeToFile.html

@@ -89,34 +89,36 @@
                     response.data.data.forEach((item,index) => {
                         const div = document.createElement('div');
                         div.className = 'div-border';
-                        let iconSrc = '';
-                        if (item.attinfos[index].postfix == 'word' || item.attinfos[index].postfix == 'Word') {
-                            iconSrc = './img/word.svg';
-                        } else if (item.attinfos[index].postfix == 'pdf' || item.attinfos[index].postfix == 'PDF') {
-                            iconSrc = './img/pdfType.svg';
-                        } else if (item.attinfos[index].postfix == 'png' || item.attinfos[index].postfix == 'PNG' || item.attinfos[index].postfix == 'JPG' || item.attinfos[index].postfix == 'jpg') {
-                            iconSrc = './img/pngType.svg';
-                        }else if (item.attinfos[index].postfix == 'ppt' || item.attinfos[index].postfix == 'PPT') {
-                            iconSrc = './img/ppt.svg';
-                        }else if (item.attinfos[index].postfix == 'mp3' || item.attinfos[index].postfix == 'MP3' || item.attinfos[index].postfix == 'MP4' || item.attinfos[index].postfix == 'mp4'
-                            || item.attinfos[index].postfix == 'mov' || item.attinfos[index].postfix == 'MOV') {
-                            iconSrc = './img/mov.svg';
-                        }else if (item.attinfos[index].postfix == 'EXCEL' || item.attinfos[index].postfix == 'excel' || item.attinfos[index].postfix == 'xlsx' || item.attinfos[index].postfix == 'XLSX') {
-                            iconSrc = './img/excel.svg';
-                        } else {
-                            iconSrc = './img/default.svg';
-                        }
-                        div.innerHTML = `
+                        item.attinfos.forEach((data,rowindex) => {
+                            let iconSrc = '';
+                            if (data.postfix == 'word' || data.postfix == 'Word') {
+                                iconSrc = './img/word.svg';
+                            } else if (data.postfix == 'pdf' || data.postfix == 'PDF') {
+                                iconSrc = './img/pdfType.svg';
+                            } else if (data.postfix == 'png' || data.postfix == 'PNG' || data.postfix == 'JPG' || data.postfix == 'jpg') {
+                                iconSrc = './img/pngType.svg';
+                            }else if (data.postfix == 'ppt' || data.postfix == 'PPT') {
+                                iconSrc = './img/ppt.svg';
+                            }else if (data.postfix == 'mp3' || data.postfix == 'MP3' || data.postfix == 'MP4' || data.postfix == 'mp4'
+                                || data.postfix == 'mov' || data.postfix == 'MOV') {
+                                iconSrc = './img/mov.svg';
+                            }else if (data.postfix == 'EXCEL' || data.postfix == 'excel' || data.postfix == 'xlsx' || data.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 class="content-style">${data.document.indexOf('.')}</div>
                             </div>
                 `;
-                        dataContainer.appendChild(div);
-                        div.addEventListener('click', function() {
-                            console.log(item.attinfos[index].url)
-                            downloadFile(item.attinfos[index].url)
-                        });
+                            dataContainer.appendChild(div);
+                            div.addEventListener('click', function() {
+                                console.log(data.url)
+                                downloadFile(data.url)
+                            });
+                        })
                     })
                 })
                 .catch(function (error) {

+ 135 - 0
public/codeToFileCopy.html

@@ -0,0 +1,135 @@
+<!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,index) => {
+                        const div = document.createElement('div');
+                        div.className = 'div-border';
+                        let iconSrc = '';
+                        if (item.attinfos[index].postfix == 'word' || item.attinfos[index].postfix == 'Word') {
+                            iconSrc = './img/word.svg';
+                        } else if (item.attinfos[index].postfix == 'pdf' || item.attinfos[index].postfix == 'PDF') {
+                            iconSrc = './img/pdfType.svg';
+                        } else if (item.attinfos[index].postfix == 'png' || item.attinfos[index].postfix == 'PNG' || item.attinfos[index].postfix == 'JPG' || item.attinfos[index].postfix == 'jpg') {
+                            iconSrc = './img/pngType.svg';
+                        }else if (item.attinfos[index].postfix == 'ppt' || item.attinfos[index].postfix == 'PPT') {
+                            iconSrc = './img/ppt.svg';
+                        }else if (item.attinfos[index].postfix == 'mp3' || item.attinfos[index].postfix == 'MP3' || item.attinfos[index].postfix == 'MP4' || item.attinfos[index].postfix == 'mp4'
+                            || item.attinfos[index].postfix == 'mov' || item.attinfos[index].postfix == 'MOV') {
+                            iconSrc = './img/mov.svg';
+                        }else if (item.attinfos[index].postfix == 'EXCEL' || item.attinfos[index].postfix == 'excel' || item.attinfos[index].postfix == 'xlsx' || item.attinfos[index].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[index].url)
+                            downloadFile(item.attinfos[index].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>