Commit 72d1aec0 authored by jyx's avatar jyx

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

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