@chiyou/minigame-framework 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/Scripts/index.ts +2 -5
- package/package.json +5 -10
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +0 -78
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +0 -230
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +0 -31
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +0 -224
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +0 -34
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +0 -524
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +0 -34
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +0 -631
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +0 -460
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +0 -31
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +0 -227
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +0 -458
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +0 -35
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +0 -770
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +0 -519
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +0 -492
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +0 -695
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +0 -34
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +0 -597
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +0 -33
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +0 -458
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +0 -51
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +0 -17
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +0 -45
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +0 -555
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +0 -148
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +0 -48
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +0 -715
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +0 -296
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +0 -45
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +0 -284
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +0 -283
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +0 -43
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +0 -406
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +0 -43
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +0 -248
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +0 -517
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +0 -295
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +0 -55
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +0 -964
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +0 -295
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +0 -44
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +0 -393
- package/dist/Framework/Definition/AdDefinition.d.ts +0 -130
- package/dist/Framework/Definition/AdDefinition.js +0 -208
- package/dist/Framework/Definition/FrameworkBase.d.ts +0 -13
- package/dist/Framework/Definition/FrameworkBase.js +0 -23
- package/dist/Framework/Definition/PrivacyDefinition.d.ts +0 -51
- package/dist/Framework/Definition/PrivacyDefinition.js +0 -70
- package/dist/Framework/Definition/SocialDefinition.d.ts +0 -16
- package/dist/Framework/Definition/SocialDefinition.js +0 -2
- package/dist/Framework/Definition/SystemDefinition.d.ts +0 -43
- package/dist/Framework/Definition/SystemDefinition.js +0 -28
- package/dist/Framework/Definition/UIDefinition.d.ts +0 -6
- package/dist/Framework/Definition/UIDefinition.js +0 -7
- package/dist/Framework/Definition/UserDefinition.d.ts +0 -14
- package/dist/Framework/Definition/UserDefinition.js +0 -10
- package/dist/Framework/Manager/AdMgr.d.ts +0 -57
- package/dist/Framework/Manager/AdMgr.js +0 -684
- package/dist/Framework/Manager/AudioMgr.d.ts +0 -28
- package/dist/Framework/Manager/AudioMgr.js +0 -265
- package/dist/Framework/Manager/BaseMgr.d.ts +0 -18
- package/dist/Framework/Manager/BaseMgr.js +0 -114
- package/dist/Framework/Manager/EventMgr.d.ts +0 -18
- package/dist/Framework/Manager/EventMgr.js +0 -90
- package/dist/Framework/Manager/ExcelMgr.d.ts +0 -24
- package/dist/Framework/Manager/ExcelMgr.js +0 -156
- package/dist/Framework/Manager/LifeCycleMgr.d.ts +0 -20
- package/dist/Framework/Manager/LifeCycleMgr.js +0 -110
- package/dist/Framework/Manager/NodePoolMgr.d.ts +0 -53
- package/dist/Framework/Manager/NodePoolMgr.js +0 -279
- package/dist/Framework/Manager/PrivacyMgr.d.ts +0 -15
- package/dist/Framework/Manager/PrivacyMgr.js +0 -176
- package/dist/Framework/Manager/ResMgr.d.ts +0 -49
- package/dist/Framework/Manager/ResMgr.js +0 -337
- package/dist/Framework/Manager/SocialMgr.d.ts +0 -23
- package/dist/Framework/Manager/SocialMgr.js +0 -220
- package/dist/Framework/Manager/SystemMgr.d.ts +0 -24
- package/dist/Framework/Manager/SystemMgr.js +0 -222
- package/dist/Framework/Manager/TimerMgr.d.ts +0 -11
- package/dist/Framework/Manager/TimerMgr.js +0 -63
- package/dist/Framework/Manager/UIMgr.d.ts +0 -33
- package/dist/Framework/Manager/UIMgr.js +0 -223
- package/dist/Framework/Manager/UserMgr.d.ts +0 -15
- package/dist/Framework/Manager/UserMgr.js +0 -148
- package/dist/Framework/Utils/BezierUtils.d.ts +0 -49
- package/dist/Framework/Utils/BezierUtils.js +0 -247
- package/dist/Framework/Utils/CSVUtils.d.ts +0 -35
- package/dist/Framework/Utils/CSVUtils.js +0 -341
- package/dist/Framework/Utils/LogUtils.d.ts +0 -7
- package/dist/Framework/Utils/LogUtils.js +0 -32
- package/dist/Framework/Utils/NumberUtils.d.ts +0 -16
- package/dist/Framework/Utils/NumberUtils.js +0 -44
- package/dist/Framework/Utils/TaskUtils.d.ts +0 -10
- package/dist/Framework/Utils/TaskUtils.js +0 -24
- package/dist/Framework/Utils/TimeUtils.d.ts +0 -19
- package/dist/Framework/Utils/TimeUtils.js +0 -33
- package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +0 -12
- package/dist/Framework/Utils/WXBizDataCryptUtils.js +0 -37
- package/dist/index.d.ts +0 -30
- package/dist/index.js +0 -35
|
@@ -1,695 +0,0 @@
|
|
|
1
|
-
import { AbsAdAdapter, InterstitialAdStatus, RewardedVideoAdStatus } from './AbsAdAdapter';
|
|
2
|
-
import { LogUtils } from '../../Utils/LogUtils';
|
|
3
|
-
import { InterstitialAd_Callback_Status, RewardedVideoAd_Callback_Status, AdDefinition } from '../../Definition/AdDefinition';
|
|
4
|
-
import { PlatformID } from '../../Definition/SystemDefinition';
|
|
5
|
-
class WXInterstitialAd {
|
|
6
|
-
constructor(adUnitId, callback) {
|
|
7
|
-
this.unitId = adUnitId;
|
|
8
|
-
this.ad = null;
|
|
9
|
-
this.status = InterstitialAdStatus.Status_Init;
|
|
10
|
-
this.callback = callback;
|
|
11
|
-
this.errorListener = null;
|
|
12
|
-
this.loadListener = null;
|
|
13
|
-
this.closeListener = null;
|
|
14
|
-
this.isShowImmediately = false;
|
|
15
|
-
}
|
|
16
|
-
destroy() {
|
|
17
|
-
if (this.ad !== null) {
|
|
18
|
-
if (this.errorListener !== null) {
|
|
19
|
-
this.ad.offError(this.errorListener);
|
|
20
|
-
this.errorListener = null;
|
|
21
|
-
}
|
|
22
|
-
if (this.loadListener !== null) {
|
|
23
|
-
this.ad.offLoad(this.loadListener);
|
|
24
|
-
this.loadListener = null;
|
|
25
|
-
}
|
|
26
|
-
if (this.closeListener !== null) {
|
|
27
|
-
this.ad.offClose(this.closeListener);
|
|
28
|
-
this.closeListener = null;
|
|
29
|
-
}
|
|
30
|
-
this.ad.destroy();
|
|
31
|
-
this.ad = null;
|
|
32
|
-
}
|
|
33
|
-
this.isShowImmediately = false;
|
|
34
|
-
this.status = InterstitialAdStatus.Status_Destroyed;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
class WXRewardedVideoAd {
|
|
38
|
-
constructor(adUnitId, callback) {
|
|
39
|
-
this.unitId = adUnitId;
|
|
40
|
-
this.ad = null;
|
|
41
|
-
this.status = RewardedVideoAdStatus.Status_Init;
|
|
42
|
-
this.callback = callback;
|
|
43
|
-
this.errorListener = null;
|
|
44
|
-
this.loadListener = null;
|
|
45
|
-
this.closeListener = null;
|
|
46
|
-
this.isShowImmediately = false;
|
|
47
|
-
}
|
|
48
|
-
destroy() {
|
|
49
|
-
if (this.ad !== null) {
|
|
50
|
-
if (this.errorListener !== null) {
|
|
51
|
-
this.ad.offError(this.errorListener);
|
|
52
|
-
this.errorListener = null;
|
|
53
|
-
}
|
|
54
|
-
if (this.loadListener !== null) {
|
|
55
|
-
this.ad.offLoad(this.loadListener);
|
|
56
|
-
this.loadListener = null;
|
|
57
|
-
}
|
|
58
|
-
if (this.closeListener !== null) {
|
|
59
|
-
this.ad.offClose(this.closeListener);
|
|
60
|
-
this.closeListener = null;
|
|
61
|
-
}
|
|
62
|
-
this.ad.destroy();
|
|
63
|
-
this.ad = null;
|
|
64
|
-
}
|
|
65
|
-
this.isShowImmediately = false;
|
|
66
|
-
this.status = RewardedVideoAdStatus.Status_Destroyed;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
class WXCustomAd {
|
|
70
|
-
constructor(adUnitId, ad, isFirstLoad) {
|
|
71
|
-
this.unitId = adUnitId;
|
|
72
|
-
this.ad = ad;
|
|
73
|
-
this.errorListener = null;
|
|
74
|
-
this.loadListener = null;
|
|
75
|
-
this.resizeListener = null;
|
|
76
|
-
this.closeListener = null;
|
|
77
|
-
this.isRecreating = false;
|
|
78
|
-
this.isFirstLoad = isFirstLoad;
|
|
79
|
-
}
|
|
80
|
-
destroy() {
|
|
81
|
-
if (this.ad !== null) {
|
|
82
|
-
if (this.errorListener !== null) {
|
|
83
|
-
this.ad.offError(this.errorListener);
|
|
84
|
-
this.errorListener = null;
|
|
85
|
-
}
|
|
86
|
-
if (this.loadListener !== null) {
|
|
87
|
-
this.ad.offLoad(this.loadListener);
|
|
88
|
-
this.loadListener = null;
|
|
89
|
-
}
|
|
90
|
-
if (this.resizeListener !== null) {
|
|
91
|
-
this.ad.offResize(this.resizeListener);
|
|
92
|
-
this.resizeListener = null;
|
|
93
|
-
}
|
|
94
|
-
if (this.closeListener !== null) {
|
|
95
|
-
this.ad.offClose(this.closeListener);
|
|
96
|
-
this.closeListener = null;
|
|
97
|
-
}
|
|
98
|
-
this.ad.destroy();
|
|
99
|
-
this.ad = null;
|
|
100
|
-
}
|
|
101
|
-
this.isRecreating = false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
export class AdAdapterWeiXin extends AbsAdAdapter {
|
|
105
|
-
constructor() {
|
|
106
|
-
super(...arguments);
|
|
107
|
-
this.wxInterstitialAd = null;
|
|
108
|
-
this.wxRewardedVideoAd = null;
|
|
109
|
-
this.wxCustomAds = [];
|
|
110
|
-
}
|
|
111
|
-
init(interstitialAdUnitId, interstitialAdCallback, rewardedVideoAdUnitId, rewardedVideoAdCallback) {
|
|
112
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "init()");
|
|
113
|
-
this.wxInterstitialAd = new WXInterstitialAd(interstitialAdUnitId, interstitialAdCallback);
|
|
114
|
-
this.wxRewardedVideoAd = new WXRewardedVideoAd(rewardedVideoAdUnitId, rewardedVideoAdCallback);
|
|
115
|
-
this.wxCustomAds = [];
|
|
116
|
-
}
|
|
117
|
-
createBannerAd(adUnitId) {
|
|
118
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createBannerAd()");
|
|
119
|
-
let isFirstLoad = true;
|
|
120
|
-
for (let i = 0; i < this.wxCustomAds.length; i++) {
|
|
121
|
-
if (this.wxCustomAds[i].unitId === adUnitId) {
|
|
122
|
-
isFirstLoad = this.wxCustomAds[i].isFirstLoad;
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
this.destroyBannerAd(adUnitId);
|
|
127
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createBannerAd() adUnitId=" + adUnitId);
|
|
128
|
-
let bannerAdInfo = AdDefinition.AdInfoConfig.BannerAd_Info;
|
|
129
|
-
if (bannerAdInfo === null || !bannerAdInfo.shouldShow) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
let bannerAdPlatformInfo = AdDefinition.BannerAdStyleConfig.get(PlatformID.ID_MiniGame_WeiXin);
|
|
133
|
-
if (bannerAdPlatformInfo === null) {
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
let bannerAdPostion = this.calcBannerAdPosition(bannerAdInfo, bannerAdPlatformInfo);
|
|
137
|
-
let customAdParam = {
|
|
138
|
-
adUnitId: adUnitId,
|
|
139
|
-
style: {
|
|
140
|
-
left: bannerAdPostion.left,
|
|
141
|
-
top: bannerAdPostion.top,
|
|
142
|
-
width: bannerAdPostion.realWidth,
|
|
143
|
-
fixed: true,
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
if (bannerAdPlatformInfo.canAutoRefresh) {
|
|
147
|
-
customAdParam.adIntervals = bannerAdPlatformInfo.refreshInterval;
|
|
148
|
-
}
|
|
149
|
-
let customAd = window["wx"].createCustomAd(customAdParam);
|
|
150
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wx.createCustomAd() " + (customAd !== null ? "success" : "fail"));
|
|
151
|
-
LogUtils.Instance.log("", customAd);
|
|
152
|
-
if (!customAd) {
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
let wxCustomAd = new WXCustomAd(adUnitId, customAd, isFirstLoad);
|
|
156
|
-
this.wxCustomAds.push(wxCustomAd);
|
|
157
|
-
wxCustomAd.errorListener = (err) => {
|
|
158
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onError()");
|
|
159
|
-
if (err) {
|
|
160
|
-
LogUtils.Instance.log("", err);
|
|
161
|
-
}
|
|
162
|
-
if (!wxCustomAd.isRecreating) {
|
|
163
|
-
wxCustomAd.isRecreating = true;
|
|
164
|
-
this.scheduleOnce(() => {
|
|
165
|
-
wxCustomAd.isRecreating = false;
|
|
166
|
-
this.createCustomAd(adUnitId);
|
|
167
|
-
}, 15);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
wxCustomAd.ad.onError(wxCustomAd.errorListener);
|
|
171
|
-
wxCustomAd.loadListener = () => {
|
|
172
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onLoad()");
|
|
173
|
-
if (wxCustomAd.isFirstLoad) {
|
|
174
|
-
wxCustomAd.isFirstLoad = false;
|
|
175
|
-
}
|
|
176
|
-
if (this.adMgr.isPermanentAdShowing()) {
|
|
177
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.show()");
|
|
178
|
-
wxCustomAd.ad.show()
|
|
179
|
-
.then(() => {
|
|
180
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.show() success");
|
|
181
|
-
}).catch((err) => {
|
|
182
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.show() fail");
|
|
183
|
-
if (err) {
|
|
184
|
-
LogUtils.Instance.log("", err);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
wxCustomAd.ad.onLoad(wxCustomAd.loadListener);
|
|
190
|
-
wxCustomAd.resizeListener = (res) => {
|
|
191
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onResize()");
|
|
192
|
-
if (res) {
|
|
193
|
-
LogUtils.Instance.log("", res);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
wxCustomAd.ad.onResize(wxCustomAd.resizeListener);
|
|
197
|
-
wxCustomAd.closeListener = () => {
|
|
198
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onClose()");
|
|
199
|
-
};
|
|
200
|
-
wxCustomAd.ad.onClose(wxCustomAd.closeListener);
|
|
201
|
-
if (!bannerAdPlatformInfo.canAutoRefresh) {
|
|
202
|
-
if (!wxCustomAd.isRecreating) {
|
|
203
|
-
wxCustomAd.isRecreating = true;
|
|
204
|
-
this.scheduleOnce(() => {
|
|
205
|
-
wxCustomAd.isRecreating = false;
|
|
206
|
-
this.createBannerAd(adUnitId);
|
|
207
|
-
}, bannerAdPlatformInfo.refreshInterval);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
destroyBannerAd(adUnitId) {
|
|
213
|
-
this.destroyCustomAd(adUnitId);
|
|
214
|
-
}
|
|
215
|
-
showBannerAd(adUnitId) {
|
|
216
|
-
this.showCustomAd(adUnitId);
|
|
217
|
-
}
|
|
218
|
-
hideBannerAd(adUnitId) {
|
|
219
|
-
this.hideCustomAd(adUnitId);
|
|
220
|
-
}
|
|
221
|
-
createInterstitialAd() {
|
|
222
|
-
this.destroyInterstitialAd();
|
|
223
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createInterstitialAd() adUnitId=" + this.wxInterstitialAd.unitId);
|
|
224
|
-
let interstitialAd = window["wx"].createInterstitialAd({
|
|
225
|
-
adUnitId: this.wxInterstitialAd.unitId
|
|
226
|
-
});
|
|
227
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wx.createInterstitialAd() " + (interstitialAd !== null ? "success" : "fail"));
|
|
228
|
-
LogUtils.Instance.log("", interstitialAd);
|
|
229
|
-
if (!interstitialAd) {
|
|
230
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_Error;
|
|
231
|
-
this.wxInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
this.wxInterstitialAd.ad = interstitialAd;
|
|
235
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_Init;
|
|
236
|
-
this.wxInterstitialAd.errorListener = (err) => {
|
|
237
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.onError()");
|
|
238
|
-
if (err) {
|
|
239
|
-
LogUtils.Instance.log("", err);
|
|
240
|
-
}
|
|
241
|
-
if (this.wxInterstitialAd.status !== InterstitialAdStatus.Status_Watching) {
|
|
242
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_Error;
|
|
243
|
-
this.wxInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Error);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
this.wxInterstitialAd.ad.onError(this.wxInterstitialAd.errorListener);
|
|
247
|
-
this.wxInterstitialAd.loadListener = () => {
|
|
248
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.onLoad()");
|
|
249
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
|
|
250
|
-
if (this.wxInterstitialAd.isShowImmediately) {
|
|
251
|
-
this.wxInterstitialAd.isShowImmediately = false;
|
|
252
|
-
this._showInterstitialAd();
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
this.wxInterstitialAd.ad.onLoad(this.wxInterstitialAd.loadListener);
|
|
256
|
-
this.wxInterstitialAd.closeListener = () => {
|
|
257
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.onClose()");
|
|
258
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_Watched;
|
|
259
|
-
this.wxInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Close);
|
|
260
|
-
this.scheduleOnce(() => {
|
|
261
|
-
if (this.wxInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
|
|
262
|
-
this._loadInterstitialAd(false);
|
|
263
|
-
}
|
|
264
|
-
}, 2);
|
|
265
|
-
};
|
|
266
|
-
this.wxInterstitialAd.ad.onClose(this.wxInterstitialAd.closeListener);
|
|
267
|
-
this.scheduleOnce(() => {
|
|
268
|
-
if (this.wxInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
|
|
269
|
-
this._loadInterstitialAd(false);
|
|
270
|
-
}
|
|
271
|
-
}, 2);
|
|
272
|
-
}
|
|
273
|
-
showInterstitialAd() {
|
|
274
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "showInterstitialAd()");
|
|
275
|
-
if (this.wxInterstitialAd.ad === null) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.status=" + InterstitialAdStatus[this.wxInterstitialAd.status]);
|
|
279
|
-
switch (this.wxInterstitialAd.status) {
|
|
280
|
-
case InterstitialAdStatus.Status_Destroyed:
|
|
281
|
-
case InterstitialAdStatus.Status_Watching:
|
|
282
|
-
case InterstitialAdStatus.Status_StartToWatch:
|
|
283
|
-
break;
|
|
284
|
-
case InterstitialAdStatus.Status_Loaded:
|
|
285
|
-
this._showInterstitialAd();
|
|
286
|
-
break;
|
|
287
|
-
case InterstitialAdStatus.Status_Watched:
|
|
288
|
-
case InterstitialAdStatus.Status_Init:
|
|
289
|
-
case InterstitialAdStatus.Status_Error:
|
|
290
|
-
this._loadInterstitialAd(true);
|
|
291
|
-
break;
|
|
292
|
-
default:
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
destroyInterstitialAd() {
|
|
297
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "destroyInterstitialAd()");
|
|
298
|
-
this.wxInterstitialAd.destroy();
|
|
299
|
-
}
|
|
300
|
-
isIntersititialAdShowing() {
|
|
301
|
-
if (this.wxInterstitialAd.ad === null) {
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
if (this.wxInterstitialAd.status === InterstitialAdStatus.Status_Watching) {
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
_loadInterstitialAd(isShowImmediately) {
|
|
310
|
-
this.wxInterstitialAd.isShowImmediately = isShowImmediately;
|
|
311
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.load()");
|
|
312
|
-
this.wxInterstitialAd.ad.load()
|
|
313
|
-
.then(() => {
|
|
314
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.load() success");
|
|
315
|
-
}).catch((err) => {
|
|
316
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.load() error");
|
|
317
|
-
if (err) {
|
|
318
|
-
LogUtils.Instance.log("", err);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
_showInterstitialAd() {
|
|
323
|
-
if (this.wxInterstitialAd.status !== InterstitialAdStatus.Status_Loaded) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_StartToWatch;
|
|
327
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.show()");
|
|
328
|
-
this.wxInterstitialAd.ad.show()
|
|
329
|
-
.then(() => {
|
|
330
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.show() success");
|
|
331
|
-
if (this.wxInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
|
|
332
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_Watching;
|
|
333
|
-
this.wxInterstitialAd.callback(InterstitialAd_Callback_Status.Status_Watching);
|
|
334
|
-
}
|
|
335
|
-
}).catch((err) => {
|
|
336
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxInterstitialAd.ad.show() error");
|
|
337
|
-
if (err) {
|
|
338
|
-
LogUtils.Instance.log("", err);
|
|
339
|
-
}
|
|
340
|
-
if (this.wxInterstitialAd.status === InterstitialAdStatus.Status_StartToWatch) {
|
|
341
|
-
this.wxInterstitialAd.status = InterstitialAdStatus.Status_Loaded;
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
createRewardedVideoAd() {
|
|
346
|
-
this.destroyRewardedVideoAd();
|
|
347
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createRewardedVideoAd() adUnitId=" + this.wxRewardedVideoAd.unitId);
|
|
348
|
-
let rewardedVideoAd = window["wx"].createRewardedVideoAd({
|
|
349
|
-
adUnitId: this.wxRewardedVideoAd.unitId,
|
|
350
|
-
});
|
|
351
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wx.createRewardedVideoAd() " + (rewardedVideoAd !== null ? "success" : "fail"));
|
|
352
|
-
LogUtils.Instance.log("", rewardedVideoAd);
|
|
353
|
-
if (!rewardedVideoAd) {
|
|
354
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
355
|
-
this.wxRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
this.wxRewardedVideoAd.ad = rewardedVideoAd;
|
|
359
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_Init;
|
|
360
|
-
this.wxRewardedVideoAd.errorListener = (err) => {
|
|
361
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.onError()");
|
|
362
|
-
if (err) {
|
|
363
|
-
LogUtils.Instance.log("", err);
|
|
364
|
-
}
|
|
365
|
-
if (this.wxRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Watching) {
|
|
366
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_Error;
|
|
367
|
-
this.wxRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Error);
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
this.wxRewardedVideoAd.ad.onError(this.wxRewardedVideoAd.errorListener);
|
|
371
|
-
this.wxRewardedVideoAd.loadListener = (res) => {
|
|
372
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.onLoad()");
|
|
373
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
374
|
-
if (this.wxRewardedVideoAd.isShowImmediately) {
|
|
375
|
-
this.wxRewardedVideoAd.isShowImmediately = false;
|
|
376
|
-
this._showRewardedVideoAd();
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
this.wxRewardedVideoAd.ad.onLoad(this.wxRewardedVideoAd.loadListener);
|
|
380
|
-
this.wxRewardedVideoAd.closeListener = (res) => {
|
|
381
|
-
let isEnded = (res !== null) ? res.isEnded : false;
|
|
382
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.onClose()");
|
|
383
|
-
LogUtils.Instance.log("", "isEnded=" + isEnded);
|
|
384
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watched;
|
|
385
|
-
if (isEnded) {
|
|
386
|
-
this.wxRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Complete);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
this.wxRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Giveup);
|
|
390
|
-
}
|
|
391
|
-
this.scheduleOnce(() => {
|
|
392
|
-
if (this.wxRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
393
|
-
this._loadRewardedVideoAd(false);
|
|
394
|
-
}
|
|
395
|
-
}, 2);
|
|
396
|
-
};
|
|
397
|
-
this.wxRewardedVideoAd.ad.onClose(this.wxRewardedVideoAd.closeListener);
|
|
398
|
-
this.scheduleOnce(() => {
|
|
399
|
-
if (this.wxRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
400
|
-
this._loadRewardedVideoAd(false);
|
|
401
|
-
}
|
|
402
|
-
}, 2);
|
|
403
|
-
}
|
|
404
|
-
showRewardedVideoAd() {
|
|
405
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "showRewardedVideoAd()");
|
|
406
|
-
if (this.wxRewardedVideoAd.ad === null) {
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.status=" + RewardedVideoAdStatus[this.wxRewardedVideoAd.status]);
|
|
410
|
-
switch (this.wxRewardedVideoAd.status) {
|
|
411
|
-
case RewardedVideoAdStatus.Status_Destroyed:
|
|
412
|
-
case RewardedVideoAdStatus.Status_StartToWatch:
|
|
413
|
-
case RewardedVideoAdStatus.Status_Watching:
|
|
414
|
-
break;
|
|
415
|
-
case RewardedVideoAdStatus.Status_Loaded:
|
|
416
|
-
this._showRewardedVideoAd();
|
|
417
|
-
break;
|
|
418
|
-
case RewardedVideoAdStatus.Status_Watched:
|
|
419
|
-
case RewardedVideoAdStatus.Status_Init:
|
|
420
|
-
case RewardedVideoAdStatus.Status_Error:
|
|
421
|
-
this._loadRewardedVideoAd(true);
|
|
422
|
-
break;
|
|
423
|
-
default:
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
destroyRewardedVideoAd() {
|
|
428
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "destroyRewardedVideoAd()");
|
|
429
|
-
this.wxRewardedVideoAd.destroy();
|
|
430
|
-
}
|
|
431
|
-
isRewardedVideoAdLoaded() {
|
|
432
|
-
if (this.wxRewardedVideoAd.ad === null) {
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
if (this.wxRewardedVideoAd.status === RewardedVideoAdStatus.Status_Loaded) {
|
|
436
|
-
return true;
|
|
437
|
-
}
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
isRewardedVideoAdShowing() {
|
|
441
|
-
if (this.wxRewardedVideoAd.ad === null) {
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
if (this.wxRewardedVideoAd.status === RewardedVideoAdStatus.Status_Watching) {
|
|
445
|
-
return true;
|
|
446
|
-
}
|
|
447
|
-
return false;
|
|
448
|
-
}
|
|
449
|
-
_loadRewardedVideoAd(isShowImmediately) {
|
|
450
|
-
this.wxRewardedVideoAd.isShowImmediately = isShowImmediately;
|
|
451
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.load()");
|
|
452
|
-
this.wxRewardedVideoAd.ad.load()
|
|
453
|
-
.then(() => {
|
|
454
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.load() success");
|
|
455
|
-
}).catch((err) => {
|
|
456
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.load() error");
|
|
457
|
-
if (err) {
|
|
458
|
-
LogUtils.Instance.log("", err);
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
_showRewardedVideoAd() {
|
|
463
|
-
if (this.wxRewardedVideoAd.status !== RewardedVideoAdStatus.Status_Loaded) {
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_StartToWatch;
|
|
467
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.show()");
|
|
468
|
-
this.wxRewardedVideoAd.ad.show()
|
|
469
|
-
.then(() => {
|
|
470
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.show() success");
|
|
471
|
-
if (this.wxRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
472
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_Watching;
|
|
473
|
-
this.wxRewardedVideoAd.callback(RewardedVideoAd_Callback_Status.Status_Watching);
|
|
474
|
-
}
|
|
475
|
-
}).catch((err) => {
|
|
476
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxRewardedVideoAd.ad.show() error");
|
|
477
|
-
if (err) {
|
|
478
|
-
LogUtils.Instance.log("", err);
|
|
479
|
-
}
|
|
480
|
-
if (this.wxRewardedVideoAd.status === RewardedVideoAdStatus.Status_StartToWatch) {
|
|
481
|
-
this.wxRewardedVideoAd.status = RewardedVideoAdStatus.Status_Loaded;
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
createCustomAd(adUnitId) {
|
|
486
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createCustomAd()");
|
|
487
|
-
let isFirstLoad = true;
|
|
488
|
-
for (let i = 0; i < this.wxCustomAds.length; i++) {
|
|
489
|
-
if (this.wxCustomAds[i].unitId === adUnitId) {
|
|
490
|
-
isFirstLoad = this.wxCustomAds[i].isFirstLoad;
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
this.destroyCustomAd(adUnitId);
|
|
495
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createCustomAd() adUnitId=" + adUnitId);
|
|
496
|
-
let customAdInfo = AdDefinition.AdInfoConfig.CustomAd_Info;
|
|
497
|
-
if (customAdInfo === null || !customAdInfo.shouldShow) {
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
let customAdPlatformInfo = AdDefinition.CustomAdStyleConfig.get(PlatformID.ID_MiniGame_WeiXin);
|
|
501
|
-
if (customAdPlatformInfo === null) {
|
|
502
|
-
return false;
|
|
503
|
-
}
|
|
504
|
-
let customAdPostion = this.calcCustomAdPosition(customAdInfo, customAdPlatformInfo);
|
|
505
|
-
let customAdParam = {
|
|
506
|
-
adUnitId: adUnitId,
|
|
507
|
-
style: {
|
|
508
|
-
left: customAdPostion.left,
|
|
509
|
-
top: customAdPostion.top,
|
|
510
|
-
width: customAdPostion.realWidth,
|
|
511
|
-
fixed: true,
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
if (customAdPlatformInfo.canAutoRefresh) {
|
|
515
|
-
customAdParam.adIntervals = customAdPlatformInfo.refreshInterval;
|
|
516
|
-
}
|
|
517
|
-
let customAd = window["wx"].createCustomAd(customAdParam);
|
|
518
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wx.createCustomAd() " + (customAd !== null ? "success" : "fail"));
|
|
519
|
-
LogUtils.Instance.log("", customAd);
|
|
520
|
-
if (!customAd) {
|
|
521
|
-
return false;
|
|
522
|
-
}
|
|
523
|
-
let wxCustomAd = new WXCustomAd(adUnitId, customAd, isFirstLoad);
|
|
524
|
-
this.wxCustomAds.push(wxCustomAd);
|
|
525
|
-
wxCustomAd.errorListener = (err) => {
|
|
526
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onError()");
|
|
527
|
-
if (err) {
|
|
528
|
-
LogUtils.Instance.log("", err);
|
|
529
|
-
}
|
|
530
|
-
if (!wxCustomAd.isRecreating) {
|
|
531
|
-
wxCustomAd.isRecreating = true;
|
|
532
|
-
this.scheduleOnce(() => {
|
|
533
|
-
wxCustomAd.isRecreating = false;
|
|
534
|
-
this.createCustomAd(adUnitId);
|
|
535
|
-
}, 15);
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
wxCustomAd.ad.onError(wxCustomAd.errorListener);
|
|
539
|
-
wxCustomAd.loadListener = () => {
|
|
540
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onLoad()");
|
|
541
|
-
if (wxCustomAd.isFirstLoad) {
|
|
542
|
-
wxCustomAd.isFirstLoad = false;
|
|
543
|
-
}
|
|
544
|
-
if (this.adMgr.isPermanentAdShowing()) {
|
|
545
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.show()");
|
|
546
|
-
wxCustomAd.ad.show()
|
|
547
|
-
.then(() => {
|
|
548
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.show() success");
|
|
549
|
-
}).catch((err) => {
|
|
550
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.show() fail");
|
|
551
|
-
if (err) {
|
|
552
|
-
LogUtils.Instance.log("", err);
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
|
-
wxCustomAd.ad.onLoad(wxCustomAd.loadListener);
|
|
558
|
-
wxCustomAd.resizeListener = (res) => {
|
|
559
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onResize()");
|
|
560
|
-
if (res) {
|
|
561
|
-
LogUtils.Instance.log("", res);
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
wxCustomAd.ad.onResize(wxCustomAd.resizeListener);
|
|
565
|
-
wxCustomAd.closeListener = () => {
|
|
566
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onClose()");
|
|
567
|
-
};
|
|
568
|
-
wxCustomAd.ad.onClose(wxCustomAd.closeListener);
|
|
569
|
-
if (!customAdPlatformInfo.canAutoRefresh) {
|
|
570
|
-
if (!wxCustomAd.isRecreating) {
|
|
571
|
-
wxCustomAd.isRecreating = true;
|
|
572
|
-
this.scheduleOnce(() => {
|
|
573
|
-
wxCustomAd.isRecreating = false;
|
|
574
|
-
this.createCustomAd(adUnitId);
|
|
575
|
-
}, customAdPlatformInfo.refreshInterval);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
return true;
|
|
579
|
-
}
|
|
580
|
-
destroyCustomAd(adUnitId) {
|
|
581
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "destroyCustomAd(): adUnitId=" + adUnitId);
|
|
582
|
-
let index = -1;
|
|
583
|
-
for (let i = 0; i < this.wxCustomAds.length; i++) {
|
|
584
|
-
if (this.wxCustomAds[i].unitId === adUnitId) {
|
|
585
|
-
index = i;
|
|
586
|
-
break;
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
if (index >= 0) {
|
|
590
|
-
this.wxCustomAds[index].destroy();
|
|
591
|
-
this.wxCustomAds.splice(index, 1);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
showCustomAd(adUnitId) {
|
|
595
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "showCustomAd(): adUnitId=" + adUnitId);
|
|
596
|
-
for (let i = 0; i < this.wxCustomAds.length; i++) {
|
|
597
|
-
if (this.wxCustomAds[i].unitId === adUnitId) {
|
|
598
|
-
let customAd = this.wxCustomAds[i];
|
|
599
|
-
if (!customAd.ad.isShow()) {
|
|
600
|
-
customAd.ad.show();
|
|
601
|
-
}
|
|
602
|
-
break;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
hideCustomAd(adUnitId) {
|
|
607
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "hideCustomAd(): adUnitId=" + adUnitId);
|
|
608
|
-
for (let i = 0; i < this.wxCustomAds.length; i++) {
|
|
609
|
-
if (this.wxCustomAds[i].unitId === adUnitId) {
|
|
610
|
-
let customAd = this.wxCustomAds[i];
|
|
611
|
-
if (customAd.ad.isShow()) {
|
|
612
|
-
customAd.ad.hide();
|
|
613
|
-
}
|
|
614
|
-
break;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
createPortalAd(adUnitId) {
|
|
619
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createPortalAd()");
|
|
620
|
-
let isFirstLoad = true;
|
|
621
|
-
for (let i = 0; i < this.wxCustomAds.length; i++) {
|
|
622
|
-
if (this.wxCustomAds[i].unitId === adUnitId) {
|
|
623
|
-
isFirstLoad = this.wxCustomAds[i].isFirstLoad;
|
|
624
|
-
break;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
this.destroyPortalAd(adUnitId);
|
|
628
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "createPortalAd() adUnitId=" + adUnitId);
|
|
629
|
-
let portalAdPlatformInfo = AdDefinition.PortalAdStyleConfig.get(PlatformID.ID_MiniGame_WeiXin);
|
|
630
|
-
if (portalAdPlatformInfo === null) {
|
|
631
|
-
return false;
|
|
632
|
-
}
|
|
633
|
-
let portalAdPostion = this.calcPortalAdPosition(portalAdPlatformInfo);
|
|
634
|
-
let customAdParam = {
|
|
635
|
-
adUnitId: adUnitId,
|
|
636
|
-
style: {
|
|
637
|
-
left: portalAdPostion.left,
|
|
638
|
-
top: portalAdPostion.top,
|
|
639
|
-
width: portalAdPostion.realWidth,
|
|
640
|
-
fixed: true,
|
|
641
|
-
},
|
|
642
|
-
adIntervals: 30,
|
|
643
|
-
};
|
|
644
|
-
let customAd = window["wx"].createCustomAd(customAdParam);
|
|
645
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wx.createCustomAd() " + (customAd !== null ? "success" : "fail"));
|
|
646
|
-
LogUtils.Instance.log("", customAd);
|
|
647
|
-
if (!customAd) {
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
let wxCustomAd = new WXCustomAd(adUnitId, customAd, isFirstLoad);
|
|
651
|
-
this.wxCustomAds.push(wxCustomAd);
|
|
652
|
-
wxCustomAd.errorListener = (err) => {
|
|
653
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onError()");
|
|
654
|
-
if (err) {
|
|
655
|
-
LogUtils.Instance.log("", err);
|
|
656
|
-
}
|
|
657
|
-
if (!wxCustomAd.isRecreating) {
|
|
658
|
-
wxCustomAd.isRecreating = true;
|
|
659
|
-
this.scheduleOnce(() => {
|
|
660
|
-
wxCustomAd.isRecreating = false;
|
|
661
|
-
this.createPortalAd(adUnitId);
|
|
662
|
-
}, 15);
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
wxCustomAd.ad.onError(wxCustomAd.errorListener);
|
|
666
|
-
wxCustomAd.loadListener = () => {
|
|
667
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onLoad()");
|
|
668
|
-
if (wxCustomAd.isFirstLoad) {
|
|
669
|
-
wxCustomAd.isFirstLoad = false;
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
wxCustomAd.ad.onLoad(wxCustomAd.loadListener);
|
|
673
|
-
wxCustomAd.resizeListener = (res) => {
|
|
674
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onResize()");
|
|
675
|
-
if (res) {
|
|
676
|
-
LogUtils.Instance.log("", res);
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
wxCustomAd.ad.onResize(wxCustomAd.resizeListener);
|
|
680
|
-
wxCustomAd.closeListener = () => {
|
|
681
|
-
LogUtils.Instance.log(AdAdapterWeiXin.TAG, "wxCustomAd.ad.onClose()");
|
|
682
|
-
};
|
|
683
|
-
wxCustomAd.ad.onClose(wxCustomAd.closeListener);
|
|
684
|
-
}
|
|
685
|
-
destroyPortalAd(adUnitId) {
|
|
686
|
-
this.destroyCustomAd(adUnitId);
|
|
687
|
-
}
|
|
688
|
-
showPortalAd(adUnitId) {
|
|
689
|
-
this.showCustomAd(adUnitId);
|
|
690
|
-
}
|
|
691
|
-
hidePortalAd(adUnitId) {
|
|
692
|
-
this.hideCustomAd(adUnitId);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
AdAdapterWeiXin.TAG = "AdAdapterWeiXin";
|