Browse Source

视频间隔添加

薛鸿潇 5 years ago
parent
commit
7c56b238fd
1 changed files with 25 additions and 1 deletions
  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 冯聪
  */
 export default class AdSystem {
-    
+
     /** 构造函数
      * @param adSdk 传入当前使用广告sdk
      */
@@ -75,6 +75,7 @@ export default class AdSystem {
      */
     public wacthAdSuccess(placementId = '') {
         mk.console.log("wacthAdSuccess");
+        if (this.isAdCooling()) return;
         this.videoAdcallBack(true);
     }
 
@@ -109,4 +110,27 @@ export default class AdSystem {
             // 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);
+        }
+    }
 }