RewardVideoSystem.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { _decorator, Component } from "cc";
  2. import { DataSystem } from "../core/data/DataSystem";
  3. import { ADData } from "../data/jsb/ADData";
  4. import { ISJSB, platform } from "../data/jsb/platform";
  5. import { Http } from '../core/net/Http';
  6. import { g } from "../data/g";
  7. const { ccclass, property, requireComponent } = _decorator;
  8. /**
  9. * 激励视频系统
  10. * @author 袁浩
  11. */
  12. @ccclass('RewardVideoSystem')
  13. @requireComponent(Http)
  14. export class RewardVideoSystem extends Component {
  15. private static thisObject: RewardVideoSystem;
  16. // private callback: (value: ADData) => void;
  17. // private showTime = 0;
  18. start() {
  19. RewardVideoSystem.thisObject = this;
  20. }
  21. // update() {
  22. // let adData = DataSystem.getData(ADData);
  23. // if (DataSystem.watch(ADData, "rewardVideoADShow")) {//展示
  24. // //上报展示
  25. // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj });
  26. // }
  27. // if (DataSystem.watch(ADData, "rewardVideoADComplete")) {//完播
  28. // //完播由服务端上报
  29. // this.callback(adData);
  30. // this.callback = null;
  31. // this.showTime = 0;
  32. // }
  33. // if (DataSystem.watch(ADData, "rewardVideoADLoss")) {//放弃
  34. // //放弃不用上报
  35. // this.callback(null);
  36. // this.callback = null;
  37. // this.showTime = 0;
  38. // }
  39. // if (DataSystem.watch(ADData, "rewardVideoADError")) {//加载失败
  40. // //上报失败
  41. // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj });
  42. // this.callback(null);
  43. // this.callback = null;
  44. // this.showTime = 0;
  45. // }
  46. // if (DataSystem.watch(ADData, "bannerADShow")) {//banner展示
  47. // DataSystem.getData(ADData).ad_type = 7;//上报展示
  48. // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj });
  49. // }
  50. // if (DataSystem.watch(ADData, "fullScreenADShow")) {//全屏展示
  51. // DataSystem.getData(ADData).ad_type = 9;//上报展示
  52. // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj });
  53. // }
  54. // if (DataSystem.watch(ADData, "fullScreenADComplete")) {//全屏完播
  55. // DataSystem.getData(ADData).ad_type = 8;//上报展示
  56. // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj });
  57. // }
  58. // if (DataSystem.watch(ADData, "interstitalADShow")) {//插屏展示
  59. // DataSystem.getData(ADData).ad_type = 2;
  60. // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj });
  61. // }
  62. // if (DataSystem.watch(ADData, "nativeExpressADShow")) {//信息流展示展示
  63. // DataSystem.getData(ADData).ad_type = 3;
  64. // this.getComponent(Http).send("/api/ad/videoLog", { adData: adData.obj });
  65. // }
  66. // if (!!this.showTime && Date.now() - this.showTime > 60 * 1000) {//展示60秒后无返回则清空
  67. // this.showTime = 0;
  68. // this.callback = null;
  69. // }
  70. // }
  71. // public show() {
  72. // return new Promise<ADData>((resolve => {
  73. // if (!ISJSB()) {//web版本直接返回成功
  74. // resolve(DataSystem.getData(ADData));
  75. // return;
  76. // }
  77. // if (this.callback) {//如果正在展示则返回无奖励
  78. // resolve(null);
  79. // return;
  80. // }
  81. // this.callback = resolve;
  82. // this.showTime = Date.now();
  83. // platform.showRewardVideoAD();
  84. // }));
  85. // }
  86. /**
  87. * 展示激励视频
  88. * @returns 是否可以发放奖励
  89. */
  90. public static show() {
  91. return g.showRewardVideo();
  92. }
  93. }