mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 09:08:51 +08:00
chore: 🚀 更新微信ad
This commit is contained in:
parent
3b6c631208
commit
2e124b2d6d
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<wd-config-provider :theme="theme" :theme-vars="isRed ? themeVars : {}">
|
||||
<wd-toast />
|
||||
<view class="page-wraper">
|
||||
<wd-cell title="切换暗黑" title-width="240px" center v-if="showDarkMode">
|
||||
<wd-switch v-model="isDark" />
|
||||
@ -9,9 +8,22 @@
|
||||
<wd-switch v-model="isRed" />
|
||||
</wd-cell>
|
||||
<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>
|
||||
</view>
|
||||
<wd-notify />
|
||||
<wd-toast />
|
||||
</wd-config-provider>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
@ -24,23 +36,32 @@ export default {
|
||||
}
|
||||
</script>
|
||||
<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 { useDark } from '../../store'
|
||||
|
||||
interface Props {
|
||||
showDarkMode?: boolean
|
||||
safeAreaInsetBottom?: boolean
|
||||
useWxAd?: boolean
|
||||
}
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
showDarkMode: false,
|
||||
safeAreaInsetBottom: true
|
||||
safeAreaInsetBottom: true,
|
||||
useWxAd: process.env.NODE_ENV === 'development' ? false : true
|
||||
})
|
||||
|
||||
const darkMode = useDark()
|
||||
const isDark = 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 = {
|
||||
colorTheme: 'red'
|
||||
@ -56,6 +77,16 @@ onMounted(() => {
|
||||
onClosed: () => console.log('onClosed'),
|
||||
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>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<page-wraper>
|
||||
<page-wraper :use-wx-ad="false">
|
||||
<view class="page">
|
||||
<view class="page__hd">
|
||||
<view class="page__title">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user