小程序激励广告一直报"errCode":1002,广告单元无效?广告位ID核对了好几遍了,没有填错。
// 微信广告 激励广告 初始化方法
initRewardedVideoAd() {
if (wx.createRewardedVideoAd) {
rewardedVideoAd = wx.createRewardedVideoAd({
adUnitId: 'adunit-xxxxxx'
});
rewardedVideoAd.onError((err) => {
console.error('激励视频广告加载失败', err);
});
rewardedVideoAd.onClose((res) => {
if ((res && res.isEnded) || res === undefined) {
// 检查用户是否已经登录
if (!that.userInfo) {
console.log('用户未登录,不发放奖励');
return;
}
// 生成当前时间的 ISO 字符串
const create_date = new Date().toISOString();
const update_date = new Date().toISOString();
// 确保 userId 正确提取
const userId = that.userInfo._id;
// 调用云函数并传递 userId、create_date 和 update_date 作为顶层参数
uniCloud.callFunction({
name: 'rewardAdScore',
data: {
userId: userId, // 直接传递 userId
create_date: create_date, // 传递创建时间
update_date: update_date // 传递更新时间
}
}).then(result => {
if (result.result.success) {
uni.showToast({
title: '积分已发放!',
icon: 'success'
});
// 刷新用户积分显示
that.getScore();
} else {
uni.showToast({
title: '积分发放失败,请稍后再试',
icon: 'none'
});
}
}).catch(err => {
console.error('积分发放失败', err);
uni.showToast({
title: '积分发放失败,请稍后再试',
icon: 'none'
});
});
} else {
// 播放中途退出,进行提示
console.log('中途退出');
}
});
}
},

你好,麻烦提供一下代码片段和appid
我也遇到相同情况了,老哥,是怎么解决的呢?