|
...
|
...
|
@@ -12,7 +12,7 @@ module.exports = data => { |
|
|
|
}
|
|
|
|
}, ]
|
|
|
|
// 原来的样式1,2,3
|
|
|
|
if (data.type1 && !data.type2) {
|
|
|
|
if (data.type1 && !data.type2 && data.type1 != '4') {
|
|
|
|
views.push({
|
|
|
|
"type": "image",
|
|
|
|
"url": 'https://nosqn.colorcun.com/rectangleBj.png',
|
|
...
|
...
|
@@ -375,6 +375,128 @@ module.exports = data => { |
|
|
|
}
|
|
|
|
}, );
|
|
|
|
}
|
|
|
|
// 新的样式4
|
|
|
|
if (data.type1 && !data.type2 && data.type1 == '4') {
|
|
|
|
views.push({
|
|
|
|
"type": "image",
|
|
|
|
"url": 'https://nosqn.colorcun.com/rectangleBj.png',
|
|
|
|
"css": {
|
|
|
|
"width": "210px",
|
|
|
|
"height": "168px",
|
|
|
|
"top": "0px",
|
|
|
|
"left": "0px",
|
|
|
|
"mode": "aspectFill"
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
"type": "text",
|
|
|
|
"text": data.info.sellerName,
|
|
|
|
"css": {
|
|
|
|
"color": "#FFEFC5",
|
|
|
|
"width": "190px",
|
|
|
|
"top": "10px",
|
|
|
|
"left": "10px",
|
|
|
|
"right": "10px",
|
|
|
|
"borderColor": "#000000",
|
|
|
|
"fontSize": "12px",
|
|
|
|
"fontWeight": "400",
|
|
|
|
"maxLines": "2",
|
|
|
|
"textStyle": "fill",
|
|
|
|
"textDecoration": "none",
|
|
|
|
"fontFamily": "PingFang SC",
|
|
|
|
"textAlign": "center",
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
"type": "text",
|
|
|
|
"text": data.info.date,
|
|
|
|
"css": {
|
|
|
|
"color": "#FFEFC5",
|
|
|
|
"width": "100px",
|
|
|
|
"height": "168px",
|
|
|
|
"top": "142px",
|
|
|
|
"left": "10px",
|
|
|
|
"borderColor": "#000000",
|
|
|
|
"fontSize": "18px",
|
|
|
|
"fontWeight": "500",
|
|
|
|
"maxLines": "1",
|
|
|
|
"textStyle": "fill",
|
|
|
|
"textDecoration": "none",
|
|
|
|
"fontFamily": "PingFang SC",
|
|
|
|
"textAlign": "left",
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
"type": "text",
|
|
|
|
"text": data.info.time,
|
|
|
|
"css": {
|
|
|
|
"color": "#FFEFC5",
|
|
|
|
"width": "100px",
|
|
|
|
"height": "168px",
|
|
|
|
"top": "142px",
|
|
|
|
"left": "120px",
|
|
|
|
"borderColor": "#000000",
|
|
|
|
"fontSize": "18px",
|
|
|
|
"fontWeight": "500",
|
|
|
|
"maxLines": "1",
|
|
|
|
"textStyle": "fill",
|
|
|
|
"textDecoration": "none",
|
|
|
|
"fontFamily": "PingFang SC",
|
|
|
|
"textAlign": "left",
|
|
|
|
}
|
|
|
|
})
|
|
|
|
const fontSize = 24;
|
|
|
|
const padding = 4;
|
|
|
|
const canvasWidth = 210;
|
|
|
|
const textTop = 60;
|
|
|
|
// 处理显示文本
|
|
|
|
let displayText = data.info.oneTableName;
|
|
|
|
if (displayText && displayText.length > 7) {
|
|
|
|
displayText = displayText.substring(0, 6) + "...";
|
|
|
|
}
|
|
|
|
// 计算宽度(考虑中英文差异)
|
|
|
|
function getTextWidth(text, fontSize) {
|
|
|
|
let width = 0;
|
|
|
|
for (let i = 0; i < text.length; i++) {
|
|
|
|
const charCode = text.charCodeAt(i);
|
|
|
|
// 中文字符或全角字符
|
|
|
|
if (charCode > 127 || (charCode >= 0xFF00 && charCode <= 0xFFEF)) {
|
|
|
|
width += fontSize * 1.0;
|
|
|
|
} else {
|
|
|
|
width += fontSize * 0.6; // 英文字符、数字或半角符号
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Math.ceil(width);
|
|
|
|
}
|
|
|
|
// 计算文本宽度
|
|
|
|
const textWidth = getTextWidth(displayText, fontSize);
|
|
|
|
const bgWidth = textWidth + padding * 2;
|
|
|
|
const bgHeight = fontSize + padding * 1;
|
|
|
|
// 计算居中位置
|
|
|
|
const leftPosition = (canvasWidth - bgWidth) / 2;
|
|
|
|
// 添加到views
|
|
|
|
views.push({
|
|
|
|
"type": "text",
|
|
|
|
"text": displayText,
|
|
|
|
"css": {
|
|
|
|
"color": "#FFEFC5",
|
|
|
|
"width": bgWidth + 'px',
|
|
|
|
"height": bgHeight + 'px',
|
|
|
|
"top": textTop + 'px',
|
|
|
|
"left": Math.max(0, leftPosition) + 'px', // 确保不超出左边界
|
|
|
|
'background': 'rgba(255, 239, 197, 0.4)',
|
|
|
|
"fontSize": fontSize + 'px',
|
|
|
|
"fontWeight": "normal",
|
|
|
|
"maxLines": "1",
|
|
|
|
"overflow": "visible",
|
|
|
|
"textStyle": "fill",
|
|
|
|
"textDecoration": "none",
|
|
|
|
"fontFamily": "PingFang SC",
|
|
|
|
"textAlign": "center",
|
|
|
|
"lineHeight": bgHeight + 'px',
|
|
|
|
"boxSizing": "border-box",
|
|
|
|
"borderRadius": "5px",
|
|
|
|
"padding": "0 0 4px 0",
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
"width": "210px",
|
|
|
|
"height": "168px",
|
...
|
...
|
|