Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xiaoxiaoleTuia
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王剑峰
xiaoxiaoleTuia
Commits
34c03ee8
Commit
34c03ee8
authored
Feb 18, 2020
by
liupengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去测试
parent
31cb528f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
16 deletions
+30
-16
adVideo.ts
egret/src/adVideo/adVideo.ts
+23
-5
dianxiangVideo.ts
egret/src/adVideo/dianxiangVideo.ts
+7
-11
No files found.
egret/src/adVideo/adVideo.ts
View file @
34c03ee8
...
...
@@ -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
);
...
...
egret/src/adVideo/dianxiangVideo.ts
View file @
34c03ee8
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment