@dcloudio/uni-cli-shared 2.0.1-alpha-34820220426002 → 2.0.1-alpha-34820220427003
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/components/ad-fullscreen-video.vue +1 -1
- package/components/ad-interstitial.vue +1 -1
- package/components/ad-rewarded-video.vue +1 -1
- package/components/ad.mixin.js +32 -17
- package/components/ad.mixin.mp.js +19 -2
- package/components/uniad.vue +3 -3
- package/lib/pages.js +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view @click="_onclick">
|
|
3
3
|
<slot :options="options" :loading="loading" :error="errorMessage" />
|
|
4
4
|
<!-- #ifdef MP-WEIXIN -->
|
|
5
|
-
<
|
|
5
|
+
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
6
6
|
<!-- #endif -->
|
|
7
7
|
</view>
|
|
8
8
|
</template>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view @click="_onclick">
|
|
3
3
|
<slot :options="options" :loading="loading" :error="errorMessage" />
|
|
4
4
|
<!-- #ifdef MP-WEIXIN -->
|
|
5
|
-
<
|
|
5
|
+
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
6
6
|
<!-- #endif -->
|
|
7
7
|
</view>
|
|
8
8
|
</template>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view @click="_onclick">
|
|
3
3
|
<slot :options="options" :loading="loading" :error="errorMessage" />
|
|
4
4
|
<!-- #ifdef MP-WEIXIN -->
|
|
5
|
-
<
|
|
5
|
+
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
6
6
|
<!-- #endif -->
|
|
7
7
|
</view>
|
|
8
8
|
</template>
|
package/components/ad.mixin.js
CHANGED
|
@@ -19,14 +19,13 @@ const ProviderType = {
|
|
|
19
19
|
const RETRY_COUNT = 1
|
|
20
20
|
|
|
21
21
|
class AdBase {
|
|
22
|
-
constructor (adInstance, options = {}
|
|
22
|
+
constructor (adInstance, options = {}) {
|
|
23
23
|
this._isLoad = false
|
|
24
24
|
this._isLoading = false
|
|
25
25
|
this._isPlaying = false
|
|
26
26
|
this._lastLoadTime = 0
|
|
27
27
|
this._lastError = null
|
|
28
28
|
this._retryCount = 0
|
|
29
|
-
this._isInterstitial = interstitial || false
|
|
30
29
|
if (options.retry !== undefined) {
|
|
31
30
|
this._retry = options.retry
|
|
32
31
|
} else {
|
|
@@ -140,18 +139,9 @@ class AdBase {
|
|
|
140
139
|
return
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
this._isPlaying = true
|
|
147
|
-
this._ad.show()
|
|
148
|
-
onshow && onshow()
|
|
149
|
-
}, 1000)
|
|
150
|
-
} else {
|
|
151
|
-
this._isPlaying = true
|
|
152
|
-
this._ad.show()
|
|
153
|
-
onshow && onshow()
|
|
154
|
-
}
|
|
142
|
+
this._isPlaying = true
|
|
143
|
+
this._ad.show()
|
|
144
|
+
onshow && onshow()
|
|
155
145
|
}
|
|
156
146
|
|
|
157
147
|
onLoad (e) {
|
|
@@ -199,8 +189,8 @@ class FullScreenVideo extends AdBase {
|
|
|
199
189
|
}
|
|
200
190
|
|
|
201
191
|
class Interstitial extends AdBase {
|
|
202
|
-
constructor (options = {}
|
|
203
|
-
super(plus.ad.createInterstitialAd(options), options
|
|
192
|
+
constructor (options = {}) {
|
|
193
|
+
super(plus.ad.createInterstitialAd(options), options)
|
|
204
194
|
}
|
|
205
195
|
}
|
|
206
196
|
|
|
@@ -208,6 +198,7 @@ class AdHelper {
|
|
|
208
198
|
constructor (adType) {
|
|
209
199
|
this._ads = {}
|
|
210
200
|
this._adType = adType
|
|
201
|
+
this._lastWaterfallIndex = -1
|
|
211
202
|
}
|
|
212
203
|
|
|
213
204
|
load (options, onload, onerror) {
|
|
@@ -251,6 +242,10 @@ class AdHelper {
|
|
|
251
242
|
return
|
|
252
243
|
}
|
|
253
244
|
|
|
245
|
+
if (index === 0) {
|
|
246
|
+
this._lastWaterfallIndex = -1
|
|
247
|
+
}
|
|
248
|
+
|
|
254
249
|
const options2 = {
|
|
255
250
|
adpid: adpid[index],
|
|
256
251
|
urlCallback,
|
|
@@ -258,6 +253,7 @@ class AdHelper {
|
|
|
258
253
|
}
|
|
259
254
|
|
|
260
255
|
this.load(options2, (res) => {
|
|
256
|
+
this._lastWaterfallIndex = index
|
|
261
257
|
onload(options2)
|
|
262
258
|
}, (err) => {
|
|
263
259
|
index++
|
|
@@ -280,8 +276,13 @@ class AdHelper {
|
|
|
280
276
|
return
|
|
281
277
|
}
|
|
282
278
|
|
|
279
|
+
let idx = index
|
|
280
|
+
if (this._lastWaterfallIndex > -1) {
|
|
281
|
+
idx = this._lastWaterfallIndex
|
|
282
|
+
}
|
|
283
|
+
|
|
283
284
|
const options2 = {
|
|
284
|
-
adpid: adpid[
|
|
285
|
+
adpid: adpid[idx],
|
|
285
286
|
urlCallback,
|
|
286
287
|
retry: false
|
|
287
288
|
}
|
|
@@ -352,6 +353,13 @@ class AdHelper {
|
|
|
352
353
|
return this._ads[adpid]
|
|
353
354
|
}
|
|
354
355
|
|
|
356
|
+
getProvider (adpid) {
|
|
357
|
+
if (this._ads[adpid]) {
|
|
358
|
+
return this._ads[adpid].getProvider()
|
|
359
|
+
}
|
|
360
|
+
return null
|
|
361
|
+
}
|
|
362
|
+
|
|
355
363
|
remove (adpid) {
|
|
356
364
|
if (this._ads[adpid]) {
|
|
357
365
|
this._ads[adpid].destroy()
|
|
@@ -464,6 +472,13 @@ export default {
|
|
|
464
472
|
})
|
|
465
473
|
},
|
|
466
474
|
|
|
475
|
+
getProvider () {
|
|
476
|
+
if (Array.isArray(this.adpid)) {
|
|
477
|
+
return null
|
|
478
|
+
}
|
|
479
|
+
return this._adHelper.getProvider(this.adpid)
|
|
480
|
+
},
|
|
481
|
+
|
|
467
482
|
_loadAd () {
|
|
468
483
|
if (this._canCreateAd()) {
|
|
469
484
|
this.load()
|
|
@@ -45,12 +45,19 @@ export default {
|
|
|
45
45
|
},
|
|
46
46
|
methods: {
|
|
47
47
|
load () {
|
|
48
|
-
this.
|
|
48
|
+
if (this.loading) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
this._startLoading()
|
|
52
|
+
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
this.loading = false
|
|
55
|
+
}, 3000)
|
|
49
56
|
},
|
|
50
57
|
|
|
51
58
|
show () {
|
|
52
59
|
this.errorMessage = null
|
|
53
|
-
this._ad = this.selectComponent('.
|
|
60
|
+
this._ad = this.selectComponent('.uniad-plugin')
|
|
54
61
|
this._ad.show()
|
|
55
62
|
},
|
|
56
63
|
|
|
@@ -63,6 +70,16 @@ export default {
|
|
|
63
70
|
this.errorMessage = null
|
|
64
71
|
},
|
|
65
72
|
|
|
73
|
+
_canCreateAd () {
|
|
74
|
+
let result = false
|
|
75
|
+
if (typeof this.adpid === 'string' && this.adpid.length > 0) {
|
|
76
|
+
result = true
|
|
77
|
+
} else if (typeof this.adpid === 'number') {
|
|
78
|
+
result = true
|
|
79
|
+
}
|
|
80
|
+
return result
|
|
81
|
+
},
|
|
82
|
+
|
|
66
83
|
_onmpload (e) {
|
|
67
84
|
this.loading = false
|
|
68
85
|
this._dispatchEvent(EventType.Load, {})
|
package/components/uniad.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view @click="onclick">
|
|
3
|
-
<
|
|
4
|
-
class="
|
|
3
|
+
<uniad-plugin
|
|
4
|
+
class="uniad-plugin"
|
|
5
5
|
:adpid="adpid"
|
|
6
6
|
:unit-id="unitId"
|
|
7
7
|
@load="_onmpload"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<script>
|
|
15
15
|
import adMixin from './ad.mixin.mp.js'
|
|
16
16
|
export default {
|
|
17
|
-
name: '
|
|
17
|
+
name: 'Uniad',
|
|
18
18
|
mixins: [adMixin],
|
|
19
19
|
props: {
|
|
20
20
|
},
|
package/lib/pages.js
CHANGED
|
@@ -519,7 +519,7 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
|
|
|
519
519
|
|
|
520
520
|
const BUILT_IN_COMPONENTS = ['page-meta', 'navigation-bar', 'uni-match-media']
|
|
521
521
|
|
|
522
|
-
const BUILT_IN_EASYCOMS = ['unicloud-db', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial', 'ad-interactive']
|
|
522
|
+
const BUILT_IN_EASYCOMS = ['unicloud-db', 'uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial', 'ad-interactive']
|
|
523
523
|
|
|
524
524
|
function isBuiltInComponent (name) { // uni-template-compiler/lib/util.js 识别微信内置组件
|
|
525
525
|
return BUILT_IN_COMPONENTS.includes(name)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "2.0.1-alpha-
|
|
3
|
+
"version": "2.0.1-alpha-34820220427003",
|
|
4
4
|
"description": "uni-cli-shared",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"postcss-urlrewrite": "^0.2.2",
|
|
24
24
|
"strip-json-comments": "^2.0.1"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "b807a1fde329785b59ebc8360f0afffe7b7ecd5e"
|
|
27
27
|
}
|