Commit 49d321a0 authored by jyx's avatar jyx

添加观看广告解锁两集功能

parent 88e0db8e
<template>
<view>
<uni-popup type="center" ref="adPop2" :maskClick="false" :isMaskClick="false">
<view class="container">
<view class="content">
<text class="title">恭喜解锁剧集成功!</text>
<text class="info">再看一个广告可额外解锁 2 集视频,是否继续观看广告领取福利?</text>
<view class="flex space">
<text class="button1" @click="onClose">取消</text>
<text class="button2" @click="handleAd">领取福利</text>
</view>
</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 {};
},
methods: {
handleShow() {
this.$refs.adPop2.open('center');
},
handleAd() {
this.$refs.adPop2.close();
this.$emit('handleAdMore');
},
onClose() {
this.$refs.adPop2.close();
this.$emit('handleCloseMore');
},
},
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;
}
.content {
border-radius: 20rpx;
background-color: white;
display: flex;
// width: 600rpx;
padding: 50rpx 0;
flex-direction: column;
align-items: center;
.title {
color: black;
font-size: 40rpx;
margin-bottom: 30rpx;
}
.info {
width: 500rpx;
color: gray;
font-size: 34rpx;
margin-bottom: 30rpx;
}
.button1 {
width: 200rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
margin: 10rpx 20rpx;
border-radius: 80rpx;
background-color: lightgrey;
color: black;
font-size: 36rpx;
box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1);
}
.button2 {
width: 200rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
margin: 10rpx 20rpx;
border-radius: 80rpx;
background-color: orangered;
color: white;
font-size: 36rpx;
box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1);
}
.downtext {
color: darkgray;
font-size: 26rpx;
}
}
</style>
\ No newline at end of file
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<view class="content"> <view class="content">
<text class="title">恭喜你,获得免费看剧名额</text> <text class="title">恭喜你,获得免费看剧名额</text>
<text class="button1" @click="handleAd">看视频免费解锁1集</text> <text class="button-ad" @click="handleAd">看视频免费解锁1集</text>
<text class="button2" @click="handleVip">免广告解锁</text> <text class="button-vip" @click="handleVip">免广告解锁</text>
<text class="downtext">{{countDown}}s后自动进入广告,观看完成解锁第{{vedioIndex+1}}集剧情</text> <text class="downtext">{{countDown}}s后自动进入广告,观看完成解锁第{{vedioIndex+1}}集剧情</text>
</view> </view>
</view> </view>
...@@ -72,12 +72,12 @@ ...@@ -72,12 +72,12 @@
}, },
handleVip() { handleVip() {
clearInterval(this.timer) clearInterval(this.timer)
this.$refs.adPop.close('center'); this.$refs.adPop.close();
this.$emit('handleVip'); this.$emit('handleVip');
}, },
onClose() { onClose() {
clearInterval(this.timer) clearInterval(this.timer)
this.$refs.adPop.close('center'); this.$refs.adPop.close();
this.$emit('handleClose'); this.$emit('handleClose');
}, },
onload(e) { onload(e) {
...@@ -95,9 +95,13 @@ ...@@ -95,9 +95,13 @@
handler: function(newVal, oldVal) { handler: function(newVal, oldVal) {
if (newVal) { if (newVal) {
this.handleShow(); this.handleShow();
} else { } else {
clearInterval(this.timer) try {
this.$refs.adPop.close('center'); clearInterval(this.timer)
this.$refs.adPop.close();
} catch {
}
} }
}, },
immediate: true immediate: true
...@@ -139,7 +143,7 @@ ...@@ -139,7 +143,7 @@
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.button1 { .button-ad {
width: 500rpx; width: 500rpx;
height: 66rpx; height: 66rpx;
line-height: 66rpx; line-height: 66rpx;
...@@ -148,22 +152,22 @@ ...@@ -148,22 +152,22 @@
border-radius: 10rpx; border-radius: 10rpx;
background-color: orange; background-color: orange;
color: white; color: white;
font-size: 36rpx; font-size: 36rpx;
box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1); box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1);
} }
.button2 { .button-vip {
width: 500rpx; width: 498rpx;
height: 66rpx; height: 64rpx;
line-height: 66rpx; line-height: 64rpx;
text-align: center; text-align: center;
margin: 20rpx 20rpx; margin: 20rpx 20rpx;
border-radius: 10rpx; border-radius: 10rpx;
background-color: white; background-color: white;
border: 1px orange solid; border: 1px orange solid;
color: orange; color: orange;
font-size: 36rpx; font-size: 36rpx;
box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1); box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1);
} }
.downtext { .downtext {
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
import common from '@/mixins/common'; import common from '@/mixins/common';
import { import {
message,
navigateTo, navigateTo,
} from '@/utils/fun.js'; } from '@/utils/fun.js';
...@@ -153,10 +154,8 @@ ...@@ -153,10 +154,8 @@
success: ({ success: ({
data data
}) => { }) => {
this.isEditStyle = false this.isEditStyle = false
uni.showToast({ message.notify("删除成功")
title: "删除成功"
})
this.loadData() this.loadData()
} }
}); });
......
...@@ -56,7 +56,8 @@ ...@@ -56,7 +56,8 @@
import { import {
navigateTo, navigateTo,
message
} from '@/utils/fun.js'; } from '@/utils/fun.js';
let audo = uni.createInnerAudioContext() let audo = uni.createInnerAudioContext()
...@@ -103,10 +104,8 @@ ...@@ -103,10 +104,8 @@
// #ifdef H5 // #ifdef H5
uni.setClipboardData({ uni.setClipboardData({
data: href, data: href,
complete() { complete() {
uni.showToast({ message.notify("分享连接已复制到剪贴板")
title: "分享连接已复制到剪贴板"
})
} }
}) })
// #endif // #endif
...@@ -274,10 +273,8 @@ ...@@ -274,10 +273,8 @@
showLoading: false, showLoading: false,
success: ({ success: ({
data data
}) => { }) => {
uni.showToast({ message.notify("收藏成功")
title: "收藏成功"
})
} }
}); });
}, },
...@@ -292,10 +289,8 @@ ...@@ -292,10 +289,8 @@
showLoading: false, showLoading: false,
success: ({ success: ({
data data
}) => { }) => {
uni.showToast({ message.notify("取消收藏")
title: "取消收藏"
})
} }
}); });
}, },
......
...@@ -69,8 +69,7 @@ ...@@ -69,8 +69,7 @@
@clickClose="coinPopupClose" @paySuccess="paySuccess" /> @clickClose="coinPopupClose" @paySuccess="paySuccess" />
<ad-popup :show="showAdPop" @handleAd="handleAd" @handleVip="handleVip" @handleClose="handleClose" <ad-popup :show="showAdPop" @handleAd="handleAd" @handleVip="handleVip" @handleClose="handleClose"
:vedioIndex="originIndex" /> :vedioIndex="originIndex" />
<ad-more-popup :show="showAdMorePop" @handleAd2="handleAd" @handleClose="handleClose" <ad-more-popup :show="showAdMorePop" @handleAdMore="handleAd2" @handleCloseMore="handleClose2" />
/>
<sign-popup :show="showSignPop" @close="showSignPop = false" /> <sign-popup :show="showSignPop" @close="showSignPop = false" />
</view> </view>
</template> </template>
...@@ -110,6 +109,7 @@ ...@@ -110,6 +109,7 @@
episodePopup, episodePopup,
signPopup, signPopup,
adPopup, adPopup,
adMorePopup,
ttVideoPlayer ttVideoPlayer
}, },
data() { data() {
...@@ -137,12 +137,13 @@ ...@@ -137,12 +137,13 @@
showTap: false, showTap: false,
showCoinPop: false, showCoinPop: false,
showSignPop: false, showSignPop: false,
showAdPop: false, showAdPop: false,
showAdMorePop: false, showAdMorePop: false,
vipBackPage: '', vipBackPage: '',
curTimeData: '', curTimeData: '',
localTimeData: '', localTimeData: '',
canUseTTPlayer: true, canUseTTPlayer: true,
isMoreAd: false
}; };
}, },
onLoad(options) { onLoad(options) {
...@@ -182,27 +183,15 @@ ...@@ -182,27 +183,15 @@
}); });
} }
// this.post({ this.reportBeginSeeTime()
// url: '/vedio/confs', },
// showLoading: false, onHide() {
// success: ({ this.reportEndSeeTime()
// data },
// }) => { onUnload() {
// // this.showAdForServer = data.douyinAdTipOpen; this.removeRewardPoint()
// this.showAdForServer = true; this.reportEndSeeTime()
// }
// });
}, },
// 分享
// onShareAppMessage() {
// let result = {
// title: this.data.title,
// imageUrl: this.data.coverImage,
// path: `/pageC/ttvideo/ttVideoDetail?bookId=${this.bookData.id}`
// }
// return result;
// },
methods: { methods: {
startPlay() { startPlay() {
if (tt.canIUse('preloadResourceVideo')) { if (tt.canIUse('preloadResourceVideo')) {
...@@ -273,7 +262,7 @@ ...@@ -273,7 +262,7 @@
govip() { govip() {
navigateTo(`/pagesA/vipPay/vipPay`) navigateTo(`/pagesA/vipPay/vipPay`)
}, },
timeupdate(event) {}, timeUpdate(event) {},
selectThisVideo(index) { selectThisVideo(index) {
if (this.originIndex == index) { if (this.originIndex == index) {
return return
...@@ -304,6 +293,58 @@ ...@@ -304,6 +293,58 @@
this.isqp = true this.isqp = true
this.controls = true this.controls = true
}, },
reportBeginSeeTime() {
// 上报看剧时间
let that = this
this.post({
url: '/vTask/common/reportCompleteMsg/beginSeeTime',
data: {},
showLoading: false,
success: ({
data
}) => {}
});
},
reportEndSeeTime() {
// 上报看剧时间
let that = this
this.post({
url: '/vTask/common/reportCompleteMsg/endSeeTime',
data: {},
showLoading: false,
success: ({
data
}) => {}
});
},
addRewardPoint(vedioId) {
// 看两次广告 10分钟内 免费看两集
let that = this
this.post({
url: '/vTask/vedioPageSeeAdForAddPoint',
data: {
vedioId
},
showLoading: false,
success: ({
data
}) => {
message.notify("恭喜您,10分钟内可免费解锁两集!")
}
});
},
removeRewardPoint() {
// 丢失所有剧集内临时看点
let that = this
this.post({
url: '/vTask/vedioPageClose',
data: {},
showLoading: false,
success: ({
data
}) => {}
});
},
unlock(num) { unlock(num) {
let that = this let that = this
this.post({ this.post({
...@@ -316,10 +357,8 @@ ...@@ -316,10 +357,8 @@
success: ({ success: ({
data data
}) => { }) => {
uni.showToast({ message.notify(data.msg)
title: data.msg,
icon: 'none'
})
if (data.code == 200) { if (data.code == 200) {
that.originList[that.originIndex].lock = false that.originList[that.originIndex].lock = false
setTimeout(() => { setTimeout(() => {
...@@ -507,7 +546,6 @@ ...@@ -507,7 +546,6 @@
}); });
}, },
cancelCollect(vedioId, index) { cancelCollect(vedioId, index) {
// this.showSignPop = true
this.data.collect = 0 this.data.collect = 0
// 取消收藏 // 取消收藏
this.post({ this.post({
...@@ -546,10 +584,8 @@ ...@@ -546,10 +584,8 @@
// 监听错误 // 监听错误
this.ad.onError((err) => { this.ad.onError((err) => {
uni.hideLoading(); uni.hideLoading();
message.notify("网络太火爆了,请稍候重试")
uni.showToast({
title: "网络太火爆了,请稍候重试"
})
switch (err.errCode) { switch (err.errCode) {
case 1004: case 1004:
// 无合适的广告 // 无合适的广告
...@@ -569,15 +605,24 @@ ...@@ -569,15 +605,24 @@
this.ad.onClose((data) => { this.ad.onClose((data) => {
uni.hideLoading(); uni.hideLoading();
if (data.isEnded) { if (data.isEnded) {
uni.showToast({ if (that.isMoreAd) {
title: "正在为您解锁剧集" message.notify("正在为您解锁剧集")
}) this.adUnlock(this.originIndex, '')
that.showAdPop = false that.addRewardPoint(that.originList[that.originIndex].vedioId)
that.adUnlock(that.originIndex, '')
that.isMoreAd = false
that.showAdMorePop = false
that.showAdPop = false
} else {
that.showAdPop = false
that.$nextTick(() => {
// 延迟渲染,否则位置错乱
that.showAdMorePop = true
})
}
} else { } else {
uni.showToast({ message.notify("未观看完整视频")
title: "未观看完整视频"
})
that.$nextTick(() => { that.$nextTick(() => {
// 延迟渲染,否则位置错乱 // 延迟渲染,否则位置错乱
...@@ -606,19 +651,29 @@ ...@@ -606,19 +651,29 @@
handleClose() { handleClose() {
this.showAdPop = false this.showAdPop = false
}, },
handleClose2() {
// 再看广告解锁两集,取消
this.showAdMorePop = false
this.adUnlock(this.originIndex, '')
message.notify("正在为您解锁剧集")
},
handleAd() { handleAd() {
// this.showAdPop = false // this.showAdPop = false
this.playRewardVideo() this.playRewardVideo()
}, },
handleAd2() {
// 再看广告解锁两集,看广告
this.showAdMorePop = false
this.isMoreAd = true
this.playRewardVideo()
},
handleVip() { handleVip() {
this.showAdPop = false this.showAdPop = false
this.showCoinPop = true this.showCoinPop = true
}, },
playRewardVideo() { playRewardVideo() {
// 播放激励视频 // 播放激励视频
uni.showLoading({ message.notify('广告加载中')
title: '广告加载中'
});
this.ad.show(); this.ad.show();
}, },
adUnlock(num, ecpm) { adUnlock(num, ecpm) {
...@@ -634,11 +689,9 @@ ...@@ -634,11 +689,9 @@
showLoading: false, showLoading: false,
success: ({ success: ({
data data
}) => { }) => {
uni.showToast({ message.notify( data.msg)
title: data.msg,
icon: 'none'
})
if (data.code == 200) { if (data.code == 200) {
that.originList[that.originIndex].lock = false that.originList[that.originIndex].lock = false
setTimeout(() => { setTimeout(() => {
......
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