Commit 859199c583bbdc777342283ad755b5aed12aa24f
Merge branch 'ft-dev' into 'main'
feat:新增意见反馈接口,摄像头接口等 See merge request huang/thingskit-app!17
Showing
1 changed file
with
0 additions
and
139 deletions
Too many changes to show.
To preserve performance only 1 of 39 files are displayed.
components/module/f-ad/f-ad.vue
deleted
100644 → 0
1 | -<template> | |
2 | - <view> | |
3 | - <!-- #ifdef MP-WEIXIN --> | |
4 | - <view class="adContent"> | |
5 | - <block v-for="(item,index) in typeArr" :key="index"> | |
6 | - <block v-if="item===1"> | |
7 | - <!-- banner广告 --> | |
8 | - <ad unit-id="adunit-ecdb31747eeb025d" ad-intervals="30"></ad> | |
9 | - </block> | |
10 | - <block v-if="item===2"> | |
11 | - <!-- 视频广告 --> | |
12 | - <ad unit-id="adunit-3e70c6aaf0d18a5c" ad-type="video" ad-theme="white"></ad> | |
13 | - </block> | |
14 | - <block v-if="item===3"> | |
15 | - <!-- 原生模板广告 --> | |
16 | - <ad-custom unit-id="adunit-ce4c3aa5a5a8aea3"></ad-custom> | |
17 | - </block> | |
18 | - </block> | |
19 | - </view> | |
20 | - <!-- #endif --> | |
21 | - </view> | |
22 | -</template> | |
23 | - | |
24 | -<script> | |
25 | -import { mapState, mapMutations } from 'vuex'; | |
26 | -let rewardedVideoAd = null // 定义激励视频广告 | |
27 | -let insertScreenVideoAd = null // 定义插屏视频广告 | |
28 | -export default { | |
29 | - props:{ | |
30 | - //1.banner广告 2.视频广告 3.原生模板广告 4.插屏视频广告 5.激励视频广告 | |
31 | - typeArray:{ | |
32 | - type: Array, | |
33 | - default: function() { | |
34 | - return []; | |
35 | - }, | |
36 | - } | |
37 | - }, | |
38 | - data() { | |
39 | - return { | |
40 | - _isExcitationLoaded:false, //激励广告是否加载好 | |
41 | - _isInsertScreenLoaded:false,//插屏广告是否加载好 | |
42 | - typeArr:[1] | |
43 | - }; | |
44 | - }, | |
45 | - created() { | |
46 | - // #ifdef MP-WEIXIN | |
47 | - this.typeArr = this.typeArray | |
48 | - this.typeArr.forEach(item=>{ | |
49 | - if(item===5){ | |
50 | - this.excitationAd('adunit-fb0093bcd1f2f790') //激励 | |
51 | - }else if(item===4){ | |
52 | - this.insertScreenAd('adunit-9d97cc3babda47e5') //插屏 | |
53 | - } | |
54 | - }) | |
55 | - // #endif | |
56 | - }, | |
57 | - mounted(e) { | |
58 | - | |
59 | - }, | |
60 | - //方法 | |
61 | - methods: { | |
62 | - // 激励广告 | |
63 | - excitationAd(adUnitId){ | |
64 | - this._isExcitationLoaded = false | |
65 | - // 在页面onLoad回调事件中创建激励视频广告实例 | |
66 | - if (uni.createRewardedVideoAd) { | |
67 | - rewardedVideoAd = uni.createRewardedVideoAd({ | |
68 | - adUnitId: adUnitId | |
69 | - }) | |
70 | - rewardedVideoAd.onLoad(() => { | |
71 | - this._isExcitationLoaded = true | |
72 | - }) | |
73 | - rewardedVideoAd.onError((err) => {}) | |
74 | - rewardedVideoAd.onClose((res) => { | |
75 | - // 用户点击了【关闭广告】按钮 | |
76 | - if (res && res.isEnded) { | |
77 | - // 正常播放结束,可以下发游戏奖励 | |
78 | - this.$emit('excitationAdCallback',1) | |
79 | - } else { | |
80 | - // 播放中途退出,不下发游戏奖励 | |
81 | - this.$emit('excitationAdCallback',2) | |
82 | - } | |
83 | - }) | |
84 | - } | |
85 | - }, | |
86 | - // 显示激励广告 | |
87 | - showExcitationAd(){ | |
88 | - if (this._isExcitationLoaded) { | |
89 | - rewardedVideoAd.show().catch(() => { | |
90 | - // 失败重试 | |
91 | - rewardedVideoAd.load() | |
92 | - .then(() => rewardedVideoAd.show()) | |
93 | - .catch(err => { | |
94 | - console.log('激励视频 广告显示失败') | |
95 | - }) | |
96 | - }) | |
97 | - } | |
98 | - }, | |
99 | - // 插屏广告 | |
100 | - insertScreenAd(adUnitId){ | |
101 | - this._isInsertScreenLoaded = false | |
102 | - // 在页面onLoad回调事件中创建激励视频广告实例 | |
103 | - if (uni.createInterstitialAd) { | |
104 | - insertScreenVideoAd = uni.createInterstitialAd({ | |
105 | - adUnitId: adUnitId | |
106 | - }) | |
107 | - insertScreenVideoAd.onLoad(() => { | |
108 | - this._isInsertScreenLoaded = true | |
109 | - console.log('插屏广告加载完') | |
110 | - this.showInsertScreenAd() | |
111 | - }) | |
112 | - insertScreenVideoAd.onError((err) => { | |
113 | - console.log(err,'插屏广告拉取失败') | |
114 | - }) | |
115 | - insertScreenVideoAd.onClose((res) => { | |
116 | - console.log('插屏广告关闭') | |
117 | - }) | |
118 | - } | |
119 | - }, | |
120 | - // 显示插屏广告 | |
121 | - showInsertScreenAd(){ | |
122 | - console.log('显示插屏广告') | |
123 | - if (this._isInsertScreenLoaded) { | |
124 | - insertScreenVideoAd.show().catch((err) => { | |
125 | - console.error(err,'插屏广告显示失败') | |
126 | - }) | |
127 | - } | |
128 | - } | |
129 | - | |
130 | - | |
131 | - | |
132 | - } | |
133 | -}; | |
134 | -</script> | |
135 | -<style lang="scss" scoped> | |
136 | -.adContent{ | |
137 | - width: 100%; | |
138 | -} | |
139 | -</style> |