提交 4e83fc2c 编写于 作者: d-u-a's avatar d-u-a 提交者: qiang

update: h5-ad

上级 abdf9849
...@@ -254,7 +254,7 @@ class AdScript { ...@@ -254,7 +254,7 @@ class AdScript {
load (provider, script, success, fail) { load (provider, script, success, fail) {
if (this._cache[provider] === undefined) { if (this._cache[provider] === undefined) {
this.loadScript(script) this.loadScript(provider, script)
} }
if (this._cache[provider] === 1) { if (this._cache[provider] === 1) {
...@@ -400,6 +400,9 @@ export default { ...@@ -400,6 +400,9 @@ export default {
beforeDestroy () { beforeDestroy () {
this._clearCheckTimer() this._clearCheckTimer()
this.$refs.container.innerHTML = '' this.$refs.container.innerHTML = ''
if (this._shanhuAd) {
delete this._shanhuAd
}
}, },
methods: { methods: {
_onhandle (e) { _onhandle (e) {
...@@ -432,47 +435,75 @@ export default { ...@@ -432,47 +435,75 @@ export default {
const data = this._pl[this._pi] const data = this._pl[this._pi]
const providerConfig = this._b[data.a1][data.t] const providerConfig = this._b[data.a1][data.t]
const script = providerConfig.script
var randomId = this._randomId() var id = this._randomId()
var view = this._createView(id)
if (data.a1 === '10011') { if (data.a1 === '10011') {
AdTencent.instance.load(data.a3, data.a2, (res) => { AdTencent.instance.load(data.a3, data.a2, (res) => {
window.TencentGDT.NATIVE.renderAd(res, randomId) window.TencentGDT.NATIVE.renderAd(res, id)
}) })
this._startCheckTimer() this._startCheckTimer()
} else if (data.a1 === '10012') { } else if (data.a1 === '10012') {
this._renderAdView(providerConfig, data, randomId) this._renderScript(view, script)
} else if (data.a1 === '10014') {
AdScript.instance.load(data.t, script, () => {
this._renderShanhu(id, data.tt, data.tar)
}, (err) => {
this.$trigger('error', {}, err)
})
} else { } else {
AdScript.instance.load(data.t, providerConfig.script, () => { AdScript.instance.load(data.t, script, () => {
this._renderAdView(providerConfig, data, randomId) this._renderAdView(id, view, script, data)
}, (err) => { }, (err) => {
this.$trigger('error', {}, err) this.$trigger('error', {}, err)
}) })
} }
}, },
_renderAdView (providerConfig, data, randomId) { _createView (id) {
var adView = document.createElement('div') var adView = document.createElement('div')
adView.setAttribute('class', randomId) adView.setAttribute('id', id)
adView.setAttribute('id', randomId) adView.setAttribute('class', id)
this.$refs.container.innerHTML = '' this.$refs.container.innerHTML = ''
this.$refs.container.append(adView) this.$refs.container.append(adView)
return adView
if (data.a1 === '10011') { },
} else if (data.a1 === '10012') { _renderScript (view, script) {
var adScript = document.createElement('script') var adScript = document.createElement('script')
const script = providerConfig.script for (const var1 in script) {
for (const var1 in script) { adScript.setAttribute(var1, script[var1])
adScript.setAttribute(var1, script[var1])
}
adView.appendChild(adScript)
} else {
let bindThis = window
providerConfig.s.split('.').reduce((total, currentValue) => {
bindThis = total
return total[currentValue]
}, window).bind(bindThis)(data.a2, randomId, 2)
} }
view.appendChild(adScript)
this._startCheckTimer()
},
_renderAdView (id, view, script, data) {
let bindThis = window
script.s.split('.').reduce((total, currentValue) => {
bindThis = total
return total[currentValue]
}, window).bind(bindThis)(data.a2, id, 2)
this._startCheckTimer()
},
_renderShanhu (id, type, target) {
this._shanhuAd = new window.CoralTBSAdv(id, {
type: type,
target: target,
advShowCb: () => {
this._report(42)
this.$trigger('load', {}, {})
},
advClickCb: () => {
this._report(43)
this.$trigger('adclicked', {}, {})
},
advCloseCb: () => {
this.$trigger('close', {}, {})
},
advErrorCb: (errorno) => {
this.$trigger('error', {}, errorno)
}
})
this._startCheckTimer() this._startCheckTimer()
}, },
_renderNext () { _renderNext () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册