octopus-ad
Version:
Quickapp Sample Template
66 lines (65 loc) • 1.93 kB
JavaScript
const dispatchAdEvent = function (t, e) {
try {
this.isAdDestroyed ||
(this.adEvent && this.adEvent[t]
? this.adEvent[t].call(this, e)
: 'shake' === t &&
this.parent &&
this.parent.adEvent &&
this.parent.adEvent.onClick &&
this.parent.adEvent.onClick.call(this.parent, e))
} catch (t) {}
},
defineAdComponent = function (n) {
try {
this.adTimer && clearInterval(this.adTimer)
let t = setInterval(() => {
if (this.isAdDestroyed || !this.$app) clearInterval(t)
else if (
this.$app &&
this.$app.$def &&
this.$app.$def.union_quick_app_sdk &&
this.$app.$def.union_quick_app_sdk.components
) {
clearInterval(t)
let e = this.$app.$def.union_quick_app_sdk.components[n]
e &&
(Object.keys(e).forEach((t) => {
this[t] = e[t]
}),
dispatchAdEvent.call(this, 'onInit'))
}
}, 10)
this.adTimer = t
} catch (t) {}
},
validateAdstyle = function (t) {
var e,
n = [
'containerStyle',
'titleStyle',
'imgStyle',
'buttonStyle',
'iconStyle',
'descStyle',
'brandStyle',
'closeBtnStyle',
'downloadStyle',
'downloadBrandStyle',
'downloadIconStyle',
'downloadButtonStyle',
'downloadTextStyle',
'openAdBtnStyle',
]
let i = !1
for (e in (t = JSON.parse(JSON.stringify(t))))
n &&
!~n.indexOf(e) &&
(console.log(
`百度网盟广告组件adStyle属性:${e}校验不通过,仅支持以下自定义样式属性:` +
[...n]
),
(i = !0))
return !i
}
export { dispatchAdEvent, defineAdComponent, validateAdstyle }