123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <template>
- <view class="page" :style="{height:windowHeight}">
- <view class="dis j-s a-c" style="padding: 0 10px;">
- <view class="maskTool">
- <text>广告</text>
- <text>丨</text>
- <text v-if="countdownTime>0">观看{{countdownTime}}秒后获得奖励</text>
- <text v-else>已获得奖励</text>
- </view>
- <view class="maskTool1 dis j-s a-c">
- <image :src="isMuted?'../../static/img/volume1.png':'../../static/img/volume2.png'" mode=""
- style="width: 15px;height: 15px;" @click="isMuteds"></image>
- <text>丨</text>
- <!-- #ifdef APP -->
- <text @click="showAlert">关闭</text>
- <!-- #endif -->
- <text @click="showAlert1">关闭</text>
- </view>
- </view>
- <view class="" :style="{width:'100%',height:'calc(100% - 45px)',position: 'relative'}">
- <video id="myVideo" src="../../ad.mp4" autoplay controls :style="{width:'100%',height:'100%'}"
- :controls="true" @play="startCountdown">
- </video>
- </view>
- <u-modal v-model="show" content="暂未获得奖励,是否继续观看视频"></u-modal>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- countdownTime: 30,
- windowHeight: "",
- isMuted: true,
- show: false,
- }
- },
- onShow() {
- // 确保视频元素存在
- this.$nextTick(() => {
- this.video = document.getElementById('myVideo');
- });
- },
- onLoad() {
- const res = uni.getSystemInfoSync();
- this.windowHeight = res.windowHeight + 'px';
- },
- methods: {
- isMuteds() {
- this.isMuted = !this.isMuted;
- this.video.muted = this.isMuted;
- },
- startCountdown() {
- if (this.intervalId) {
- clearInterval(this.intervalId);
- }
- this.intervalId = setInterval(() => {
- if (this.countdownTime > 0) {
- this.countdownTime--;
- } else {
- clearInterval(this.intervalId);
- }
- }, 1000);
- },
- showAlert1() {
- this.show = true;
- },
- showAlert() {
- // 判断plus对象是否存在
- if (plus) {
- // 创建一个提示窗
- plus.nativeUI.alert('这是一个弹窗', function() {});
- } else {
- // 非App环境的处理逻辑
- alert('这是一个浏览器的弹窗');
- }
- }
- },
- beforeDestroy() {
- if (this.intervalId) {
- clearInterval(this.intervalId);
- }
- }
- }
- </script>
- <style>
- page {
- background-color: #000;
- }
- </style>
- <style lang="scss" scoped>
- .page {
- padding-top: 20px;
- background-color: #000;
- }
- .maskTool {
- border: 1px solid #999;
- height: auto;
- color: #fff;
- border-radius: 20px;
- padding: 5px 10px;
- }
- .maskTool1 {
- border: 1px solid #999;
- height: auto;
- color: #fff;
- border-radius: 20px;
- padding: 5px 10px;
- }
- </style>
|