瀏覽代碼

二维码管理循环展示数据

qymljy 2 月之前
父節點
當前提交
e99280fca5
共有 6 個文件被更改,包括 35 次插入14 次删除
  1. 31 14
      public/codeToFile.html
  2. 1 0
      public/img/excelType.svg
  3. 1 0
      public/img/mov.svg
  4. 0 0
      public/img/pdfType.svg
  5. 1 0
      public/img/pngType.svg
  6. 1 0
      public/img/ppt.svg

+ 31 - 14
public/codeToFile.html

@@ -33,6 +33,7 @@
                 border: #cccccc solid 1px;
                 display: flex;
                 justify-content: left;
+                margin-bottom: 20px;
             }
             .img-style{
                 width: 90px;
@@ -51,14 +52,9 @@
         <div class="title-div">
             <div class="title-font" >产品技术资料</div>
         </div>
-        <div class="margin-style">
-            <div class="div-border">
-                <img src="./img/word.svg" class="img-style">
-                <div class="content-style">BLGX支耳式蜗轮型中线蝶阀DN50-600 PN16送审图(自制整轴)</div>
-            </div>
-        </div>
-        <div class="margin-style" id="boxContainer"></div>
+        <div class="margin-style" id="dataContainer"></div>
         <script>
+            let dataList = []
             window.onload = async function(){
                 var loc=location.href;
                 var n1=loc.length;
@@ -76,13 +72,34 @@
                 .then(function (response) {
                     console.log(response)
                     console.log(response.data.data.length)
-                    for (var i=0;i<response.data.data.length -1;i++){
-                        a='<div class="div-border">';
-                        a += '<img src="./img/word.svg" class="img-style">';
-                        a += '<div class="content-style">'+response.data.data[i].remarks+'</div>';
-                        a+='</div>';
-                        $(".boxContainer").append(a);
-                    }
+                    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);
+                    })
                 })
                 .catch(function (error) {
                     console.log(error);

+ 1 - 0
public/img/excelType.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1756796851259" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11939" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M276.621241 320.123586h431.139311v465.037242H276.621241z" fill="#FFFFFF" p-id="11940"></path><path d="M912.454621 1000.41269a48.16331 48.16331 0 0 1-35.310345 15.254069H138.593103a51.729655 51.729655 0 0 1-50.387862-50.776276V50.776276A54.589793 54.589793 0 0 1 103.247448 15.254069a48.869517 48.869517 0 0 1 35.310345-15.254069h503.631448l285.272276 287.70869v677.217103a49.681655 49.681655 0 0 1-15.042207 35.522207z m-245.300966-630.819311h-78.388965l-79.942621 117.901242-76.623448-117.901242H351.408552l117.018482 164.722759-125.634206 176.198621h79.90731l84.356414-125.669518 84.356414 124.89269h81.743448l-125.669517-175.315862z m0 0" fill="#42B275" p-id="11941"></path><path d="M927.496828 287.70869h-234.955035a51.553103 51.553103 0 0 1-50.21131-50.846897V0z m0 0" fill="#74D4AF" p-id="11942"></path></svg>

+ 1 - 0
public/img/mov.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1756796646732" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11347" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M647.450483 0H139.652414a49.434483 49.434483 0 0 0-35.592828 15.36 55.048828 55.048828 0 0 0-15.148138 35.80469v921.6a52.118069 52.118069 0 0 0 50.740966 51.164689h744.659862a48.587034 48.587034 0 0 0 35.592827-15.36 50.070069 50.070069 0 0 0 15.148138-35.804689V290.074483z" fill="#C386F0" p-id="11348"></path><path d="M935.088552 290.074483h-236.861793a51.941517 51.941517 0 0 1-50.599725-51.235311V0z m0 0" fill="#FFFFFF" opacity=".45" p-id="11349"></path><path d="M683.961379 470.934069a23.51669 23.51669 0 0 0-23.552 0l-52.753655 30.543448V460.093793a20.833103 20.833103 0 0 0-23.552-23.552h-232.342069a20.833103 20.833103 0 0 0-23.552 23.552v176.09269a20.797793 20.797793 0 0 0 23.552 23.516689h232.342069a20.797793 20.797793 0 0 0 23.552-23.516689v-41.489655l52.753655 30.402206a23.552 23.552 0 0 0 35.310345-20.232827v-113.487448a23.58731 23.58731 0 0 0-11.758345-20.44469z" fill="#FFFFFF" p-id="11350"></path></svg>

文件差異過大導致無法顯示
+ 0 - 0
public/img/pdfType.svg


+ 1 - 0
public/img/pngType.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1756796808868" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11790" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M647.485793 0H139.687724a49.434483 49.434483 0 0 0-35.628138 15.36 54.872276 54.872276 0 0 0-15.112827 35.80469v921.6a52.082759 52.082759 0 0 0 50.740965 51.164689h744.624552a48.657655 48.657655 0 0 0 35.628138-15.36 50.034759 50.034759 0 0 0 15.112827-35.804689V290.074483z" fill="#FF4C5E" p-id="11791"></path><path d="M935.053241 290.074483h-236.861793a51.941517 51.941517 0 0 1-50.564414-51.235311V0z m0 0" fill="#FFFFFF" opacity=".45" p-id="11792"></path><path d="M593.425655 373.089103L395.511172 715.917241h395.864276z" fill="#FFFFFF" p-id="11793"></path><path d="M375.913931 544.485517l-98.868965 171.396414h197.949793z" fill="#FFFFFF" p-id="11794"></path><path d="M312.35531 408.505379m-35.416276 0a35.416276 35.416276 0 1 0 70.832552 0 35.416276 35.416276 0 1 0-70.832552 0Z" fill="#FFFFFF" p-id="11795"></path></svg>

+ 1 - 0
public/img/ppt.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1756796734064" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11494" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M644.343172 4.096H140.464552a48.975448 48.975448 0 0 0-35.310345 15.32469 54.836966 54.836966 0 0 0-15.042207 35.698758v917.892414A51.835586 51.835586 0 0 0 140.499862 1024h738.974897a48.128 48.128 0 0 0 35.310344-15.32469 49.964138 49.964138 0 0 0 15.006897-35.698758V292.969931z" fill="#F16C41" p-id="11495"></path><path d="M929.75669 292.969931h-235.060966a51.588414 51.588414 0 0 1-50.176-50.988138V4.096z m0 0" fill="#FFFFFF" opacity=".45" p-id="11496"></path><path d="M501.865931 377.997241a117.195034 117.195034 0 0 0-56.708414 14.124138v-14.124138H396.535172v340.215173h48.622345v-111.474759a117.195034 117.195034 0 0 0 56.708414 14.124138 121.502897 121.502897 0 0 0 0-243.041103z m0 194.418759a72.845241 72.845241 0 0 1-56.708414-27.188966v-91.347862a72.845241 72.845241 0 1 1 56.708414 118.536828z" fill="#FFFFFF" p-id="11497"></path></svg>

部分文件因文件數量過多而無法顯示