|
@@ -179,7 +179,7 @@ async function getWxacodeBase64() {
|
|
|
shareType: 'COUPON',
|
|
shareType: 'COUPON',
|
|
|
sharePath: 'pages/home/home',
|
|
sharePath: 'pages/home/home',
|
|
|
shareContentId: shareId.value,
|
|
shareContentId: shareId.value,
|
|
|
- width: 360,
|
|
|
|
|
|
|
+ width: 290,
|
|
|
})
|
|
})
|
|
|
console.log('res:', res)
|
|
console.log('res:', res)
|
|
|
const contentType = res.header['Content-Type'] || res.header['content-type']
|
|
const contentType = res.header['Content-Type'] || res.header['content-type']
|
|
@@ -364,7 +364,7 @@ function drawTitle(ctx, width, height, scale) {
|
|
|
// 绘制优惠券金额
|
|
// 绘制优惠券金额
|
|
|
function drawCouponAmount(ctx, width, height, scale) {
|
|
function drawCouponAmount(ctx, width, height, scale) {
|
|
|
const centerX = width / 2
|
|
const centerX = width / 2
|
|
|
- const bottomY = 220 * scale
|
|
|
|
|
|
|
+ const bottomY = 230 * scale
|
|
|
ctx.textBaseline = 'bottom' // 设置文本基线为底部对齐
|
|
ctx.textBaseline = 'bottom' // 设置文本基线为底部对齐
|
|
|
|
|
|
|
|
if (couponDetail.value.type === '2') {
|
|
if (couponDetail.value.type === '2') {
|
|
@@ -398,7 +398,7 @@ function drawCouponAmount(ctx, width, height, scale) {
|
|
|
// 绘制"折"字(与数字间距8px,垂直位置微调使视觉对齐)
|
|
// 绘制"折"字(与数字间距8px,垂直位置微调使视觉对齐)
|
|
|
ctx.font = unitFont
|
|
ctx.font = unitFont
|
|
|
// 根据字体大小比例微调"折"字的y坐标,使其视觉上与数字底部对齐
|
|
// 根据字体大小比例微调"折"字的y坐标,使其视觉上与数字底部对齐
|
|
|
- const unitY = bottomY - (72 - 36) * scale * 0.15 // 微调垂直位置
|
|
|
|
|
|
|
+ const unitY = bottomY - (72 - 36) * scale * 0.35 // 微调垂直位置
|
|
|
ctx.fillText(unit, startX + numberWidth + 8 * scale, unitY)
|
|
ctx.fillText(unit, startX + numberWidth + 8 * scale, unitY)
|
|
|
}
|
|
}
|
|
|
else if (couponDetail.value.type === '3') {
|
|
else if (couponDetail.value.type === '3') {
|
|
@@ -417,6 +417,8 @@ function drawCouponAmount(ctx, width, height, scale) {
|
|
|
ctx.font = symbolFont
|
|
ctx.font = symbolFont
|
|
|
const symbol = '¥'
|
|
const symbol = '¥'
|
|
|
const symbolWidth = ctx.measureText(symbol).width
|
|
const symbolWidth = ctx.measureText(symbol).width
|
|
|
|
|
+ console.log('symbolWidth:', ctx.measureText(symbol))
|
|
|
|
|
+ // const symbolHeight = ctx.measureText(symbol).height
|
|
|
|
|
|
|
|
// 计算总宽度
|
|
// 计算总宽度
|
|
|
const totalWidth = symbolWidth + numberWidth + 8 * scale // 8px间距(减小间距)
|
|
const totalWidth = symbolWidth + numberWidth + 8 * scale // 8px间距(减小间距)
|
|
@@ -427,13 +429,13 @@ function drawCouponAmount(ctx, width, height, scale) {
|
|
|
// 绘制"¥"符号(垂直位置微调使视觉对齐)
|
|
// 绘制"¥"符号(垂直位置微调使视觉对齐)
|
|
|
ctx.textAlign = 'left'
|
|
ctx.textAlign = 'left'
|
|
|
// 根据字体大小比例微调"¥"符号的y坐标,使其视觉上与数字底部对齐
|
|
// 根据字体大小比例微调"¥"符号的y坐标,使其视觉上与数字底部对齐
|
|
|
- const symbolY = bottomY - (72 - 36) * scale * 0.15 // 微调垂直位置
|
|
|
|
|
|
|
+ const symbolY = bottomY - (72 - 36) * scale * 0.25 // 微调垂直位置
|
|
|
ctx.fillText(symbol, startX, symbolY)
|
|
ctx.fillText(symbol, startX, symbolY)
|
|
|
|
|
|
|
|
// 绘制数字
|
|
// 绘制数字
|
|
|
ctx.fillStyle = '#FF6B35'
|
|
ctx.fillStyle = '#FF6B35'
|
|
|
ctx.font = numberFont
|
|
ctx.font = numberFont
|
|
|
- ctx.fillText(number, startX + symbolWidth + 8 * scale, symbolY)
|
|
|
|
|
|
|
+ ctx.fillText(number, startX + symbolWidth + 8 * scale, bottomY)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 恢复默认文本对齐方式
|
|
// 恢复默认文本对齐方式
|
|
@@ -535,14 +537,14 @@ function drawCouponDescription(ctx, width, height, scale) {
|
|
|
async function drawQRCodeArea(ctx, canvas, qrCodeImg, width, height, scale) {
|
|
async function drawQRCodeArea(ctx, canvas, qrCodeImg, width, height, scale) {
|
|
|
const qrSize = 180 * scale
|
|
const qrSize = 180 * scale
|
|
|
const qrX = (width - qrSize) / 2
|
|
const qrX = (width - qrSize) / 2
|
|
|
- const qrY = 450 * scale
|
|
|
|
|
|
|
+ const qrY = 435 * scale
|
|
|
|
|
|
|
|
// 1. 优化卡片样式:使用更柔和的阴影和渐变背景
|
|
// 1. 优化卡片样式:使用更柔和的阴影和渐变背景
|
|
|
ctx.shadowColor = 'rgba(0, 0, 0, 0.08)'
|
|
ctx.shadowColor = 'rgba(0, 0, 0, 0.08)'
|
|
|
ctx.shadowBlur = 15 * scale
|
|
ctx.shadowBlur = 15 * scale
|
|
|
ctx.shadowOffsetY = 8 * scale
|
|
ctx.shadowOffsetY = 8 * scale
|
|
|
|
|
|
|
|
- drawRoundRect(ctx, qrX - 30 * scale, qrY - 30 * scale, qrSize + 60 * scale, qrSize + 80 * scale, 20 * scale)
|
|
|
|
|
|
|
+ drawRoundRect(ctx, qrX - 30 * scale, qrY - 30 * scale, qrSize + 60 * scale, qrSize + 106 * scale, 20 * scale)
|
|
|
|
|
|
|
|
// 使用柔和的白色背景,增加卡片层次感
|
|
// 使用柔和的白色背景,增加卡片层次感
|
|
|
ctx.fillStyle = '#FFFFFF'
|
|
ctx.fillStyle = '#FFFFFF'
|
|
@@ -717,17 +719,17 @@ async function drawQRCodeArea(ctx, canvas, qrCodeImg, width, height, scale) {
|
|
|
// 增加辅助文字,让提示更清晰
|
|
// 增加辅助文字,让提示更清晰
|
|
|
ctx.fillStyle = '#9E9E9E'
|
|
ctx.fillStyle = '#9E9E9E'
|
|
|
ctx.font = `${16 * scale}px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif`
|
|
ctx.font = `${16 * scale}px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif`
|
|
|
- ctx.fillText('领取专属优惠券', width / 2, qrY + qrSize + 65 * scale)
|
|
|
|
|
|
|
+ ctx.fillText('领取专属优惠券', width / 2, qrY + qrSize + 60 * scale)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 绘制底部信息
|
|
// 绘制底部信息
|
|
|
function drawFooter(ctx, width, height, scale) {
|
|
function drawFooter(ctx, width, height, scale) {
|
|
|
// 计算二维码区域的位置
|
|
// 计算二维码区域的位置
|
|
|
const qrSize = 200 * scale
|
|
const qrSize = 200 * scale
|
|
|
- const qrY = 440 * scale
|
|
|
|
|
|
|
+ const qrY = 435 * scale
|
|
|
|
|
|
|
|
// 底部信息显示在二维码下方,与二维码提示文字保持适当间距
|
|
// 底部信息显示在二维码下方,与二维码提示文字保持适当间距
|
|
|
- const footerY = qrY + qrSize + 80 * scale // 在"长按识别二维码领取"文字下方40*scale处
|
|
|
|
|
|
|
+ const footerY = qrY + qrSize + 80 * scale // 在"长按识别小程序码领取"文字下方40*scale处
|
|
|
|
|
|
|
|
ctx.fillStyle = '#999999'
|
|
ctx.fillStyle = '#999999'
|
|
|
ctx.font = `${16 * scale}px sans-serif`
|
|
ctx.font = `${16 * scale}px sans-serif`
|