mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-07 01:28:30 +08:00
chore: 🚀 更新微信ad
This commit is contained in:
parent
3b6c631208
commit
2e124b2d6d
@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<wd-config-provider :theme="theme" :theme-vars="isRed ? themeVars : {}">
|
<wd-config-provider :theme="theme" :theme-vars="isRed ? themeVars : {}">
|
||||||
<wd-toast />
|
|
||||||
<view class="page-wraper">
|
<view class="page-wraper">
|
||||||
<wd-cell title="切换暗黑" title-width="240px" center v-if="showDarkMode">
|
<wd-cell title="切换暗黑" title-width="240px" center v-if="showDarkMode">
|
||||||
<wd-switch v-model="isDark" />
|
<wd-switch v-model="isDark" />
|
||||||
@ -9,9 +8,22 @@
|
|||||||
<wd-switch v-model="isRed" />
|
<wd-switch v-model="isRed" />
|
||||||
</wd-cell>
|
</wd-cell>
|
||||||
<slot />
|
<slot />
|
||||||
|
<!-- #ifdef MP-WEIXIN -->
|
||||||
|
<!-- 横幅广告和格子广告可以共存,但插屏广告展示时,不显示横幅广告和格子广告 -->
|
||||||
|
<template v-if="useWxAd && !showWxAd3">
|
||||||
|
<ad-custom v-if="showWxAd" unit-id="adunit-06191d6d3d1ddfc4"></ad-custom>
|
||||||
|
<ad-custom
|
||||||
|
v-if="showWxAd2"
|
||||||
|
style="width: 120rpx; height: auto; position: fixed; right: 12rpx; top: 160rpx; z-index: 999"
|
||||||
|
unit-id="adunit-95aad07aafad3619"
|
||||||
|
></ad-custom>
|
||||||
|
</template>
|
||||||
|
<!-- #endif -->
|
||||||
|
|
||||||
<wd-gap height="0" v-if="safeAreaInsetBottom" safe-area-bottom></wd-gap>
|
<wd-gap height="0" v-if="safeAreaInsetBottom" safe-area-bottom></wd-gap>
|
||||||
</view>
|
</view>
|
||||||
<wd-notify />
|
<wd-notify />
|
||||||
|
<wd-toast />
|
||||||
</wd-config-provider>
|
</wd-config-provider>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@ -24,23 +36,32 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, onMounted } from 'vue'
|
import { computed, ref, onMounted, nextTick } from 'vue'
|
||||||
import { setNotifyDefaultOptions, type ConfigProviderThemeVars } from '@/uni_modules/wot-design-uni'
|
import { setNotifyDefaultOptions, type ConfigProviderThemeVars } from '@/uni_modules/wot-design-uni'
|
||||||
import { useDark } from '../../store'
|
import { useDark } from '../../store'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
showDarkMode?: boolean
|
showDarkMode?: boolean
|
||||||
safeAreaInsetBottom?: boolean
|
safeAreaInsetBottom?: boolean
|
||||||
|
useWxAd?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
showDarkMode: false,
|
showDarkMode: false,
|
||||||
safeAreaInsetBottom: true
|
safeAreaInsetBottom: true,
|
||||||
|
useWxAd: process.env.NODE_ENV === 'development' ? false : true
|
||||||
})
|
})
|
||||||
|
|
||||||
const darkMode = useDark()
|
const darkMode = useDark()
|
||||||
const isDark = ref<boolean>(false)
|
const isDark = ref<boolean>(false)
|
||||||
const isRed = ref<boolean>(false)
|
const isRed = ref<boolean>(false)
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
// 横幅广告和格子广告可以共存,但插屏广告展示时,不显示横幅广告和格子广告
|
||||||
|
const showWxAd = ref<boolean>(Math.random() > 0.5) // 横幅广告
|
||||||
|
const showWxAd2 = ref<boolean>(Math.random() > 0.33) // 格子广告
|
||||||
|
const showWxAd3 = ref<boolean>(Math.random() > 0.66) // 插屏广告
|
||||||
|
let interstitialAd: UniApp.InterstitialAdContext | null = null
|
||||||
|
// #endif
|
||||||
|
|
||||||
const themeVars: ConfigProviderThemeVars = {
|
const themeVars: ConfigProviderThemeVars = {
|
||||||
colorTheme: 'red'
|
colorTheme: 'red'
|
||||||
@ -56,6 +77,16 @@ onMounted(() => {
|
|||||||
onClosed: () => console.log('onClosed'),
|
onClosed: () => console.log('onClosed'),
|
||||||
onOpened: () => console.log('onOpened')
|
onOpened: () => console.log('onOpened')
|
||||||
})
|
})
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
// 微信广告
|
||||||
|
if (uni.createInterstitialAd && showWxAd3.value && props.useWxAd) {
|
||||||
|
interstitialAd = uni.createInterstitialAd({ adUnitId: 'adunit-fc8522e2b1185c89' })
|
||||||
|
nextTick(() => {
|
||||||
|
console.log(interstitialAd)
|
||||||
|
interstitialAd && interstitialAd.show()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<page-wraper>
|
<page-wraper :use-wx-ad="false">
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<view class="page__hd">
|
<view class="page__hd">
|
||||||
<view class="page__title">
|
<view class="page__title">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user