Commit 72d1aec0 authored by jyx's avatar jyx

优化激励视频全局监听问题

parent 1c25fb07
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
<userPage v-show="currentPage==3" ref="user" /> <userPage v-show="currentPage==3" ref="user" />
</view> </view>
<view v-if="!isShowBlackBar" class="tabs-bar"> <view v-if="!isShowBlackBar" class="tabs-bar">
<view :class="currentPage==0?'tab active': 'tab'" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" <view :class="currentPage==0?'tab active': 'tab'"
@click="tabChange(0)"> :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" @click="tabChange(0)">
<view v-if="false" style="margin: 16rpx 0 11rpx;"> <view v-if="false" style="margin: 16rpx 0 11rpx;">
<image v-if="currentPage==0" class="tabs-image" src="/static/tab/index_selected.png" <image v-if="currentPage==0" class="tabs-image" src="/static/tab/index_selected.png"
mode="heightFix"> mode="heightFix">
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
</view> </view>
剧场 剧场
</view> </view>
<view :class="currentPage == 1?'tab active': 'tab'" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" <view :class="currentPage == 1?'tab active': 'tab'"
@click="tabChange(1)"> :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" @click="tabChange(1)">
<view v-if="false" style="margin: 16rpx 0 11rpx;"> <view v-if="false" style="margin: 16rpx 0 11rpx;">
<image v-if="currentPage==1" class="tabs-image" src="/static/tab/promote_selected.png" <image v-if="currentPage==1" class="tabs-image" src="/static/tab/promote_selected.png"
mode="heightFix"></image> mode="heightFix"></image>
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
</view> </view>
推荐 推荐
</view> </view>
<view :class="currentPage == 2?'tab active': 'tab'" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" <view :class="currentPage == 2?'tab active': 'tab'"
@click="tabChange(2)"> :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" @click="tabChange(2)">
<view v-if="false" style="margin: 16rpx 0 11rpx;"> <view v-if="false" style="margin: 16rpx 0 11rpx;">
<image v-if="currentPage==2" class="tabs-image" src="/static/tab/promote_selected.png" <image v-if="currentPage==2" class="tabs-image" src="/static/tab/promote_selected.png"
mode="heightFix"></image> mode="heightFix"></image>
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
</view> </view>
看过 看过
</view> </view>
<view :class="currentPage == 3?'tab active': 'tab'" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" <view :class="currentPage == 3?'tab active': 'tab'"
@click="tabChange(3)"> :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" @click="tabChange(3)">
<view v-if="false" style="margin: 16rpx 0 11rpx;"> <view v-if="false" style="margin: 16rpx 0 11rpx;">
<image v-if="currentPage==3" class="tabs-image" src="/static/tab/my_selected.png" mode="heightFix"> <image v-if="currentPage==3" class="tabs-image" src="/static/tab/my_selected.png" mode="heightFix">
</image> </image>
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
</view> </view>
<view v-if="isShowBlackBar" class="tabs-bar2"> <view v-if="isShowBlackBar" class="tabs-bar2">
<view :class="currentPage==0?'tab active': 'tab'" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" <view :class="currentPage==0?'tab active': 'tab'"
@click="tabChange(0)"> :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" @click="tabChange(0)">
<view v-if="false" style="margin: 16rpx 0 11rpx;"> <view v-if="false" style="margin: 16rpx 0 11rpx;">
<image v-if="currentPage==0" class="tabs-image" src="/static/tab/index_selected.png" <image v-if="currentPage==0" class="tabs-image" src="/static/tab/index_selected.png"
mode="heightFix"> mode="heightFix">
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
</view> </view>
剧场 剧场
</view> </view>
<view :class="currentPage == 1?'tab active': 'tab'" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" <view :class="currentPage == 1?'tab active': 'tab'"
@click="tabChange(1)"> :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" @click="tabChange(1)">
<view v-if="false" style="margin: 16rpx 0 11rpx;"> <view v-if="false" style="margin: 16rpx 0 11rpx;">
<image v-if="currentPage==1" class="tabs-image" src="/static/tab/promote_selected.png" <image v-if="currentPage==1" class="tabs-image" src="/static/tab/promote_selected.png"
mode="heightFix"></image> mode="heightFix"></image>
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
</view> </view>
推荐 推荐
</view> </view>
<view :class="currentPage == 2?'tab active': 'tab'" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" <view :class="currentPage == 2?'tab active': 'tab'"
@click="tabChange(2)"> :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'" @click="tabChange(2)">
<view v-if="false" style="margin: 16rpx 0 11rpx;"> <view v-if="false" style="margin: 16rpx 0 11rpx;">
<image v-if="currentPage==2" class="tabs-image" src="/static/tab/my_selected.png" mode="heightFix"> <image v-if="currentPage==2" class="tabs-image" src="/static/tab/my_selected.png" mode="heightFix">
</image> </image>
...@@ -78,7 +78,8 @@ ...@@ -78,7 +78,8 @@
</view> </view>
</view> </view>
<view v-if="showEditBar" class="editBar" :style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'"> <view v-if="showEditBar" class="editBar"
:style="'padding-top:35rpx;padding-bottom:' + bottomSafePadding + 'px;'">
<view class="editItem" @click="!isFullChoice?fullChoice():noChoice()"> <view class="editItem" @click="!isFullChoice?fullChoice():noChoice()">
{{!isFullChoice?'全选':'全不选'}} {{!isFullChoice?'全选':'全不选'}}
</view> </view>
...@@ -90,6 +91,9 @@ ...@@ -90,6 +91,9 @@
</template> </template>
<script> <script>
import {
REWARD_ID
} from '@/utils/adConstant.js';
import { import {
navigateTo, navigateTo,
alert alert
...@@ -133,7 +137,6 @@ ...@@ -133,7 +137,6 @@
}, },
}) })
} }
}, },
onShow() { onShow() {
try { try {
...@@ -144,7 +147,7 @@ ...@@ -144,7 +147,7 @@
this.$refs.recommend.show(); this.$refs.recommend.show();
} else if (this.currentPage == 2) { } else if (this.currentPage == 2) {
this.$refs.follow.show(); this.$refs.follow.show();
}else if (this.currentPage == 3) { } else if (this.currentPage == 3) {
this.$refs.user.show(); this.$refs.user.show();
} }
} catch (e) { } catch (e) {
......
...@@ -135,6 +135,9 @@ ...@@ -135,6 +135,9 @@
this.getTaskList() this.getTaskList()
this.preloadAd() this.preloadAd()
}, },
onUnload() {
this.ad.offClose(this.ad.closeHandler);
},
methods: { methods: {
async onShareAppMessage(option) { async onShareAppMessage(option) {
const title = this.share.title; const title = this.share.title;
...@@ -180,10 +183,8 @@ ...@@ -180,10 +183,8 @@
this.ad.load(); this.ad.load();
}, },
showAd(item, isSign) { showAd(item, isSign) {
this.ad.show();
let that = this let that = this
// 监听视频播放完成 this.ad.closeHandler = function(res) {
this.ad.onClose((data) => {
tt.hideLoading(); tt.hideLoading();
if (data.isEnded) { if (data.isEnded) {
if (isSign) { if (isSign) {
...@@ -194,7 +195,11 @@ ...@@ -194,7 +195,11 @@
} else { } else {
message.notify('未观看完视频'); message.notify('未观看完视频');
} }
}); };
this.ad.onClose(this.ad.closeHandler)
this.ad.show();
}, },
getSignList() { getSignList() {
let that = this let that = this
...@@ -267,6 +272,9 @@ ...@@ -267,6 +272,9 @@
}) })
}, },
sign() { sign() {
let item = this.signList[this.signData.todayMsgIndexInWeek]
this.showAd(item, true)
return
let buttonStatus = this.signData.buttonStatus let buttonStatus = this.signData.buttonStatus
if (this.signData == '' || this.signData.buttonStatus == 2) { if (this.signData == '' || this.signData.buttonStatus == 2) {
return return
...@@ -280,7 +288,6 @@ ...@@ -280,7 +288,6 @@
let rewardMoreType = this.signList[this.signData.todayMsgIndexInWeek].rewardMoreType let rewardMoreType = this.signList[this.signData.todayMsgIndexInWeek].rewardMoreType
if (rewardMoreType == 1) { if (rewardMoreType == 1) {
// TODO 看广告
let item = this.signList[this.signData.todayMsgIndexInWeek] let item = this.signList[this.signData.todayMsgIndexInWeek]
this.showAd(item, true) this.showAd(item, true)
} else if (ewardMoreType == 2) { } else if (ewardMoreType == 2) {
......
...@@ -166,11 +166,9 @@ ...@@ -166,11 +166,9 @@
this.localTimeData = uni.getStorageSync('ONE_DAY_OPENBEG'); this.localTimeData = uni.getStorageSync('ONE_DAY_OPENBEG');
this.getData() this.getData()
this.preloadAd()
}, },
onShow() { onShow() {
// 从VIP页面返回关闭弹框 // 从VIP页面返回关闭弹框
// this.$refs.episodePopup.down();
this.windowWidth = uni.getSystemInfoSync().windowWidth this.windowWidth = uni.getSystemInfoSync().windowWidth
this.windowHeight = uni.getSystemInfoSync().windowHeight - this.safeArea - this.ttuop this.windowHeight = uni.getSystemInfoSync().windowHeight - this.safeArea - this.ttuop
...@@ -183,12 +181,16 @@ ...@@ -183,12 +181,16 @@
}); });
} }
this.preloadAd()
this.reportBeginSeeTime() this.reportBeginSeeTime()
}, },
onHide() { onHide() {
// 移除
this.ad.offClose(this.ad.closeHandler);
this.reportEndSeeTime() this.reportEndSeeTime()
}, },
onUnload() { onUnload() {
this.ad.offClose(this.ad.closeHandler);
this.removeRewardPoint() this.removeRewardPoint()
this.reportEndSeeTime() this.reportEndSeeTime()
}, },
...@@ -243,16 +245,6 @@ ...@@ -243,16 +245,6 @@
} }
}, },
showPayDialog() { showPayDialog() {
// let isIOS = wx.getSystemInfoSync().platform;
// if (isIOS === 'ios') {
// uni.showToast({
// title: '暂不支持IOS系统',
// icon: 'none'
// })
// return
// }
this.$nextTick(() => { this.$nextTick(() => {
// 延迟渲染,否则位置错乱 // 延迟渲染,否则位置错乱
// this.showCoinPop = true // this.showCoinPop = true
...@@ -575,42 +567,20 @@ ...@@ -575,42 +567,20 @@
}); });
}, },
preloadAd() { preloadAd() {
let that = this
// 创建实例 // 创建实例
this.ad = tt.createRewardedVideoAd({ this.ad = tt.createRewardedVideoAd({
adUnitId: REWARD_ID, adUnitId: REWARD_ID,
}); });
// 监听错误 let that = this
this.ad.onError((err) => { this.ad.closeHandler = function(res) {
uni.hideLoading();
message.notify("网络太火爆了,请稍候重试")
switch (err.errCode) {
case 1004:
// 无合适的广告
break;
default:
// 更多请参考错误码文档
}
that.$nextTick(() => {
// 延迟渲染,否则位置错乱
that.showCoinPop = true
})
});
// 监听视频播放完成
this.ad.onClose((data) => {
uni.hideLoading(); uni.hideLoading();
if (data.isEnded) { if (res && res.isEnded || res === undefined) {
if (that.isMoreAd) { if (that.isMoreAd) {
message.notify("正在为您解锁剧集") message.notify("正在为您解锁剧集")
this.adUnlock(this.originIndex, '') this.adUnlock(this.originIndex, '')
that.addRewardPoint(that.originList[that.originIndex].vedioId) that.addRewardPoint(that.originList[that.originIndex].vedioId)
that.isMoreAd = false that.isMoreAd = false
that.showAdMorePop = false that.showAdMorePop = false
that.showAdPop = false that.showAdPop = false
...@@ -623,17 +593,31 @@ ...@@ -623,17 +593,31 @@
} }
} else { } else {
message.notify("未观看完整视频") message.notify("未观看完整视频")
}
};
// that.$nextTick(() => { // 监听错误
// // 延迟渲染,否则位置错乱 this.ad.onError((err) => {
// that.showCoinPop = true uni.hideLoading();
// }) message.notify("网络太火爆了,请稍候重试")
switch (err.errCode) {
case 1004:
// 无合适的广告
break;
default:
// 更多请参考错误码文档
} }
that.$nextTick(() => {
// 延迟渲染,否则位置错乱
that.showCoinPop = true
})
}); });
// do other thing // 监听视频播放完成
// 卸载 close 事件监听 this.ad.onClose(this.ad.closeHandler);
// this.ad.offClose(closeHandler);
// 预加载资源 // 预加载资源
this.ad.load(); this.ad.load();
...@@ -690,7 +674,7 @@ ...@@ -690,7 +674,7 @@
success: ({ success: ({
data data
}) => { }) => {
message.notify( data.msg) message.notify(data.msg)
if (data.code == 200) { if (data.code == 200) {
that.originList[that.originIndex].lock = false that.originList[that.originIndex].lock = false
......
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