import { _decorator, Component } from "cc"; import { DataSystem } from "../core/data/DataSystem"; import { ADData } from "../data/jsb/ADData"; import { ISJSB, platform } from "../data/jsb/platform"; import { Http } from '../core/net/Http'; import { g } from "../data/g"; const { ccclass, property, requireComponent } = _decorator; /** * 激励视频系统 * @author 袁浩 */ @ccclass('RewardVideoSystem') @requireComponent(Http) export class RewardVideoSystem extends Component { private static thisObject: RewardVideoSystem; // private callback: (value: ADData) => void; // private showTime = 0; start() { RewardVideoSystem.thisObject = this; } // update() { // let adData = DataSystem.getData(ADData); // if (DataSystem.watch(ADData, "rewardVideoADShow")) {//展示 // //上报展示 // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj }); // } // if (DataSystem.watch(ADData, "rewardVideoADComplete")) {//完播 // //完播由服务端上报 // this.callback(adData); // this.callback = null; // this.showTime = 0; // } // if (DataSystem.watch(ADData, "rewardVideoADLoss")) {//放弃 // //放弃不用上报 // this.callback(null); // this.callback = null; // this.showTime = 0; // } // if (DataSystem.watch(ADData, "rewardVideoADError")) {//加载失败 // //上报失败 // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj }); // this.callback(null); // this.callback = null; // this.showTime = 0; // } // if (DataSystem.watch(ADData, "bannerADShow")) {//banner展示 // DataSystem.getData(ADData).ad_type = 7;//上报展示 // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj }); // } // if (DataSystem.watch(ADData, "fullScreenADShow")) {//全屏展示 // DataSystem.getData(ADData).ad_type = 9;//上报展示 // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj }); // } // if (DataSystem.watch(ADData, "fullScreenADComplete")) {//全屏完播 // DataSystem.getData(ADData).ad_type = 8;//上报展示 // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj }); // } // if (DataSystem.watch(ADData, "interstitalADShow")) {//插屏展示 // DataSystem.getData(ADData).ad_type = 2; // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj }); // } // if (DataSystem.watch(ADData, "nativeExpressADShow")) {//信息流展示展示 // DataSystem.getData(ADData).ad_type = 3; // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj }); // } // if (!!this.showTime && Date.now() - this.showTime > 60 * 1000) {//展示60秒后无返回则清空 // this.showTime = 0; // this.callback = null; // } // } // public show() { // return new Promise((resolve => { // if (!ISJSB()) {//web版本直接返回成功 // resolve(DataSystem.getData(ADData)); // return; // } // if (this.callback) {//如果正在展示则返回无奖励 // resolve(null); // return; // } // this.callback = resolve; // this.showTime = Date.now(); // platform.showRewardVideoAD(); // })); // } /** * 展示激励视频 * @returns 是否可以发放奖励 */ public static show() { return g.showRewardVideo(); } }