Commit 34c03ee8 authored by liupengfei's avatar liupengfei

去测试

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