|
@@ -304,9 +304,11 @@ const getImageTempRatio = (url) => {
|
|
|
maxLine:最多绘制的行数
|
|
|
**/
|
|
|
//处理文字多出省略号显示
|
|
|
+const enterpriseNameLines = ref(0)
|
|
|
const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine, isEnterpriseName) => {
|
|
|
ctx.setFontSize(fontSize);//设置字体大小
|
|
|
var allRow = Math.ceil(ctx.measureText(text).width / maxWidth);//实际总共能分多少行
|
|
|
+ enterpriseNameLines.value = allRow
|
|
|
var count = allRow >= maxLine ? maxLine : allRow;//实际能分多少行与设置的最大显示行数比,谁小就用谁做循环次数
|
|
|
var endPos = 0;//当前字符串的截断点
|
|
|
for (var j = 0; j < count; j++) {
|
|
@@ -327,7 +329,7 @@ const dealWords = (ctx, fontSize, text, maxWidth, x, y, maxLine, isEnterpriseNam
|
|
|
}
|
|
|
} else {
|
|
|
//如果当前的字符串宽度小于最大宽度就直接输出
|
|
|
- ctx.fillText(nowStr.slice(0), x, (isEnterpriseName ? y + 20 : y) + (j + 1) * 30);
|
|
|
+ ctx.fillText(nowStr.slice(0), x, (isEnterpriseName ? y + 2 : y) + (j + 1) * 30);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -380,7 +382,8 @@ const createPoster = async () => {
|
|
|
// 企业行业类型、规模
|
|
|
context.setFontSize(20)
|
|
|
let industry = industryName && industryName.length > 6 ? `${industryName.slice(0, 7)}...` : industryName
|
|
|
- context.fillText(`${industry || ''}${scaleName ? ' | ' + scaleName : ''}`, 150, 310)
|
|
|
+ context.setFillStyle('#6c6e7b')
|
|
|
+ context.fillText(`${industry || ''}${scaleName ? ' | ' + scaleName : ''}`, 150, enterpriseNameLines.value === 1 ? 280 : 310)
|
|
|
|
|
|
context.draw(false, () =>{
|
|
|
wx.canvasToTempFilePath({
|