mahjong_group/components/com/page/home-ad-popup.vue
2025-10-08 19:17:42 +08:00

55 lines
1.2 KiB
Vue

<template>
<up-popup v-model:show="show" mode="center" bgColor="transparent" :closeable="true" :overlay="true" :safeAreaInsetBottom="false">
<view class="popup-content" @click.stop>
<image v-if="popup && popup.image" class="popup-image" :src="popup.image" mode="widthFix"></image>
</view>
</up-popup>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { getPopupConfig, getConfigData, getPopupShow } from '@/common/server/config';
const show = ref(false);
const popup = ref(null);
const shouldShowOncePerLaunch = () => {
try {
const app = getApp();
if (!app || !app.globalData) return true;
if (app.globalData.hasShownHomeAd) return false;
app.globalData.hasShownHomeAd = true;
return true;
} catch (e) {
return true;
}
};
const init = async () => {
await getConfigData();
popup.value = await getPopupConfig();
if (popup.value && popup.value.image && getPopupShow.value) {
show.value = true;
getPopupShow.value = false;
}
};
onMounted(async () => {
await init();
});
</script>
<style scoped>
.popup-content {
max-width: 640rpx;
max-height: 80vh;
padding: 0;
}
.popup-image {
width: 640rpx;
border-radius: 16rpx;
display: block;
}
</style>