This commit is contained in:
cao123
2026-09-07 13:50:02 +08:00
parent 1033136997
commit 89cd9d0404
6 changed files with 282 additions and 173 deletions
+53 -59
View File
@@ -62,7 +62,8 @@ Page({
);
return;
}
const bool = await app.login("video");
if (!bool) return;
// 开启防截屏(仅限当前页面生命周期内)
//@ts-ignore
wx.setVisualEffectOnCapture({
@@ -306,68 +307,61 @@ Page({
return;
}
const { pass } = res.data || {};
const { pass, redPackage } = res.data || {};
if (pass) {
wx.showModal({
content: "🎉 领取红包!",
showCancel: false,
confirmText: "立即领取",
confirmColor: "#FF0000",
success: async (res) => {
if (res.confirm) {
if (redPackage?.packageInfo) {
try {
wx.showLoading({ title: "领取中", mask: true });
if (wx.canIUse?.("requestMerchantTransfer")) {
await new Promise<void>((resolve, reject) => {
// @ts-ignore
wx.requestMerchantTransfer({
mchId: redPackage.mchId,
appId,
package: redPackage.packageInfo,
success: () => {
wx.showToast({ title: "领取成功", icon: "success" });
resolve();
},
fail: (err: any) => {
console.error("拉起转账失败:", err);
wx.showToast({ title: "领取失败", icon: "none" });
reject(new Error(err?.errMsg || "领取失败"));
},
});
});
} else {
wx.showModal({
content: "你的微信版本过低,请更新至最新版本。",
showCancel: false,
});
throw new Error("微信版本过低");
}
} catch (err: any) {
wx.hideLoading();
const msg = err?.data?.msg || err?.errMsg || err?.message || "领取失败";
wx.showToast({ title: msg, icon: "none" });
}
} else {
await this.handleReceive(redPackage.redId);
}
}
},
});
} else {
wx.showToast({
title: "提交成功",
icon: "success",
duration: 2000,
title: "回答错误,您与红包擦肩而过",
icon: "none",
duration: 6000,
});
}
// if (pass) {
// wx.showModal({
// content: "🎉 领取红包!",
// showCancel: false,
// confirmText: "立即领取",
// confirmColor: "#FF0000",
// success: async (res) => {
// if (res.confirm) {
// if (redPackage?.packageInfo) {
// try {
// wx.showLoading({ title: "领取中", mask: true });
// if (wx.canIUse?.("requestMerchantTransfer")) {
// await new Promise<void>((resolve, reject) => {
// // @ts-ignore
// wx.requestMerchantTransfer({
// mchId: redPackage.mchId,
// appId,
// package: redPackage.packageInfo,
// success: () => {
// wx.showToast({ title: "领取成功", icon: "success" });
// resolve();
// },
// fail: (err: any) => {
// console.error("拉起转账失败:", err);
// wx.showToast({ title: "领取失败", icon: "none" });
// reject(new Error(err?.errMsg || "领取失败"));
// },
// });
// });
// } else {
// wx.showModal({
// content: "你的微信版本过低,请更新至最新版本。",
// showCancel: false,
// });
// throw new Error("微信版本过低");
// }
// } catch (err: any) {
// wx.hideLoading();
// const msg = err?.data?.msg || err?.errMsg || err?.message || "领取失败";
// wx.showToast({ title: msg, icon: "none" });
// }
// } else {
// await this.handleReceive(redPackage.redId);
// }
// }
// },
// });
// } else {
// wx.showToast({
// title: "回答错误,您与红包擦肩而过",
// icon: "none",
// duration: 6000,
// });
// }
},
async handleReceive(id: any) {
const { code } = this.data.store as Record<string, any>;