|
@@ -1,9 +1,10 @@
|
|
|
<template>
|
|
|
<van-image
|
|
|
v-show="adShow"
|
|
|
- class="reveal-box"
|
|
|
- :class="{ radius: radius }"
|
|
|
+ v-if="adIfShow"
|
|
|
:id="getConfig.id"
|
|
|
+ class="reveal-box"
|
|
|
+ :class="{ radius }"
|
|
|
:src="getConfig.pic"
|
|
|
:alt="getConfig.name"
|
|
|
:style="getStyle"
|
|
@@ -18,12 +19,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { Image, Icon } from 'vant'
|
|
|
+import { Icon, Image } from 'vant'
|
|
|
import { adConfigFormatter, openLinkOfAd, px2viewport } from '@/utils'
|
|
|
import { ajaxGetAD } from '@/api/modules'
|
|
|
|
|
|
export default {
|
|
|
- name: 'ad-single',
|
|
|
+ name: 'AdSingle',
|
|
|
components: {
|
|
|
[Icon.name]: Icon,
|
|
|
[Image.name]: Image
|
|
@@ -80,8 +81,19 @@ export default {
|
|
|
info: {}
|
|
|
}),
|
|
|
computed: {
|
|
|
+ hasPic() {
|
|
|
+ return this.getConfig && this.getConfig.pic
|
|
|
+ },
|
|
|
adShow() {
|
|
|
- return this.show && this.loaded
|
|
|
+ return this.show && this.loaded && this.hasPic
|
|
|
+ },
|
|
|
+ adIfShow() {
|
|
|
+ // 没加载前v-if=true,v-show=false。
|
|
|
+ if (this.loaded) {
|
|
|
+ return this.adShow
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
},
|
|
|
getStyle() {
|
|
|
return {
|
|
@@ -102,6 +114,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
+ window.t = this
|
|
|
if (this.ad) {
|
|
|
this.getAD([this.ad])
|
|
|
}
|