Commit 88e0db8e authored by jyx's avatar jyx

代码优化

parent 0ceb70e6
<template> <template>
<view> <view>
<uni-popup type="center" ref="adPop" :maskClick="false" :isMaskClick="false"> <uni-popup type="center" ref="adPop" :maskClick="false" :isMaskClick="false">
<view class="container"> <view class="container">
<!-- <view class="ad-view"> <!-- <view class="ad-view">
<ad :unit-id="adUnitId" @load="onload" @close="onclose" @error="onerror"></ad> <ad :unit-id="adUnitId" @load="onload" @close="onclose" @error="onerror"></ad>
</view> --> </view> -->
<view class="content"> <image @click="onClose" style="width: 50rpx; height: 50rpx;margin-left:auto;margin-right: 30rpx;
<text class="title">恭喜你,获得免费看剧名额</text> margin-bottom: 30rpx;" src="@/static/video/close.png"></image>
<text class="button" @click="handleClose">看视频免费解锁1集</text>
<text class="downtext">{{countDown}}s后自动进入广告,观看完成解锁第{{vedioIndex+1}}集剧情</text> <view class="content">
</view> <text class="title">恭喜你,获得免费看剧名额</text>
</view> <text class="button1" @click="handleAd">看视频免费解锁1集</text>
</uni-popup> <text class="button2" @click="handleVip">免广告解锁</text>
</view> <text class="downtext">{{countDown}}s后自动进入广告,观看完成解锁第{{vedioIndex+1}}集剧情</text>
</template> </view>
</view>
<script> </uni-popup>
import { </view>
EXPRESS_ID </template>
} from "@/utils/adConstant.js"
<script>
export default { import {
name: 'adPopup', EXPRESS_ID
props: { } from "@/utils/adConstant.js"
show: {
type: Boolean, export default {
default: false, name: 'adPopup',
}, props: {
vedioIndex: { show: {
type: [Number, String], type: Boolean,
default: 0 default: false,
} },
}, vedioIndex: {
data() { type: [Number, String],
return { default: 0
adUnitId: EXPRESS_ID, }
countDown: 3, },
}; data() {
}, return {
methods: { adUnitId: EXPRESS_ID,
handleShow() { countDown: 3,
this.$refs.adPop.open('center'); timer: ''
this.startCountdown() };
}, },
startCountdown() { methods: {
let that = this; handleShow() {
this.$refs.adPop.open('center');
var countDownSeconds = 3 this.startCountdown()
},
that.countDown = countDownSeconds startCountdown() {
const timer = setInterval(() => { let that = this;
if (countDownSeconds > 0) {
that.countDown = countDownSeconds var countDownSeconds = 3
countDownSeconds-- that.countDown = countDownSeconds
} else { this.timer = setInterval(() => {
clearInterval(timer) if (countDownSeconds > 0) {
that.handleClose() that.countDown = countDownSeconds
} countDownSeconds--
}, 1000) } else {
}, clearInterval(that.timer)
handleClose() { that.handleAd()
this.$refs.adPop.close('center'); }
this.$emit('close'); }, 1000)
}, },
onload(e) { handleAd() {
console.log("onload"); clearInterval(this.timer)
}, // this.$refs.adPop.close('center');
onclose(e) { this.$emit('handleAd');
console.log("onclose: " + e.detail); },
}, handleVip() {
onerror(e) { clearInterval(this.timer)
console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg); this.$refs.adPop.close('center');
} this.$emit('handleVip');
}, },
watch: { onClose() {
show: { clearInterval(this.timer)
handler: function(newVal, oldVal) { this.$refs.adPop.close('center');
if (newVal) { this.$emit('handleClose');
this.handleShow(); },
} onload(e) {
}, console.log("onload");
immediate: true },
} onclose(e) {
} console.log("onclose: " + e.detail);
}; },
</script> onerror(e) {
console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg);
<style lang="scss"> }
.container { },
width: 600rpx; watch: {
height: 800rpx; show: {
position: relative; handler: function(newVal, oldVal) {
display: flex; if (newVal) {
flex-direction: column; this.handleShow();
justify-content: center; } else {
} clearInterval(this.timer)
this.$refs.adPop.close('center');
.ad-view { }
width: 600rpx; },
border-radius: 20rpx; immediate: true
// background-color: white; }
margin-bottom: 10px; }
} };
</script>
.content {
border-radius: 20rpx; <style lang="scss">
background-color: white; .container {
display: flex; width: 600rpx;
width: 600rpx; height: 800rpx;
padding: 30rpx 0; position: relative;
flex-direction: column; display: flex;
align-items: center; flex-direction: column;
justify-content: center;
.title { }
color: black;
font-size: 40rpx; .ad-view {
font-weight: bold; width: 600rpx;
margin-bottom: 30rpx; border-radius: 20rpx;
} // background-color: white;
margin-bottom: 10px;
.button { }
margin: 20rpx 20rpx;
border-radius: 10rpx; .content {
background-color: orange; border-radius: 20rpx;
color: white; 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;
}
.button1 {
width: 500rpx;
height: 66rpx;
line-height: 66rpx;
text-align: center;
margin: 20rpx 20rpx;
border-radius: 10rpx;
background-color: orange;
color: white;
font-size: 36rpx; font-size: 36rpx;
} box-shadow: 0 0 2px 0px rgba(255, 255, 255, 0.1);
}
.downtext{
color: darkgray; .button2 {
font-size: 26rpx; 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 {
color: darkgray;
font-size: 26rpx;
}
}
</style> </style>
\ No newline at end of file
...@@ -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';
...@@ -133,8 +137,8 @@ ...@@ -133,8 +137,8 @@
showTap: false, showTap: false,
showCoinPop: false, showCoinPop: false,
showSignPop: false, showSignPop: false,
showAdPop: false, showAdPop: false,
showAdForServer: false, showAdMorePop: false,
vipBackPage: '', vipBackPage: '',
curTimeData: '', curTimeData: '',
localTimeData: '', localTimeData: '',
...@@ -178,18 +182,18 @@ ...@@ -178,18 +182,18 @@
}); });
} }
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;
} // }
}); // });
}, },
// 分享 // 分享
// onShareAppMessage() { // onShareAppMessage() {
// let result = { // let result = {
...@@ -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.showCoinPop = false
setTimeout(() => {
this.showAdPop = true this.showAdPop = true
} else { }, 500)
this.showCoinPop = false
}
}, },
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