chore: 🚀 更新微信ad

This commit is contained in:
不如摸鱼去 2024-11-11 21:13:58 +08:00
parent 3b6c631208
commit 2e124b2d6d
2 changed files with 36 additions and 5 deletions

View File

@ -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>

View File

@ -1,5 +1,5 @@
<template>
<page-wraper>
<page-wraper :use-wx-ad="false">
<view class="page">
<view class="page__hd">
<view class="page__title">