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

ad: 全屏视频,移除创建实例后自动加载和完成后预载逻辑,避免数据过期和请求后不展示问题

上级 faf70b95
......@@ -4,11 +4,6 @@ const eventNames = [
'error'
]
const ERROR_CODE_LIST = [-5001, -5002, -5003, -5004, -5005, -5006]
const EXPIRED_TIME = 1000 * 60 * 30
const EXPIRED_TEXT = { code: -5008, errMsg: '广告数据已过期,请重新加载' }
const ProviderType = { CSJ: 'csj', GDT: 'gdt' }
class FullScreenVideoAd {
constructor (options = {}) {
const _callbacks = this._callbacks = {}
......@@ -38,6 +33,7 @@ class FullScreenVideoAd {
}
})
ad.onClose((e) => {
this._isLoad = false
this._dispatchEvent('close', { isEnded: e.isEnded })
})
ad.onError((e) => {
......@@ -48,18 +44,12 @@ class FullScreenVideoAd {
this._isLoad = false
}
this._dispatchEvent('error', data)
// TODO
if ((code === -5005 || ERROR_CODE_LIST.index(code) === -1) && this._loadPromiseReject != null) {
if (this._loadPromiseReject != null) {
this._loadPromiseReject(data)
this._loadPromiseReject = null
}
})
this._loadAd()
}
get isExpired () {
return (this._lastLoadTime !== 0 && (Math.abs(Date.now() - this._lastLoadTime) > EXPIRED_TIME))
}
load () {
......@@ -76,15 +66,6 @@ class FullScreenVideoAd {
show () {
return new Promise((resolve, reject) => {
const provider = this.getProvider()
if (provider === ProviderType.CSJ && this.isExpired) {
this._isLoad = false
// TODO
this._dispatchEvent('error', EXPIRED_TEXT)
reject(new Error(EXPIRED_TEXT.errMsg))
return
}
if (this._isLoad) {
this._ad.show()
resolve()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册