From f18617372987fe7c4b0d87ed07f8a86cd47bcef5 Mon Sep 17 00:00:00 2001 From: handongxun Date: Thu, 10 Feb 2022 10:42:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(h5-ad):=20=E5=BC=80=E5=90=AF=E6=91=87?= =?UTF-8?q?=E6=A0=91=E5=90=8E=E6=97=A0=E6=B3=95=E6=89=BE=E5=88=B0ad?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=AF=BC=E8=87=B4=E5=8F=91=E8=A1=8C=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webpack-optimize-plugin/component.js | 2 +- src/platforms/h5/view/components/ad/index.vue | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) 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 ecf714245..c90410c82 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 ae5253eeb..1c474fcc0 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) -- GitLab