feat: alipay login

This commit is contained in:
zzc
2026-02-11 17:04:11 +08:00
parent 576227154d
commit 6ca148f65e
2 changed files with 17 additions and 1 deletions

View File

@@ -1180,6 +1180,12 @@ const saveByCanvas = async (save = true) => {
canvas.width = baseW * dpr;
canvas.height = baseH * dpr;
// ⚠️ 关键修复:重置变换矩阵,防止多次调用导致 scale 累积
// 支付宝小程序在设置 width/height 后可能未完全重置 Context 状态
ctx.setTransform(1, 0, 0, 1, 0, 0);
// 清空画布(使用物理像素尺寸)
ctx.clearRect(0, 0, canvas.width, canvas.height);
// 缩放上下文,使得后续绘制指令依然可以使用逻辑坐标 (baseW, baseH)
ctx.scale(dpr, dpr);
@@ -1201,6 +1207,11 @@ const saveByCanvas = async (save = true) => {
const r2p = (rpx) => (rpx * baseW) / 506;
try {
// #ifdef MP-ALIPAY
// 支付宝环境:显式等待 Canvas 节点就绪,避免过早绘制
await new Promise((resolve) => setTimeout(resolve, 300));
// #endif
// 1⃣ 画背景
// ⭐ 先加载背景图
const [bgImg, avatarImg, titleImg] = await Promise.all([
@@ -1266,6 +1277,11 @@ const saveByCanvas = async (save = true) => {
});
// 6⃣ 输出
// #ifdef MP-ALIPAY
// 支付宝环境:等待绘制指令执行完毕,确保渲染完成
await new Promise((resolve) => setTimeout(resolve, 300));
// #endif
uni.canvasToTempFilePath({
canvas: canvas, // Canvas 2D 必须传 canvas 实例
width: canvas.width,