Ver código fonte

fix: 修复图片显示bug
1. 产品列表与下拉菜单图片兼容显示修复
2. 修复新增产品分类异常问题

kindring 1 ano atrás
pai
commit
2fd2463584

+ 3 - 1
components/header/menuDrops/menuDrop.vue

@@ -20,7 +20,7 @@
       >
         <div class="con">
           <div class="img-box">
-            <img :src="'/public/'+item.image" :alt="item.name"  class="img"/>
+            <img :src="imagePathBabel(item.image)" :alt="item.name"  class="img"/>
           </div>
           <div class="text-box">
             <div class="name">{{item.name}}</div>
@@ -38,6 +38,7 @@ import {handle} from "~/until/handle";
 import {indexTypes} from "../../../store";
 import {mapGetters} from "vuex";
 import {productMenus} from "~/map/productMap";
+import {imagePathBabel} from "@/tools/imagePath";
 /**
  * 解决方案
  * @type {[{typeKey: string, text: string}, {typeKey: string, text: string}]}
@@ -102,6 +103,7 @@ export default {
 
   },
   methods:{
+    imagePathBabel,
     getLangText(str){
       return langMap.getText(this.lang,str);
     },

+ 3 - 1
components/productList.vue

@@ -7,7 +7,7 @@
        @click="clickProductHandle(product)"
     >
           <span class="imgBox">
-             <img :src="'/public/'+product.image" :alt="product.name" class="img">
+             <img :src="imagePathBabel(product.image)" :alt="product.name" class="img">
           </span>
       <span class="more">
             {{lang===langType.cn?"了解更多":getAbbrText("了解更多")}}
@@ -27,6 +27,7 @@
 
 <script>
 import langMap from "~/map/langMap";
+import {imagePathBabel} from "@/tools/imagePath";
 
 export default {
   name: "productList",
@@ -47,6 +48,7 @@ export default {
     }
   },
   methods: {
+    imagePathBabel,
     getLangText(str) {
       return langMap.getText(this.lang, str);
     },

+ 4 - 4
components/public/imageTable.vue

@@ -9,7 +9,7 @@
     </div>
     <div class="p-con w-full px-1">
 
-      <loading v-if="tabKey===1" class="w-full h-full " :loading-state="loadingState" tip="获取图片中">
+      <loading v-if="tabKey===1" class="w-full h-full overflow-auto" :loading-state="loadingState" tip="获取图片中">
         <div class="img-viewBox" :style="imgBoxStyle" ref="imgViewBox">
           <div
               v-for="item in images"
@@ -36,7 +36,7 @@
 <!--      文件上传部分 -->
       <div
         v-if="tabKey===2"
-        class="w-full h-full flex flex-col">
+        class="w-full h-full flex flex-col ">
         <div class="w-full h-32 rounded
         border overflow-hidden flex-shrink">
           <upload-file
@@ -272,7 +272,7 @@ export default {
       form.append('file',file.file);
       let uploadUrl = this.uploadUrl;
       uploadUrl += `?type=${this.fileType}`;
-      let [err,res] = await handle(this.$axios.post(this.uploadUrl,form,{
+      let [err,res] = await handle(this.$axios.post(uploadUrl, form,{
         onUploadProgress: (progressEvent) => {
           file.percent = Math.round((progressEvent.loaded * 100) / progressEvent.total) || 0;
         }
@@ -332,7 +332,7 @@ export default {
   height: calc(100% - 80px);
 }
 .img-viewBox{
-  width: 100%;
+  width: calc(100% - 15px);
   display: flex;
   flex-wrap: wrap;
   justify-content: flex-start;

+ 3 - 1
pages/product/index.vue

@@ -11,6 +11,7 @@ import LucencyHeader from "~/components/header/lucencyHeader.vue";
 import DefaultFooter from "~/components/footer/defaultFooter.vue";
 import {apiMap, baseUrl} from "~/map/apiMap";
 import {isEmpty} from "@/until/typeTool";
+import {imagePathBabel} from "@/tools/imagePath";
 export default {
   name: "index",
   props:[
@@ -200,7 +201,8 @@ export default {
     changeTypeHandle(nextType){
       console.log(nextType)
       this.selectType(nextType);
-    }
+    },
+    imagePathBabel
   }
 }
 </script>

+ 2 - 2
server/control/product.js

@@ -215,7 +215,7 @@ async function editType( id, productType)
   return [null,res];
 }
 
-async function addType( id, productType)
+async function addType( productType)
 {
   // 判断类别关键字是否重复
   let [err,res] = await handle(d_product.getTypeByKey(productType.type_key))
@@ -230,7 +230,7 @@ async function addType( id, productType)
       },null]
   }
   // 数据校验
-  [err,res] = await handle(d_product.addProductType(id, productType));
+  [err,res] = await handle(d_product.addProductType( productType));
   if(err){
     return [err,null];
   }

+ 1 - 1
server/database/d_product.js

@@ -257,7 +257,7 @@ function deleteProductType(id) {
 function addProductType(type) {
   let sql = `INSERT INTO hfy_product_type
 (date_time, type_name, type_key, type_sort, type_logo, seo_key, sub_text)
-VALUES (?, ?, ?, ?, ?, ?)`;
+VALUES (?, ?, ?, ?, ?, ?, ?)`;
   let values = [];
   values.push(time.getUnixTimeStamp());
   values.push(type.type_name);