const util = require('../../utils/utils.js') let videoAd = null; var app = getApp(); Page({ data: { }, onLoad: function (options) { if (wx.createRewardedVideoAd) { videoAd = wx.createRewardedVideoAd({ adUnitId: 'adunit-edc5c4664389a87a' }) videoAd.onLoad(() => {}) videoAd.onError((err) => {}) videoAd.onClose((res) => { if (res && res.isEnded || res === undefined) { app.request('/deposit/refund', '', 'POST').then(res => { console.log(res); if (res.statusCode == 200) { wx.showToast({ title: '加速成功,稍后到账', icon:'none' }) } }) } else { wx.showToast({ title: '加速失败!', icon:'none' }) } }) } }, home: util.throttle(function (e) { if(app.globalData.compatible){ wx.reLaunch({ url: '/pages/compatible/index/index', }) }else{ wx.reLaunch({ url: '/pages/index/index', }) } },1000), ad(){ if (videoAd) { videoAd.show().catch(() => { // 失败重试 videoAd.load() .then(() => videoAd.show()) .catch(err => { console.log('激励视频 广告显示失败') }) }) } }, onReady: function () { }, onShow: function () { }, onHide: function () { }, onUnload: function () { }, onPullDownRefresh: function () { }, onReachBottom: function () { }, onShareAppMessage: function () { } })