Xiao_123 6 mesi fa
parent
commit
74f02de78d
1 ha cambiato i file con 5 aggiunte e 4 eliminazioni
  1. 5 4
      pagesB/positionDetail/index.vue

+ 5 - 4
pagesB/positionDetail/index.vue

@@ -289,7 +289,7 @@ const getImageTempRatio = (url) => {
   maxLine:最多绘制的行数
 **/
 //处理文字多出省略号显示
-const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine) => {
+const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine, isEnterpriseName) => {
   ctx.setFontSize(fontSize);//设置字体大小
   var allRow = Math.ceil(ctx.measureText(text).width / maxWidth);//实际总共能分多少行
   var count = allRow >= maxLine ? maxLine : allRow;//实际能分多少行与设置的最大显示行数比,谁小就用谁做循环次数
@@ -310,8 +310,9 @@ const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine) => {
           break;
         }
       }
-    } else {//如果当前的字符串宽度小于最大宽度就直接输出
-      ctx.fillText(nowStr.slice(0), x, y + (j + 1) * 30);
+    } else {
+      //如果当前的字符串宽度小于最大宽度就直接输出
+      ctx.fillText(nowStr.slice(0), x, (isEnterpriseName ? y + 20 : y) + (j + 1) * 30);
     }
   }
 }
@@ -359,7 +360,7 @@ const createPoster = async () => {
 
   // 企业名称
   context.setFillStyle('#000000')
-  dealWords(context, 25, anotherName, 250, 150, 210, 2)
+  dealWords(context, 25, anotherName, 250, 150, 210, 2, true)
 
   // 企业行业类型、规模
   context.setFontSize(20)