Commit 88e0db8e authored by jyx's avatar jyx

代码优化

parent 0ceb70e6
...@@ -7,9 +7,13 @@ ...@@ -7,9 +7,13 @@
<ad :unit-id="adUnitId" @load="onload" @close="onclose" @error="onerror"></ad> <ad :unit-id="adUnitId" @load="onload" @close="onclose" @error="onerror"></ad>
</view> --> </view> -->
<image @click="onClose" style="width: 50rpx; height: 50rpx;margin-left:auto;margin-right: 30rpx;
margin-bottom: 30rpx;" src="@/static/video/close.png"></image>
<view class="content"> <view class="content">
<text class="title">恭喜你,获得免费看剧名额</text> <text class="title">恭喜你,获得免费看剧名额</text>
<text class="button" @click="handleClose">看视频免费解锁1集</text> <text class="button1" @click="handleAd">看视频免费解锁1集</text>
<text class="button2" @click="handleVip">免广告解锁</text>
<text class="downtext">{{countDown}}s后自动进入广告,观看完成解锁第{{vedioIndex+1}}集剧情</text> <text class="downtext">{{countDown}}s后自动进入广告,观看完成解锁第{{vedioIndex+1}}集剧情</text>
</view> </view>
</view> </view>
...@@ -38,6 +42,7 @@ ...@@ -38,6 +42,7 @@
return { return {
adUnitId: EXPRESS_ID, adUnitId: EXPRESS_ID,
countDown: 3, countDown: 3,
timer: ''
}; };
}, },
methods: { methods: {
...@@ -49,21 +54,31 @@ ...@@ -49,21 +54,31 @@
let that = this; let that = this;
var countDownSeconds = 3 var countDownSeconds = 3
that.countDown = countDownSeconds that.countDown = countDownSeconds
const timer = setInterval(() => { this.timer = setInterval(() => {
if (countDownSeconds > 0) { if (countDownSeconds > 0) {
that.countDown = countDownSeconds that.countDown = countDownSeconds
countDownSeconds-- countDownSeconds--
} else { } else {
clearInterval(timer) clearInterval(that.timer)
that.handleClose() that.handleAd()
} }
}, 1000) }, 1000)
}, },
handleClose() { handleAd() {
clearInterval(this.timer)
// this.$refs.adPop.close('center');
this.$emit('handleAd');
},
handleVip() {
clearInterval(this.timer)
this.$refs.adPop.close('center'); this.$refs.adPop.close('center');
this.$emit('close'); this.$emit('handleVip');
},
onClose() {
clearInterval(this.timer)
this.$refs.adPop.close('center');
this.$emit('handleClose');
}, },
onload(e) { onload(e) {
console.log("onload"); console.log("onload");
...@@ -80,6 +95,9 @@ ...@@ -80,6 +95,9 @@
handler: function(newVal, oldVal) { handler: function(newVal, oldVal) {
if (newVal) { if (newVal) {
this.handleShow(); this.handleShow();
} else {
clearInterval(this.timer)
this.$refs.adPop.close('center');
} }
}, },
immediate: true immediate: true
...@@ -121,15 +139,34 @@ ...@@ -121,15 +139,34 @@
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.button { .button1 {
width: 500rpx;
height: 66rpx;
line-height: 66rpx;
text-align: center;
margin: 20rpx 20rpx; margin: 20rpx 20rpx;
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);
}
.button2 {
width: 500rpx;
height: 66rpx;
line-height: 66rpx;
text-align: center;
margin: 20rpx 20rpx;
border-radius: 10rpx;
background-color: white;
border: 1px orange solid;
color: orange;
font-size: 36rpx;
box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1);
} }
.downtext{ .downtext {
color: darkgray; color: darkgray;
font-size: 26rpx; font-size: 26rpx;
} }
......
...@@ -67,7 +67,10 @@ ...@@ -67,7 +67,10 @@
:originIndex="originIndex" /> :originIndex="originIndex" />
<coin-popup :show="showCoinPop" :point="data.point" :vedioId="data.vedioId" @close="showCoinPop = false" <coin-popup :show="showCoinPop" :point="data.point" :vedioId="data.vedioId" @close="showCoinPop = false"
@clickClose="coinPopupClose" @paySuccess="paySuccess" /> @clickClose="coinPopupClose" @paySuccess="paySuccess" />
<ad-popup :show="showAdPop" @close="adPopupClose" :vedioIndex="originIndex" /> <ad-popup :show="showAdPop" @handleAd="handleAd" @handleVip="handleVip" @handleClose="handleClose"
:vedioIndex="originIndex" />
<ad-more-popup :show="showAdMorePop" @handleAd2="handleAd" @handleClose="handleClose"
/>
<sign-popup :show="showSignPop" @close="showSignPop = false" /> <sign-popup :show="showSignPop" @close="showSignPop = false" />
</view> </view>
</template> </template>
...@@ -84,6 +87,7 @@ ...@@ -84,6 +87,7 @@
} from "@/utils/utils.js" } from "@/utils/utils.js"
import adPopup from '@/components/ad-popup/ad-popup.vue'; import adPopup from '@/components/ad-popup/ad-popup.vue';
import adMorePopup from '@/components/ad-more-popup/ad-more-popup.vue';
import coinPopup from '@/components/coin-popup/coin-popup.vue'; import coinPopup from '@/components/coin-popup/coin-popup.vue';
import signPopup from '@/components/sign-popup/sign-popup.vue'; import signPopup from '@/components/sign-popup/sign-popup.vue';
import episodePopup from '@/components/episode-popup/episode-popup.vue'; import episodePopup from '@/components/episode-popup/episode-popup.vue';
...@@ -134,7 +138,7 @@ ...@@ -134,7 +138,7 @@
showCoinPop: false, showCoinPop: false,
showSignPop: false, showSignPop: false,
showAdPop: false, showAdPop: false,
showAdForServer: false, showAdMorePop: false,
vipBackPage: '', vipBackPage: '',
curTimeData: '', curTimeData: '',
localTimeData: '', localTimeData: '',
...@@ -178,16 +182,16 @@ ...@@ -178,16 +182,16 @@
}); });
} }
this.post({ // this.post({
url: '/vedio/confs', // url: '/vedio/confs',
showLoading: false, // showLoading: false,
success: ({ // success: ({
data // data
}) => { // }) => {
// this.showAdForServer = data.douyinAdTipOpen; // // this.showAdForServer = data.douyinAdTipOpen;
this.showAdForServer = true; // this.showAdForServer = true;
} // }
}); // });
}, },
// 分享 // 分享
...@@ -262,7 +266,8 @@ ...@@ -262,7 +266,8 @@
this.$nextTick(() => { this.$nextTick(() => {
// 延迟渲染,否则位置错乱 // 延迟渲染,否则位置错乱
this.showCoinPop = true // this.showCoinPop = true
this.showAdPop = true
}) })
}, },
govip() { govip() {
...@@ -567,6 +572,7 @@ ...@@ -567,6 +572,7 @@
uni.showToast({ uni.showToast({
title: "正在为您解锁剧集" title: "正在为您解锁剧集"
}) })
that.showAdPop = false
that.adUnlock(that.originIndex, '') that.adUnlock(that.originIndex, '')
} else { } else {
uni.showToast({ uni.showToast({
...@@ -591,16 +597,23 @@ ...@@ -591,16 +597,23 @@
navigateTo(`/pagesA/task/task`) navigateTo(`/pagesA/task/task`)
}, },
coinPopupClose() { coinPopupClose() {
if (this.showAdForServer) {
this.showAdPop = true
} else {
this.showCoinPop = false this.showCoinPop = false
}
setTimeout(() => {
this.showAdPop = true
}, 500)
}, },
adPopupClose() { handleClose() {
this.showAdPop = false this.showAdPop = false
},
handleAd() {
// this.showAdPop = false
this.playRewardVideo() this.playRewardVideo()
}, },
handleVip() {
this.showAdPop = false
this.showCoinPop = true
},
playRewardVideo() { playRewardVideo() {
// 播放激励视频 // 播放激励视频
uni.showLoading({ uni.showLoading({
......
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