Commit 34c03ee8 authored by liupengfei's avatar liupengfei

去测试

parent 31cb528f
......@@ -33,6 +33,7 @@ class MyAdvideo {
strategy: any;
stragegyFn: any;
appContent: appContent;
isPlayEnd: boolean;
constructor(config) {
this.el = config.el;
this._times = {
......@@ -44,6 +45,7 @@ class MyAdvideo {
this.player = new AdVideo(config);
this.reset();
this.initListener();
this.isPlayEnd = false;
}
// 重置一些状态
......@@ -68,6 +70,7 @@ class MyAdvideo {
this.playPromise = new Promise((resolve) => {
this.playResolve = resolve;
});
this.isPlayEnd = false;
// 平台策略相关
this.strategy = null;
this.stragegyFn = {
......@@ -77,6 +80,16 @@ class MyAdvideo {
// 请求完成
initListener() {
document.addEventListener('visibilitychange', () => {
// 用户离开了当前页面
if (document.visibilityState === 'hidden') {
this.player.$video.pause();
}
// 用户打开或回到页面
if (document.visibilityState === 'visible' && !this.isPlayEnd) {
this.player.$video.play();
}
});
this.player.on('play', () => {
this._times._readyTime = +new Date();
this._times.duration = this.player.$video.duration
......@@ -87,9 +100,14 @@ class MyAdvideo {
}
});
this.player.on('$footerPageClick', (e) => {
console.log(e)
this.stragegyFn[this.strategy].report.videoClick(this.videoRaw, this._times, e);
this.stragegyFn[this.strategy].report.appDownload(this.videoRaw, this._times, e);
// 回调参数
const cb = (url) => {
if (url && window['bridge'] && window['bridge'].jumpAdUrl) {
window['bridge'].jumpAdUrl(url);
}
}
this.stragegyFn[this.strategy].report.videoClick(this.videoRaw, this._times, e, cb);
this.stragegyFn[this.strategy].report.appDownload(this.videoRaw, this._times, e, cb);
});
this.player.on('$process', (e) => {
if (e > 25 && !this.process25) {
......@@ -107,6 +125,7 @@ class MyAdvideo {
});
this.player.on('ended', () => {
this.stragegyFn[this.strategy].report.videoPlayEnd(this.videoRaw, this._times);
this.isPlayEnd = true;
this.playResolve();
});
this.player.on('$videoClose', () => {
......@@ -130,7 +149,6 @@ class MyAdvideo {
if (window["helpbridge"] && window["helpbridge"].adShowing) window["helpbridge"].adShowing();
this.videoRaw = res;
const { url, appIcon, name, slogen, type } = this.stragegyFn[this.strategy].resolveParams(this.videoRaw);
console.log(url);
this.url = url;
this.appContent = {
appIcon,
......@@ -160,7 +178,7 @@ class MyAdvideo {
if (this.appContent) {
const starNum = [4, 4.5, 5][Math.floor(Math.random() * 3)];
const commentNum = Math.floor(Math.random() * 5000 + 5000);
const buttonText = this.appContent.type === 1 ? '立即查看' : '立即下载';
const buttonText = this.appContent.type === 1 ? '立即下载' : '立即查看';
this.player.emit('$landPageChangeApp',
Object["assign"]({ starNum, buttonText, commentNum },
this.appContent), true);
......
......@@ -251,7 +251,7 @@ const report = {
}
},
// 广告关闭
videoClose(raw, times, event) {
videoClose(raw, times, event, cb) {
const winCloseUrls = raw.metaGroup[0].winCloseUrls;
if (winCloseUrls && !this.isReportClick) {
this.isReportClick = true;
......@@ -261,7 +261,7 @@ const report = {
}
},
// 开始下载
async appDownload(raw, times, event) {
async appDownload(raw, times, event, cb) {
const winDownloadUrls = raw.metaGroup[0].winDownloadUrls;
if (winDownloadUrls && !this.isReportDownload) {
this.isReportDownload = true;
......@@ -275,13 +275,7 @@ const report = {
window.location.href = url;
return;
}
if (url && window['bridge'] && window['bridge'].jumpAdUrl) {
window['bridge'].jumpAdUrl(url)
} else {
console.log(url);
console.log(window['bridge']);
console.log(window['bridge'].jumpAdUrl);
}
cb(url);
},
// 播放完毕, 进度100.
videoPlayEnd(raw, times) {
......@@ -322,9 +316,11 @@ export function resolveParams(raw) {
videoRaw.iconUrls && videoRaw.iconUrls.length > 0 && (ads.appIcon = videoRaw.iconUrls[0]);
videoRaw.descs && videoRaw.descs.length > 0 && (ads.slogen = videoRaw.descs[0]);
if (videoRaw.interactionType === 2) {
ads.type === 1
console.log('下载类')
ads.type = 1
} else {
ads.type === 2
console.log('链接类')
ads.type = 2
}
}
console.log(ads);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment