|
|
@@ -51,6 +51,29 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 检查当前广告类型
|
|
|
+ * @param placementId 当前广告id
|
|
|
+ * @returns 0 插屏 1 全屏
|
|
|
+ */
|
|
|
+ checkPlacementIDType(placementId) {
|
|
|
+ if (cc.sys.os === cc.sys.OS_IOS) {
|
|
|
+ if (placementId == ATSDKMgr.topon_inter_placementId) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (placementId == ATSDKMgr.topon_fullinter_placementId) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ } else if (cc.sys.os === cc.sys.OS_ANDROID) {
|
|
|
+ if (placementId == ATSDKMgr.topon_inter_placementId) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (placementId == ATSDKMgr.topon_fullinter_placementId) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//广告逻辑部分------------------------------------------------------------------------
|
|
|
/** 检测是否插屏预备好了 */
|
|
|
hasAdReady() {
|
|
|
@@ -62,8 +85,6 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
* @param type 0 插屏 1 全屏
|
|
|
*/
|
|
|
loadInter(type: number, ifLoadShow: boolean = false) {
|
|
|
-
|
|
|
- this.interAdType = type;
|
|
|
this.ifLoadShow = ifLoadShow;
|
|
|
|
|
|
this.interAdState = InterAdState.Loading;
|
|
|
@@ -100,24 +121,27 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
|
|
|
//广告回调部分------------------------------------------------------------------------
|
|
|
onInterstitialAdLoaded(placementId) {
|
|
|
-
|
|
|
this.interAdState = InterAdState.LoadSuccess;
|
|
|
|
|
|
if (this.ifLoadShow) {
|
|
|
- this.showInter(this.interAdType);
|
|
|
+ let type = this.checkPlacementIDType(placementId);
|
|
|
+ this.showInter(type);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
onInterstitialAdLoadFail(placementId, errorInfo) {
|
|
|
this.interAdState = InterAdState.LoadFail;
|
|
|
|
|
|
- if (this.interAdType == 1) {
|
|
|
- mk.tip.pop('拉取全屏视频失败,请稍后再试');
|
|
|
- gData.adData.updateADLog(10, placementId);
|
|
|
+ let id = 11
|
|
|
+ let type = this.checkPlacementIDType(placementId);
|
|
|
+ if (type == 0) {
|
|
|
+ id = 11
|
|
|
}
|
|
|
- else if (this.interAdType == 0) {
|
|
|
- gData.adData.updateADLog(11, placementId);
|
|
|
+ else if (type == 1) {
|
|
|
+ mk.tip.pop('拉取全屏视频失败,请稍后再试');
|
|
|
+ id = 10
|
|
|
}
|
|
|
+ gData.adData.updateADLog(id, placementId);
|
|
|
}
|
|
|
|
|
|
//广告展示成功
|
|
|
@@ -127,10 +151,11 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
// // console.log('99999999 onInterstitialAdShow')
|
|
|
let data = JSON.parse(callbackInfo)
|
|
|
let id = 2
|
|
|
- if (this.interAdType == 0) {
|
|
|
+ let type = this.checkPlacementIDType(placementId);
|
|
|
+ if (type == 0) {
|
|
|
id = 2
|
|
|
}
|
|
|
- else if (this.interAdType == 1) {
|
|
|
+ else if (type == 1) {
|
|
|
id = 9
|
|
|
}
|
|
|
gData.adData.updateADLog(id, placementId, data);
|
|
|
@@ -157,12 +182,16 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
//插屏广告关闭
|
|
|
onInterstitialAdClose(placementId, callbackInfo) {
|
|
|
this.interAdState = InterAdState.Close;
|
|
|
- this.loadInter(this.interAdType)
|
|
|
|
|
|
// //给奖励
|
|
|
- if (this.interAdType == 1) {
|
|
|
+ let type = this.checkPlacementIDType(placementId);
|
|
|
+ if (type == 1) {
|
|
|
let data = JSON.parse(callbackInfo);
|
|
|
gData.adData.updateADLog(8, placementId, data);
|
|
|
+ this.loadInter(1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.loadInter(0);
|
|
|
}
|
|
|
}
|
|
|
}
|