fix(huya): 优化兑换结果图字段与布局
This commit is contained in:
@@ -661,14 +661,14 @@ export default function HuyaElitePage() {
|
|||||||
)
|
)
|
||||||
? recordsTask.result.account_snapshot as Record<string, unknown>
|
? recordsTask.result.account_snapshot as Record<string, unknown>
|
||||||
: {};
|
: {};
|
||||||
|
const account = accounts.find((item) => item.id === recordsTask?.account_id);
|
||||||
const recordKey = String(record.record_id || record.order_id || index);
|
const recordKey = String(record.record_id || record.order_id || index);
|
||||||
return {
|
return {
|
||||||
key: `huya:${recordsTask?.id || 'records'}:${recordKey}`,
|
key: `huya:${recordsTask?.id || 'records'}:${recordKey}`,
|
||||||
goodsName: String(record.prize_name || '未知商品'),
|
goodsName: String(record.prize_name || '未知商品'),
|
||||||
goodsPic: String(record.icon || ''),
|
goodsPic: String(record.icon || ''),
|
||||||
roleName: String(snapshot.game_name || ''),
|
roleName: String(snapshot.game_name || account?.game_name || ''),
|
||||||
channel: String(snapshot.game_channel || ''),
|
channel: String(snapshot.game_channel || account?.game_channel || ''),
|
||||||
accountName: String(snapshot.uid || recordsTask?.account_uid || snapshot.nickname || recordsTask?.account_nickname || '-'),
|
|
||||||
exchangeTime: String(record.exchange_time_text || ''),
|
exchangeTime: String(record.exchange_time_text || ''),
|
||||||
statusText: String(record.status_label || '兑换成功'),
|
statusText: String(record.status_label || '兑换成功'),
|
||||||
footerText: '虎牙精英宝典兑换记录凭证 · 数据来自官方兑换记录',
|
footerText: '虎牙精英宝典兑换记录凭证 · 数据来自官方兑换记录',
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export interface ExchangeResultImageData {
|
|||||||
goodsPic?: string;
|
goodsPic?: string;
|
||||||
roleName?: string;
|
roleName?: string;
|
||||||
channel?: string;
|
channel?: string;
|
||||||
accountName: string;
|
accountName?: string;
|
||||||
exchangeTime?: string;
|
exchangeTime?: string;
|
||||||
statusText?: string;
|
statusText?: string;
|
||||||
footerText?: string;
|
footerText?: string;
|
||||||
@@ -150,11 +150,11 @@ export async function drawExchangeResultImage(
|
|||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
ctx.fillStyle = '#ffffff';
|
ctx.fillStyle = '#ffffff';
|
||||||
ctx.font = `bold 28px ${FONT_FAMILY}`;
|
ctx.font = `bold 28px ${FONT_FAMILY}`;
|
||||||
ctx.fillText('兑 换 成 功', CARD_W / 2, 56);
|
ctx.fillText('兑 换 成 功', CARD_W / 2, 46);
|
||||||
|
|
||||||
// 商品图(圆形裁剪)
|
// 商品图(圆形裁剪)
|
||||||
const avatarR = 52;
|
const avatarR = 52;
|
||||||
const avatarY = 112;
|
const avatarY = 128;
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(CARD_W / 2, avatarY, avatarR, 0, Math.PI * 2);
|
ctx.arc(CARD_W / 2, avatarY, avatarR, 0, Math.PI * 2);
|
||||||
@@ -201,25 +201,25 @@ export async function drawExchangeResultImage(
|
|||||||
ctx.strokeStyle = 'rgba(255,255,255,0.18)';
|
ctx.strokeStyle = 'rgba(255,255,255,0.18)';
|
||||||
ctx.lineWidth = 1;
|
ctx.lineWidth = 1;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(32, 260);
|
ctx.moveTo(32, 268);
|
||||||
ctx.lineTo(CARD_W - 32, 260);
|
ctx.lineTo(CARD_W - 32, 268);
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
|
|
||||||
// 信息区
|
// 信息区
|
||||||
const infoRows: Array<[string, string]> = [];
|
const infoRows: Array<[string, string]> = [];
|
||||||
if (info.roleName) infoRows.push(['游戏角色', info.roleName]);
|
if (info.roleName) infoRows.push(['游戏角色', info.roleName]);
|
||||||
if (info.channel) infoRows.push(['游戏区服', info.channel]);
|
if (info.channel) infoRows.push(['游戏区服', info.channel]);
|
||||||
infoRows.push(['兑换账号', info.accountName]);
|
if (info.accountName) infoRows.push(['兑换账号', info.accountName]);
|
||||||
if (time) infoRows.push(['兑换时间', time]);
|
if (time) infoRows.push(['兑换时间', time]);
|
||||||
|
|
||||||
ctx.font = `15px ${FONT_FAMILY}`;
|
ctx.font = `15px ${FONT_FAMILY}`;
|
||||||
let rowY = 288;
|
let rowY = 296;
|
||||||
for (const [label, value] of infoRows) {
|
for (const [label, value] of infoRows) {
|
||||||
ctx.textAlign = 'left';
|
ctx.textAlign = 'left';
|
||||||
ctx.fillStyle = 'rgba(255,255,255,0.6)';
|
ctx.fillStyle = 'rgba(255,255,255,0.6)';
|
||||||
ctx.fillText(label, 36, rowY);
|
ctx.fillText(label, 36, rowY);
|
||||||
ctx.fillStyle = '#ffffff';
|
ctx.fillStyle = '#ffffff';
|
||||||
ctx.fillText(truncate(value, 16), 128, rowY);
|
ctx.fillText(truncate(value, label === '兑换时间' ? 22 : 16), 128, rowY);
|
||||||
rowY += 27;
|
rowY += 27;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,18 +229,18 @@ export async function drawExchangeResultImage(
|
|||||||
const badgeW = ctx.measureText(badgeText).width + 34;
|
const badgeW = ctx.measureText(badgeText).width + 34;
|
||||||
const badgeX = (CARD_W - badgeW) / 2;
|
const badgeX = (CARD_W - badgeW) / 2;
|
||||||
ctx.fillStyle = '#2bb673';
|
ctx.fillStyle = '#2bb673';
|
||||||
roundRect(ctx, badgeX, 428, badgeW, 32, 16);
|
roundRect(ctx, badgeX, 410, badgeW, 32, 16);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
ctx.fillStyle = '#ffffff';
|
ctx.fillStyle = '#ffffff';
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.fillText(badgeText, CARD_W / 2, 444);
|
ctx.fillText(badgeText, CARD_W / 2, 426);
|
||||||
|
|
||||||
ctx.fillStyle = 'rgba(255,255,255,0.35)';
|
ctx.fillStyle = 'rgba(255,255,255,0.35)';
|
||||||
ctx.font = `10px ${FONT_FAMILY}`;
|
ctx.font = `10px ${FONT_FAMILY}`;
|
||||||
ctx.fillText(
|
ctx.fillText(
|
||||||
data.footerText || '真实兑换记录凭证 · 仅用于订单核验',
|
data.footerText || '真实兑换记录凭证 · 仅用于订单核验',
|
||||||
CARD_W / 2,
|
CARD_W / 2,
|
||||||
CARD_H - 12,
|
CARD_H - 8,
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Promise<Blob>((resolve, reject) => {
|
return new Promise<Blob>((resolve, reject) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user