diff --git a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js index ecf714245ec454e4db5cf41f63934213a8271d8b..c90410c82ceb7ee0514c196ee338e1d47b5af0d8 100644 --- a/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js +++ b/packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js @@ -6,7 +6,7 @@ const { capitalize } = require('./util') -const platformTags = ['map', 'video', 'web-view', 'cover-view', 'cover-image', 'picker'] +const platformTags = ['map', 'video', 'web-view', 'cover-view', 'cover-image', 'picker', 'ad'] const autoloadTags = { // input 在 pageHead 中有使用,resize-sensor 在很多组件中有使用,暂时直接加载 diff --git a/src/platforms/h5/view/components/ad/index.vue b/src/platforms/h5/view/components/ad/index.vue index ae5253eebc71bc95bb258665d551759af89fc134..1c474fcc08409cad6fb6f28a233e421efe4e36b2 100644 --- a/src/platforms/h5/view/components/ad/index.vue +++ b/src/platforms/h5/view/components/ad/index.vue @@ -441,7 +441,13 @@ export default { var id = this._randomId() var view = this._createView(id) - if (data.a1 === '10011') { + if (data.a1 === '10010') { + AdScript.instance.load(data.t, script, () => { + this._renderBaidu(id, data.a2) + }, (err) => { + this.$trigger('error', {}, err) + }) + } else if (data.a1 === '10011') { AdTencent.instance.load(data.a3, data.a2, (res) => { window.TencentGDT.NATIVE.renderAd(res, id) }) @@ -456,7 +462,7 @@ export default { }) } else { AdScript.instance.load(data.t, script, () => { - this._renderAdView(id, view, script, data) + this._renderAdView(id, script.s, data) }, (err) => { this.$trigger('error', {}, err) }) @@ -478,9 +484,17 @@ export default { view.appendChild(adScript) this._startCheckTimer() }, - _renderAdView (id, view, script, data) { + _renderBaidu (id, adid) { + (window.slotbydup = window.slotbydup || []).push({ + id: adid, + container: id, + async: true + }) + this._startCheckTimer() + }, + _renderAdView (id, script, data) { let bindThis = window - script.s.split('.').reduce((total, currentValue) => { + script.split('.').reduce((total, currentValue) => { bindThis = total return total[currentValue] }, window).bind(bindThis)(data.a2, id, 2)