提交 7c101633 编写于 作者: d-u-a's avatar d-u-a

update: h5-ad

上级 8f917136
......@@ -254,7 +254,7 @@ class AdScript {
load (provider, script, success, fail) {
if (this._cache[provider] === undefined) {
this.loadScript(script)
this.loadScript(provider, script)
}
if (this._cache[provider] === 1) {
......@@ -400,6 +400,9 @@ export default {
beforeDestroy () {
this._clearCheckTimer()
this.$refs.container.innerHTML = ''
if (this._shanhuAd) {
delete this._shanhuAd
}
},
methods: {
_onhandle (e) {
......@@ -432,47 +435,75 @@ export default {
const data = this._pl[this._pi]
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') {
AdTencent.instance.load(data.a3, data.a2, (res) => {
window.TencentGDT.NATIVE.renderAd(res, randomId)
window.TencentGDT.NATIVE.renderAd(res, id)
})
this._startCheckTimer()
} 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 {
AdScript.instance.load(data.t, providerConfig.script, () => {
this._renderAdView(providerConfig, data, randomId)
AdScript.instance.load(data.t, script, () => {
this._renderAdView(id, view, script, data)
}, (err) => {
this.$trigger('error', {}, err)
})
}
},
_renderAdView (providerConfig, data, randomId) {
_createView (id) {
var adView = document.createElement('div')
adView.setAttribute('class', randomId)
adView.setAttribute('id', randomId)
adView.setAttribute('id', id)
adView.setAttribute('class', id)
this.$refs.container.innerHTML = ''
this.$refs.container.append(adView)
if (data.a1 === '10011') {
} else if (data.a1 === '10012') {
var adScript = document.createElement('script')
const script = providerConfig.script
for (const var1 in script) {
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)
return adView
},
_renderScript (view, script) {
var adScript = document.createElement('script')
for (const var1 in script) {
adScript.setAttribute(var1, script[var1])
}
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()
},
_renderNext () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册