|
@@ -9,19 +9,32 @@ import ATSDKMgr from "./ATSDKMgr";
|
|
|
*/
|
|
*/
|
|
|
export default class ATInterstitial extends zgSingleton {
|
|
export default class ATInterstitial extends zgSingleton {
|
|
|
|
|
|
|
|
|
|
+ /** */
|
|
|
private ATInterstitialJS: any;
|
|
private ATInterstitialJS: any;
|
|
|
- private interType:number ;
|
|
|
|
|
|
|
|
|
|
|
|
+ /** 插屏广告类型 0 插屏 1全屏 */
|
|
|
|
|
+ private interAdType: number = 0;
|
|
|
|
|
+ /** 插屏广告状态 */
|
|
|
|
|
+ private interAdState: InterAdState = 0;
|
|
|
|
|
+ /** 是否加载完显示 */
|
|
|
|
|
+ private ifLoadShow: boolean = false;
|
|
|
|
|
+
|
|
|
|
|
+ /** 初始化 */
|
|
|
init() {
|
|
init() {
|
|
|
this.ATInterstitialJS = cc["ATInterstitialJS"];
|
|
this.ATInterstitialJS = cc["ATInterstitialJS"];
|
|
|
this.ATInterstitialJS.proxy = this;;
|
|
this.ATInterstitialJS.proxy = this;;
|
|
|
this.ATInterstitialJS.init();
|
|
this.ATInterstitialJS.init();
|
|
|
- this.loadInter(0);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (this.interAdState == InterAdState.Unload) {
|
|
|
|
|
+ this.loadInter(0);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 广告位id */
|
|
|
|
|
- placementID(type: number) {
|
|
|
|
|
- if (type == 0) {
|
|
|
|
|
|
|
+ /** 广告位id
|
|
|
|
|
+ * @param 0 插屏 1 全屏
|
|
|
|
|
+ */
|
|
|
|
|
+ placementID() {
|
|
|
|
|
+ if (this.interAdType == 0) {
|
|
|
if (cc.sys.os === cc.sys.OS_IOS) {
|
|
if (cc.sys.os === cc.sys.OS_IOS) {
|
|
|
return ATSDKMgr.topon_inter_placementId;
|
|
return ATSDKMgr.topon_inter_placementId;
|
|
|
} else if (cc.sys.os === cc.sys.OS_ANDROID) {
|
|
} else if (cc.sys.os === cc.sys.OS_ANDROID) {
|
|
@@ -37,16 +50,28 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 插屏广告
|
|
|
|
|
- * @param type 0 普通插屏 1 全屏视频插屏
|
|
|
|
|
|
|
+ //广告逻辑部分------------------------------------------------------------------------
|
|
|
|
|
+ /** 检测是否插屏预备好了 */
|
|
|
|
|
+ hasAdReady() {
|
|
|
|
|
+ return this.ATInterstitialJS.hasAdReady();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 加载插屏广告
|
|
|
|
|
+ * @param type 0 插屏 1 全屏
|
|
|
*/
|
|
*/
|
|
|
- loadInter(type) {
|
|
|
|
|
- this.interType = type;
|
|
|
|
|
|
|
+ loadInter(type: number, ifLoadShow: boolean = false) {
|
|
|
|
|
+
|
|
|
|
|
+ this.interAdType = type;
|
|
|
|
|
+ this.ifLoadShow = ifLoadShow;
|
|
|
|
|
+
|
|
|
|
|
+ this.interAdState = InterAdState.Loading;
|
|
|
|
|
+ this.ATInterstitialJS.loadInter(type);
|
|
|
|
|
+
|
|
|
// // console.log('99999999 loadInterPre ', type)
|
|
// // console.log('99999999 loadInterPre ', type)
|
|
|
// if (!this.onloadInter) {
|
|
// if (!this.onloadInter) {
|
|
|
// this.onloadInter = true
|
|
// this.onloadInter = true
|
|
|
// // console.log('99999999 loadInter ', type)
|
|
// // console.log('99999999 loadInter ', type)
|
|
|
- this.ATInterstitialJS.loadInter(type);
|
|
|
|
|
// //FC:UROI事件
|
|
// //FC:UROI事件
|
|
|
// if (GameM.commonData.ifUROI) {
|
|
// if (GameM.commonData.ifUROI) {
|
|
|
// let eventID = EncryptUtil.randomString(32);
|
|
// let eventID = EncryptUtil.randomString(32);
|
|
@@ -55,21 +80,44 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
// }
|
|
// }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- showInter(type) {
|
|
|
|
|
- this.interType = type
|
|
|
|
|
- if (this.ATInterstitialJS.checkInterReady(type)) {
|
|
|
|
|
- this.ATInterstitialJS.showInter(type);
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 显示插屏广告
|
|
|
|
|
+ * @param type 0 插屏 1 全屏
|
|
|
|
|
+ */
|
|
|
|
|
+ showInter(type: number) {
|
|
|
|
|
+
|
|
|
|
|
+ this.interAdType = type;
|
|
|
|
|
+
|
|
|
|
|
+ if (this.interAdState == InterAdState.Show) {
|
|
|
|
|
+ //正在显示不重复弹出
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- this.loadInter(type)
|
|
|
|
|
|
|
+ if (this.hasAdReady()) {
|
|
|
|
|
+ this.interAdState = InterAdState.Show;
|
|
|
|
|
+ this.ATInterstitialJS.showInter(type);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ //如果正在加载中,则不处理
|
|
|
|
|
+ if (this.interAdState == InterAdState.Loading) {
|
|
|
|
|
+ //正在加载不重复加载
|
|
|
|
|
+ this.ifLoadShow = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ this.loadInter(type, true)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- // this.ATInterstitialJS.showInter(0);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//广告回调部分------------------------------------------------------------------------
|
|
//广告回调部分------------------------------------------------------------------------
|
|
|
onInterstitialAdLoaded(placementId) {
|
|
onInterstitialAdLoaded(placementId) {
|
|
|
- // this.onloadInter = false
|
|
|
|
|
- // // console.log('99999999 onInterstitialAdLoaded ')
|
|
|
|
|
|
|
+
|
|
|
|
|
+ this.interAdState = InterAdState.LoadSuccess;
|
|
|
|
|
+
|
|
|
|
|
+ if (this.ifLoadShow) {
|
|
|
|
|
+ this.showInter(this.interAdType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// if (GameM.commonData.ifUROI) {
|
|
// if (GameM.commonData.ifUROI) {
|
|
|
// let eventID = EncryptUtil.randomString(32);
|
|
// let eventID = EncryptUtil.randomString(32);
|
|
|
// AdM.sendUROIEvent(eventID, '', placementId, "ad_fill", "interstitial", 'other', '')
|
|
// AdM.sendUROIEvent(eventID, '', placementId, "ad_fill", "interstitial", 'other', '')
|
|
@@ -77,8 +125,7 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onInterstitialAdLoadFail(placementId, errorInfo) {
|
|
onInterstitialAdLoadFail(placementId, errorInfo) {
|
|
|
- // this.onloadInter = false
|
|
|
|
|
- // // console.log('99999999 onInterstitialAdLoadFail')
|
|
|
|
|
|
|
+ this.interAdState = InterAdState.LoadFail;
|
|
|
|
|
|
|
|
// if (placementId == GameM.commonData.fullInterPlaceId) {
|
|
// if (placementId == GameM.commonData.fullInterPlaceId) {
|
|
|
// EffectNode.instance.PlayTip('拉取全屏视频失败,请稍后再试')
|
|
// EffectNode.instance.PlayTip('拉取全屏视频失败,请稍后再试')
|
|
@@ -91,6 +138,8 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
|
|
|
|
|
//广告展示成功
|
|
//广告展示成功
|
|
|
onInterstitialAdShow(placementId, callbackInfo) {
|
|
onInterstitialAdShow(placementId, callbackInfo) {
|
|
|
|
|
+ this.interAdState = InterAdState.Show;
|
|
|
|
|
+
|
|
|
// // console.log('99999999 onInterstitialAdShow')
|
|
// // console.log('99999999 onInterstitialAdShow')
|
|
|
// let data = JSON.parse(callbackInfo)
|
|
// let data = JSON.parse(callbackInfo)
|
|
|
// let id = 2
|
|
// let id = 2
|
|
@@ -125,6 +174,9 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
|
|
|
|
|
//插屏广告关闭
|
|
//插屏广告关闭
|
|
|
onInterstitialAdClose(placementId, callbackInfo) {
|
|
onInterstitialAdClose(placementId, callbackInfo) {
|
|
|
|
|
+ this.interAdState = InterAdState.Close;
|
|
|
|
|
+ this.loadInter(this.interAdType)
|
|
|
|
|
+
|
|
|
// //给奖励
|
|
// //给奖励
|
|
|
// // console.log('AnyThinkInterstitialDemo ', this.interType)
|
|
// // console.log('AnyThinkInterstitialDemo ', this.interType)
|
|
|
// if (placementId == GameM.commonData.fullInterPlaceId) {
|
|
// if (placementId == GameM.commonData.fullInterPlaceId) {
|
|
@@ -138,8 +190,22 @@ export default class ATInterstitial extends zgSingleton {
|
|
|
// data.network_firm_id, data.adsource_id, data.adsource_index, data.adsource_price,
|
|
// data.network_firm_id, data.adsource_id, data.adsource_index, data.adsource_price,
|
|
|
// data.adsource_isheaderbidding, data.publisher_revenue, data.precision, data.ecpm_level)
|
|
// data.adsource_isheaderbidding, data.publisher_revenue, data.precision, data.ecpm_level)
|
|
|
// }
|
|
// }
|
|
|
-
|
|
|
|
|
- this.loadInter(this.interType)
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
+/** 插屏广告加载状态 */
|
|
|
|
|
+export enum InterAdState {
|
|
|
|
|
+ /** 未加载 */
|
|
|
|
|
+ Unload = 0,
|
|
|
|
|
+ /** 加载中 */
|
|
|
|
|
+ Loading = 1,
|
|
|
|
|
+ /** 加载成功 */
|
|
|
|
|
+ LoadSuccess = 2,
|
|
|
|
|
+ /** 加载失败 */
|
|
|
|
|
+ LoadFail = 3,
|
|
|
|
|
+ /** 显示状态 */
|
|
|
|
|
+ Show = 4,
|
|
|
|
|
+ /** 关闭状态 */
|
|
|
|
|
+ Close = 5
|
|
|
}
|
|
}
|