微信小程序激励视频解锁高级功能(防刷完整观看校验)
判断 res.isEnded 确保用户完整看完视频才解锁次数或高清导出。
判断 res.isEnded 确保用户完整看完视频才解锁次数或高清导出。
const videoAd = wx.createRewardedVideoAd({ adUnitId: 'adunit-xxxx' });
videoAd.onClose((res) => {
if (res && res.isEnded) {
// 完整看完,发放奖励
wx.showToast({ title: '已解锁特权', icon: 'success' });
} else {
wx.showToast({ title: '需看完视频才能解锁', icon: 'none' });
}
});
// 触发展示:
function showAd() { videoAd.show().catch(() => videoAd.load().then(() => videoAd.show())); }