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

update: 调整互动广告事件触发时机

上级 f4bcef5c
......@@ -37,7 +37,6 @@ class AdBase {
ad.onLoad((e) => {
this._isLoaded = true
this._isLoading = false
this._dispatchEvent(eventTypes.load, {})
if (this._loadPromiseResolve != null) {
this._loadPromiseResolve()
......@@ -48,6 +47,8 @@ class AdBase {
this._showPromiseResolve = null
this._showAd()
}
this._dispatchEvent(eventTypes.load, {})
})
ad.onClose((e) => {
this._isLoaded = false
......@@ -70,17 +71,17 @@ class AdBase {
this._dispatchEvent(eventTypes.error, data)
const promiseError = new Error(JSON.stringify(this._adError))
promiseError.code = e.code
promiseError.errMsg = e.message
const error = new Error(JSON.stringify(this._adError))
error.code = e.code
error.errMsg = e.message
if (this._loadPromiseReject != null) {
this._loadPromiseReject(promiseError)
this._loadPromiseReject(error)
this._loadPromiseReject = null
}
if (this._showPromiseReject != null) {
this._showPromiseReject(promiseError)
this._showPromiseReject(error)
this._showPromiseReject = null
}
})
......
......@@ -169,7 +169,6 @@ class InteractiveAd {
}, (res) => {
this._isLoaded = true
this._isLoading = false
this._dispatchEvent(eventTypes.load, res)
if (this._loadPromiseResolve != null) {
this._loadPromiseResolve()
......@@ -180,14 +179,17 @@ class InteractiveAd {
this._showPromiseResolve = null
this._showAd()
}
this._dispatchEvent(eventTypes.load, res)
}, (err) => {
this._isLoading = false
this._dispatchEvent(eventTypes.error, err)
if (this._showPromiseReject != null) {
this._showPromiseReject(this._createError(err))
this._showPromiseReject = null
}
this._dispatchEvent(eventTypes.error, err)
})
}
}
......@@ -200,12 +202,13 @@ class InteractiveAd {
this._isLoaded = false
}, (err) => {
this._isLoaded = false
this._dispatchEvent(eventTypes.error, err)
if (this._showPromiseReject != null) {
this._showPromiseReject(this._createError(err))
this._showPromiseReject = null
}
this._dispatchEvent(eventTypes.error, err)
})
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册