Commit 0d03a35e authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 3abfe355
......@@ -97,7 +97,7 @@
versionName: 'v 1.0.0',
auth: false, // 三要素实名认证
userInfo: null,
pkgName: 'com.mints.dybrightvideo'
pkgName: 'com.mints.dyminivideo'
}
};
</script>
......
<template>
<view>
<uni-popup type="center" ref="adPop" :maskClick="false" :isMaskClick="false">
<view class="container">
<!-- <view class="ad-view">
<ad :unit-id="adUnitId" @load="onload" @close="onclose" @error="onerror"></ad>
</view> -->
<view class="content">
<text class="title">恭喜你,获得免费看剧名额</text>
<text class="button" @click="handleClose">看视频免费解锁1集</text>
<text class="downtext">{{countDown+'s后自动进入广告页面解锁后续'}}</text>
</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 {
adUnitId: EXPRESS_ID,
countDown: 3,
};
},
methods: {
handleShow() {
this.$refs.adPop.open('center');
this.startCountdown()
},
startCountdown() {
let that = this;
var countDownSeconds = 3
that.countDown = countDownSeconds
const timer = setInterval(() => {
if (countDownSeconds > 0) {
that.countDown = countDownSeconds
countDownSeconds--
} else {
clearInterval(timer)
that.handleClose()
}
}, 1000)
},
handleClose() {
this.$refs.adPop.close('center');
this.$emit('close');
},
onload(e) {
console.log("onload");
},
onclose(e) {
console.log("onclose: " + e.detail);
},
onerror(e) {
console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg);
}
},
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;
}
.ad-view {
width: 600rpx;
border-radius: 20rpx;
// background-color: white;
margin-bottom: 10px;
}
.content {
border-radius: 20rpx;
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;
}
.button {
margin: 20rpx 20rpx;
border-radius: 10rpx;
background-color: orange;
color: white;
font-size: 36rpx;
<template>
<view>
<uni-popup type="center" ref="adPop" :maskClick="false" :isMaskClick="false">
<view class="container">
<!-- <view class="ad-view">
<ad :unit-id="adUnitId" @load="onload" @close="onclose" @error="onerror"></ad>
</view> -->
<view class="content">
<text class="title">恭喜你,获得免费看剧名额</text>
<text class="button" @click="handleClose">看视频免费解锁1集</text>
<text class="downtext">{{countDown}}s后自动进入广告,观看完成解锁第{{vedioIndex+1}}集剧情</text>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import {
EXPRESS_ID
} from "@/utils/adConstant.js"
export default {
name: 'adPopup',
props: {
show: {
type: Boolean,
default: false,
},
vedioIndex: {
type: [Number, String],
default: 0
}
},
data() {
return {
adUnitId: EXPRESS_ID,
countDown: 3,
};
},
methods: {
handleShow() {
this.$refs.adPop.open('center');
this.startCountdown()
},
startCountdown() {
let that = this;
var countDownSeconds = 3
that.countDown = countDownSeconds
const timer = setInterval(() => {
if (countDownSeconds > 0) {
that.countDown = countDownSeconds
countDownSeconds--
} else {
clearInterval(timer)
that.handleClose()
}
}, 1000)
},
handleClose() {
this.$refs.adPop.close('center');
this.$emit('close');
},
onload(e) {
console.log("onload");
},
onclose(e) {
console.log("onclose: " + e.detail);
},
onerror(e) {
console.log("onerror: " + e.detail.errCode + " message:: " + e.detail.errMsg);
}
},
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;
}
.ad-view {
width: 600rpx;
border-radius: 20rpx;
// background-color: white;
margin-bottom: 10px;
}
.content {
border-radius: 20rpx;
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;
}
.button {
margin: 20rpx 20rpx;
border-radius: 10rpx;
background-color: orange;
color: white;
font-size: 36rpx;
}
.downtext{
color: darkgray;
font-size: 26rpx;
}
}
}
}
</style>
\ No newline at end of file
......@@ -175,11 +175,11 @@
},
handleAgree() {
this.agreeFlag = true
},
handleClickClose() {
this.$refs.coinPop.close('bottom');
this.$emit('clickClose');
this.$emit('close');
},
handleClickClose() {
this.$refs.coinPop.close('bottom');
this.$emit('clickClose');
this.$emit('close');
},
handleClose() {
this.$refs.coinPop.close('bottom');
......@@ -243,15 +243,20 @@
return
}
tt.getOrderPayment({
orderId: oid,
imId: ttData.imId,
success(res) {
that.queryOrderStatus(largeType, ttData.tidStr);
},
fail(res) {
message.notify(res.errMsg);
},
if (ttData.imId == null) {
message.notify('暂不支付ios支付,请更换设备');
return
}
tt.getOrderPayment({
orderId: oid,
imId: ttData.imId,
success(res) {
that.queryOrderStatus(largeType, ttData.tidStr);
},
fail(res) {
message.notify(res.errMsg);
},
});
} else {
tt.getOrderPayment({
......@@ -260,7 +265,7 @@
that.queryOrderStatus(largeType, ttData.tidStr);
},
fail(res) {
message.notify(res.errMsg);
// message.notify(res.errMsg);
},
});
}
......
......@@ -68,7 +68,7 @@
:originIndex="originIndex" />
<coin-popup :show="showCoinPop" :point="data.point" :vedioId="data.vedioId" @close="showCoinPop = false"
@clickClose="coinPopupClose" @paySuccess="paySuccess" />
<ad-popup :show="showAdPop" @close="adPopupClose" />
<ad-popup :show="showAdPop" @close="adPopupClose" :vedioIndex="originIndex" />
</view>
</template>
......@@ -129,6 +129,7 @@
showTap: false,
showCoinPop: false,
showAdPop: false,
showAdForServer: false,
vipBackPage: '',
canUseTTPlayer: true,
};
......@@ -168,6 +169,16 @@
});
}
this.post({
url: '/vedio/confs',
showLoading: false,
success: ({
data
}) => {
this.showAdForServer = data.douyinAdTipOpen;
}
});
},
// 分享
// onShareAppMessage() {
......@@ -444,9 +455,6 @@
this.isqp = e.detail.show
},
collect(vedioId, index) {
this.showAdPop = true
return
this.data.collect = 1
// 收藏
this.post({
......@@ -489,7 +497,7 @@
}) => {}
});
},
preloadAd() {
preloadAd() {
let that = this
// 创建实例
this.ad = tt.createRewardedVideoAd({
......@@ -509,15 +517,15 @@
break;
default:
// 更多请参考错误码文档
}
that.$nextTick(() => {
// 延迟渲染,否则位置错乱
that.showCoinPop = true
}
that.$nextTick(() => {
// 延迟渲染,否则位置错乱
that.showCoinPop = true
})
});
// 监听视频播放完成
this.ad.onClose((data) => {
uni.hideLoading();
......@@ -529,11 +537,11 @@
} else {
uni.showToast({
title: "未观看完整视频"
})
that.$nextTick(() => {
// 延迟渲染,否则位置错乱
that.showCoinPop = true
})
that.$nextTick(() => {
// 延迟渲染,否则位置错乱
that.showCoinPop = true
})
}
});
......@@ -546,16 +554,20 @@
this.ad.load();
},
coinPopupClose() {
this.showAdPop = true
if (this.showAdForServer) {
this.showAdPop = true
} else {
this.showCoinPop = false
}
},
adPopupClose() {
this.showAdPop = false
this.playRewardVideo()
},
playRewardVideo() {
// 播放激励视频
uni.showLoading({
title: '广告加载中'
// 播放激励视频
uni.showLoading({
title: '广告加载中'
});
this.ad.show();
},
......
export const EXPRESS_ID = 'q1031ievmv1z3j28gs'
export const REWARD_ID = 'm1qtdoeeqq9txgahk4'
\ No newline at end of file
export const REWARD_ID = 'jgv3yh3ma725kbclev'
\ No newline at end of file
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