Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
uniapp_vedio
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
android
uniapp_vedio
Commits
d03743cf
Commit
d03743cf
authored
Mar 06, 2024
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加激励视频解锁剧集
parent
881d45d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
251 additions
and
38 deletions
+251
-38
ad-popup.vue
vedio/components/ad-popup/ad-popup.vue
+126
-0
coin-popup.vue
vedio/components/coin-popup/coin-popup.vue
+1
-1
ttVideoDetail.vue
vedio/pagesC/ttvideo/ttVideoDetail.vue
+121
-37
adConstant.js
vedio/utils/adConstant.js
+3
-0
No files found.
vedio/components/ad-popup/ad-popup.vue
0 → 100644
View file @
d03743cf
<
template
>
<view>
<uni-popup
type=
"center"
ref=
"adPop"
:maskClick=
"false"
:isMaskClick=
"false"
>
<view
class=
"container"
>
<!--
<view
class=
"ad-view"
>
<ad
:unit-id=
"adUnitId"
@
load=
"onload"
@
close=
"onclose"
@
error=
"onerror"
></ad>
</view>
-->
<view
class=
"content"
>
<text
class=
"title"
>
恭喜你,获得免费看剧名额
</text>
<text
class=
"button"
@
click=
"handleClose"
>
看视频免费解锁1集
</text>
<text
class=
"downtext"
>
{{
countDown
+
's后自动进入广告页面解锁后续'
}}
</text>
</view>
</view>
</uni-popup>
</view>
</
template
>
<
script
>
import
{
EXPRESS_ID
}
from
"@/utils/adConstant.js"
export
default
{
name
:
'adPopup'
,
props
:
{
show
:
{
type
:
Boolean
,
default
:
false
,
},
},
data
()
{
return
{
adUnitId
:
EXPRESS_ID
,
countDown
:
0
,
};
},
methods
:
{
handleShow
()
{
this
.
$refs
.
adPop
.
open
(
'center'
);
this
.
startCountdown
()
},
startCountdown
()
{
let
that
=
this
;
var
countDownSeconds
=
10
const
timer
=
setInterval
(()
=>
{
if
(
countDownSeconds
>
0
)
{
that
.
countDown
=
countDownSeconds
countDownSeconds
--
}
else
{
clearInterval
(
timer
)
that
.
handleClose
()
}
},
1000
)
},
handleClose
()
{
this
.
$refs
.
adPop
.
close
(
'center'
);
this
.
$emit
(
'close'
);
},
onload
(
e
)
{
console
.
log
(
"onload"
);
},
onclose
(
e
)
{
console
.
log
(
"onclose: "
+
e
.
detail
);
},
onerror
(
e
)
{
console
.
log
(
"onerror: "
+
e
.
detail
.
errCode
+
" message:: "
+
e
.
detail
.
errMsg
);
}
},
watch
:
{
show
:
{
handler
:
function
(
newVal
,
oldVal
)
{
if
(
newVal
)
{
this
.
handleShow
();
}
},
immediate
:
true
}
}
};
</
script
>
<
style
lang=
"scss"
>
.container
{
width
:
600rpx
;
height
:
800rpx
;
position
:
relative
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
}
.ad-view
{
width
:
600rpx
;
border-radius
:
20rpx
;
// background-color: white;
margin-bottom
:
10px
;
}
.content
{
border-radius
:
20rpx
;
background-color
:
white
;
display
:
flex
;
width
:
600rpx
;
padding
:
30rpx
0
;
flex-direction
:
column
;
align-items
:
center
;
.title
{
color
:
black
;
font-size
:
40rpx
;
font-weight
:
bold
;
margin-bottom
:
30rpx
;
}
.button
{
margin
:
20rpx
20rpx
;
border-radius
:
10rpx
;
background-color
:
orange
;
color
:
white
;
font-size
:
36rpx
;
}
}
</
style
>
\ No newline at end of file
vedio/components/coin-popup/coin-popup.vue
View file @
d03743cf
...
...
@@ -19,7 +19,7 @@
<scroll-view
scroll-y
>
<view
style=
"display: flex;flex-direction: column;align-items: flex-end;"
>
<view
style=
"display: flex;flex-direction: row;"
>
<view
@
click=
"handleAgree"
style=
"margin-top: 1
0
rpx;margin-right: 10rpx;"
>
付费须知>
</view>
<view
@
click=
"handleAgree"
style=
"margin-top: 1
2
rpx;margin-right: 10rpx;"
>
付费须知>
</view>
<image
@
click=
"handleClose"
style=
"width: 30rpx;height: 30rpx;display: flex;align-items: right;margin-top: 20rpx;margin-right: 20rpx;margin-bottom: 10rpx;"
src=
"@/static/index/ic_quit_white.png"
></image>
...
...
vedio/pagesC/ttvideo/ttVideoDetail.vue
View file @
d03743cf
...
...
@@ -66,18 +66,24 @@
<episodePopup
ref=
"episodePopup"
@
selectVideo=
"selectThisVideo"
:windowWidth=
"windowWidth"
:windowHeight=
"windowHeight"
:tabIndex=
"tabIndex"
:tabs=
"tabs"
:subList=
"subList"
:originList=
"originList"
:originIndex=
"originIndex"
/>
<coin-popup
:show=
"showCoinPop"
:point=
"data.point"
:vedioId=
"data.vedioId"
@
close=
"
showCoinPop = fal
se"
<coin-popup
:show=
"showCoinPop"
:point=
"data.point"
:vedioId=
"data.vedioId"
@
close=
"
coinPopupClo
se"
@
paySuccess=
"paySuccess"
/>
<ad-popup
:show=
"showAdPop"
@
close=
"adPopupClose"
/>
</view>
</
template
>
<
script
>
import
{
REWARD_ID
}
from
"@/utils/adConstant.js"
import
common
from
'@/mixins/common'
;
import
{
getSubList
}
from
"@/utils/utils.js"
import
adPopup
from
'@/components/ad-popup/ad-popup.vue'
;
import
coinPopup
from
'@/components/coin-popup/coin-popup.vue'
;
import
episodePopup
from
'@/components/episode-popup/episode-popup.vue'
;
...
...
@@ -96,6 +102,7 @@
components
:
{
coinPopup
,
episodePopup
,
adPopup
,
ttVideoPlayer
},
data
()
{
...
...
@@ -121,6 +128,7 @@
subList
:
[],
showTap
:
false
,
showCoinPop
:
false
,
showAdPop
:
false
,
vipBackPage
:
''
,
canUseTTPlayer
:
true
,
};
...
...
@@ -141,42 +149,9 @@
this
.
ttuop
=
64
// #endif
this
.
getData
()
this
.
preloadAd
()
// 创建实例
this
.
ad
=
tt
.
createRewardedVideoAd
({
adUnitId
:
"5owlrx99qby0ephhco"
,
});
// 监听错误
this
.
ad
.
onError
((
err
)
=>
{
tt
.
hideLoading
();
switch
(
err
.
errCode
)
{
case
1004
:
// 无合适的广告
break
;
default
:
// 更多请参考错误码文档
}
});
// 监听视频播放完成
this
.
ad
.
onClose
((
data
)
=>
{
tt
.
hideLoading
();
if
(
data
.
isEnded
)
{
console
.
log
(
"观看了"
,
data
.
count
,
"个视频"
);
}
else
{
console
.
log
(
"未观看完视频"
);
}
});
// do other thing
// 卸载 close 事件监听
this
.
ad
.
offClose
(
closeHandler
);
// 预加载资源
this
.
ad
.
load
();
},
onShow
()
{
// 从VIP页面返回关闭弹框
...
...
@@ -469,8 +444,8 @@
this
.
isqp
=
e
.
detail
.
show
},
collect
(
vedioId
,
index
)
{
t
t
.
showLoading
();
this
.
ad
.
show
();
t
his
.
showAdPop
=
true
return
this
.
data
.
collect
=
1
// 收藏
...
...
@@ -514,6 +489,115 @@
})
=>
{}
});
},
preloadAd
()
{
// 创建实例
this
.
ad
=
tt
.
createRewardedVideoAd
({
adUnitId
:
REWARD_ID
,
});
// 监听错误
this
.
ad
.
onError
((
err
)
=>
{
tt
.
hideLoading
();
uni
.
showToast
({
title
:
"网络太火爆了,请稍候重试"
})
switch
(
err
.
errCode
)
{
case
1004
:
// 无合适的广告
break
;
default
:
// 更多请参考错误码文档
}
});
let
that
=
this
// 监听视频播放完成
this
.
ad
.
onClose
((
data
)
=>
{
tt
.
hideLoading
();
if
(
data
.
isEnded
)
{
uni
.
showToast
({
title
:
"正在为您解锁剧集"
})
that
.
adUnlock
(
that
.
originIndex
,
''
)
}
else
{
uni
.
showToast
({
title
:
"未观看完整视频"
})
}
});
// do other thing
// 卸载 close 事件监听
// this.ad.offClose(closeHandler);
// 预加载资源
this
.
ad
.
load
();
},
coinPopupClose
()
{
this
.
showCoinPop
=
false
this
.
showAdPop
=
true
},
adPopupClose
()
{
this
.
showAdPop
=
false
this
.
playRewardVideo
()
},
playRewardVideo
()
{
// 播放激励视频
tt
.
showLoading
();
this
.
ad
.
show
();
},
adUnlock
(
num
,
ecpm
)
{
let
that
=
this
this
.
post
({
url
:
'/vedio/unlockByAd'
,
data
:
{
adSource
:
'csj'
,
vedioId
:
this
.
data
.
vedioId
,
num
:
(
num
+
1
),
ecpm
:
ecpm
},
showLoading
:
false
,
success
:
({
data
})
=>
{
uni
.
showToast
({
title
:
data
.
msg
,
icon
:
'none'
})
if
(
data
.
code
==
200
)
{
that
.
originList
[
that
.
originIndex
].
lock
=
false
setTimeout
(()
=>
{
tt
.
createVideoContext
(
''
+
that
.
originList
[
that
.
originIndex
]
.
vedioIndex
,
that
)
.
play
();
that
.
commitVideo
()
},
500
)
}
else
if
(
data
.
code
==
301
)
{
that
.
originList
[
that
.
originIndex
].
lock
=
false
setTimeout
(()
=>
{
tt
.
createVideoContext
(
''
+
that
.
originList
[
that
.
originIndex
]
.
vedioIndex
,
that
)
.
play
();
that
.
commitVideo
()
},
500
)
}
else
if
(
data
.
code
==
302
)
{
that
.
originList
[
that
.
originIndex
].
lock
=
false
setTimeout
(()
=>
{
tt
.
createVideoContext
(
''
+
that
.
originList
[
that
.
originIndex
]
.
vedioIndex
,
that
)
.
play
();
that
.
commitVideo
()
},
500
)
}
else
if
(
data
.
code
==
303
)
{
that
.
showPayDialog
()
}
}
});
},
},
};
</
script
>
...
...
vedio/utils/adConstant.js
0 → 100644
View file @
d03743cf
export
const
EXPRESS_ID
=
'q1031ievmv1z3j28gs'
export
const
REWARD_ID
=
'm1qtdoeeqq9txgahk4'
\ No newline at end of file
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