diff --git a/packages/uni-cli-shared/components/ad-fullscreen-video.vue b/packages/uni-cli-shared/components/ad-fullscreen-video.vue index 4c81942f4e82f6c1b5f931718bc9e6ca1dcc4218..e809894a00eb6bdb439611c1de84e67b94d0aed8 100644 --- a/packages/uni-cli-shared/components/ad-fullscreen-video.vue +++ b/packages/uni-cli-shared/components/ad-fullscreen-video.vue @@ -2,7 +2,7 @@ - + diff --git a/packages/uni-cli-shared/components/ad-interstitial.vue b/packages/uni-cli-shared/components/ad-interstitial.vue index c561793b5608d60761d9880850c0a1985d9b84fe..af258270ae37b20de5210e71fe8d0e7f3a2a9ab3 100644 --- a/packages/uni-cli-shared/components/ad-interstitial.vue +++ b/packages/uni-cli-shared/components/ad-interstitial.vue @@ -2,7 +2,7 @@ - + diff --git a/packages/uni-cli-shared/components/ad-rewarded-video.vue b/packages/uni-cli-shared/components/ad-rewarded-video.vue index 3d81f81fca681eb96be40d75bc351e0157d0e9a7..64644467bbc5afe38b6b05d74dd7db9ddc68980f 100644 --- a/packages/uni-cli-shared/components/ad-rewarded-video.vue +++ b/packages/uni-cli-shared/components/ad-rewarded-video.vue @@ -2,7 +2,7 @@ - + diff --git a/packages/uni-cli-shared/components/ad.mixin.js b/packages/uni-cli-shared/components/ad.mixin.js index d541ed7d6651ba3cf6ab8aaf3f727f4e2ec4ecd0..62121c38a85852094669975748ea2acd984a239b 100644 --- a/packages/uni-cli-shared/components/ad.mixin.js +++ b/packages/uni-cli-shared/components/ad.mixin.js @@ -19,14 +19,13 @@ const ProviderType = { const RETRY_COUNT = 1 class AdBase { - constructor (adInstance, options = {}, interstitial) { + constructor (adInstance, options = {}) { this._isLoad = false this._isLoading = false this._isPlaying = false this._lastLoadTime = 0 this._lastError = null this._retryCount = 0 - this._isInterstitial = interstitial || false if (options.retry !== undefined) { this._retry = options.retry } else { @@ -140,18 +139,9 @@ class AdBase { return } - // TODO - if (this._isInterstitial && provider === ProviderType.GDT) { - setTimeout(() => { - this._isPlaying = true - this._ad.show() - onshow && onshow() - }, 1000) - } else { - this._isPlaying = true - this._ad.show() - onshow && onshow() - } + this._isPlaying = true + this._ad.show() + onshow && onshow() } onLoad (e) { @@ -199,8 +189,8 @@ class FullScreenVideo extends AdBase { } class Interstitial extends AdBase { - constructor (options = {}, interstitial) { - super(plus.ad.createInterstitialAd(options), options, interstitial) + constructor (options = {}) { + super(plus.ad.createInterstitialAd(options), options) } } @@ -208,6 +198,7 @@ class AdHelper { constructor (adType) { this._ads = {} this._adType = adType + this._lastWaterfallIndex = -1 } load (options, onload, onerror) { @@ -251,6 +242,10 @@ class AdHelper { return } + if (index === 0) { + this._lastWaterfallIndex = -1 + } + const options2 = { adpid: adpid[index], urlCallback, @@ -258,6 +253,7 @@ class AdHelper { } this.load(options2, (res) => { + this._lastWaterfallIndex = index onload(options2) }, (err) => { index++ @@ -280,8 +276,13 @@ class AdHelper { return } + let idx = index + if (this._lastWaterfallIndex > -1) { + idx = this._lastWaterfallIndex + } + const options2 = { - adpid: adpid[index], + adpid: adpid[idx], urlCallback, retry: false } @@ -352,6 +353,13 @@ class AdHelper { return this._ads[adpid] } + getProvider (adpid) { + if (this._ads[adpid]) { + return this._ads[adpid].getProvider() + } + return null + } + remove (adpid) { if (this._ads[adpid]) { this._ads[adpid].destroy() @@ -464,6 +472,13 @@ export default { }) }, + getProvider () { + if (Array.isArray(this.adpid)) { + return null + } + return this._adHelper.getProvider(this.adpid) + }, + _loadAd () { if (this._canCreateAd()) { this.load() diff --git a/packages/uni-cli-shared/components/ad.mixin.mp.js b/packages/uni-cli-shared/components/ad.mixin.mp.js index 8087940521f75465be3d0ee6fafcab617f4583d0..ea507591de985a27d15ad98b85b41112158b52c6 100644 --- a/packages/uni-cli-shared/components/ad.mixin.mp.js +++ b/packages/uni-cli-shared/components/ad.mixin.mp.js @@ -57,7 +57,7 @@ export default { show () { this.errorMessage = null - this._ad = this.selectComponent('.uni-ad') + this._ad = this.selectComponent('.uniad-plugin') this._ad.show() }, @@ -70,6 +70,16 @@ export default { this.errorMessage = null }, + _canCreateAd () { + let result = false + if (typeof this.adpid === 'string' && this.adpid.length > 0) { + result = true + } else if (typeof this.adpid === 'number') { + result = true + } + return result + }, + _onmpload (e) { this.loading = false this._dispatchEvent(EventType.Load, {}) diff --git a/packages/uni-cli-shared/components/uniad.vue b/packages/uni-cli-shared/components/uniad.vue index 4d9f02feb2d3ed7dd3e2fd0cc20a4dddcc15bfaa..7387d62012bc7c13597bd29a077a11872f2a3fae 100644 --- a/packages/uni-cli-shared/components/uniad.vue +++ b/packages/uni-cli-shared/components/uniad.vue @@ -1,7 +1,7 @@