薛鸿潇 5 rokov pred
rodič
commit
7c56b238fd
1 zmenil súbory, kde vykonal 25 pridanie a 1 odobranie
  1. 25 1
      assets/script/mk/system/AdSystem.ts

+ 25 - 1
assets/script/mk/system/AdSystem.ts

@@ -6,7 +6,7 @@ import JsbSystem from "./JsbSystem";
  * @author 冯聪
  * @author 冯聪
  */
  */
 export default class AdSystem {
 export default class AdSystem {
-    
+
     /** 构造函数
     /** 构造函数
      * @param adSdk 传入当前使用广告sdk
      * @param adSdk 传入当前使用广告sdk
      */
      */
@@ -75,6 +75,7 @@ export default class AdSystem {
      */
      */
     public wacthAdSuccess(placementId = '') {
     public wacthAdSuccess(placementId = '') {
         mk.console.log("wacthAdSuccess");
         mk.console.log("wacthAdSuccess");
+        if (this.isAdCooling()) return;
         this.videoAdcallBack(true);
         this.videoAdcallBack(true);
     }
     }
 
 
@@ -109,4 +110,27 @@ export default class AdSystem {
             // WxMgr.getInstance().showRewardAd(pop)
             // WxMgr.getInstance().showRewardAd(pop)
         }
         }
     }
     }
+
+    /** 时评冷却倒计时 */
+    private _ad_cooling_time: number = 0;
+
+    /**
+     * 视频是否冷却
+     * @returns 视频冷却中
+     */
+    private isAdCooling(): boolean {
+        if (this._ad_cooling_time > 0) {
+            mk.tip.pop('当前看视频太频繁了,请' + this._ad_cooling_time + '秒后再试');
+            return true;
+        }
+        this._ad_cooling_time = 5;
+        this.runCooling();
+        return false;
+    }
+    private runCooling() {
+        this._ad_cooling_time--;
+        if (this._ad_cooling_time > 0) {
+            setTimeout(this.runCooling.bind(this), 1000);
+        }
+    }
 }
 }