hookehuyr

refactor(广告组件): 移除动态广告配置改为使用静态配置

将广告组件从接收props动态配置改为使用组件内部静态配置
删除Dashboard和Welcome页面中不再需要的广告数据逻辑
......@@ -10,7 +10,7 @@
<!-- 广告图片 -->
<view class="ad-image-container" @click="handleAdClick">
<image
:src="adImageUrl"
:src="adConfig.adImageUrl"
mode="aspectFill"
class="ad-image"
alt="广告图片"
......@@ -31,24 +31,15 @@ import { ref, onMounted } from 'vue'
import Taro from '@tarojs/taro'
import { Close } from '@nutui/icons-vue-taro'
// Props
const props = defineProps({
// TODO: Mock数据配置, 等待正式接口
const adConfig = {
// 广告图片URL
adImageUrl: {
type: String,
default: ''
},
adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg',
// 点击跳转的页面路径
targetPage: {
type: String,
default: '/pages/Dashboard/index'
},
targetPage: '/pages/Dashboard/index',
// 存储键名(用于区分不同的广告)
storageKey: {
type: String,
default: 'ad_overlay_shown'
}
})
storageKey: 'dashboard_ad_overlay'
}
// Emits
const emit = defineEmits(['close', 'click'])
......@@ -74,7 +65,7 @@ const getTodayDateString = () => {
*/
const hasShownToday = () => {
try {
const lastShownDate = Taro.getStorageSync(props.storageKey)
const lastShownDate = Taro.getStorageSync(adConfig.storageKey)
const today = getTodayDateString()
return lastShownDate === today
} catch (error) {
......@@ -89,7 +80,7 @@ const hasShownToday = () => {
const markAsShownToday = () => {
try {
const today = getTodayDateString()
Taro.setStorageSync(props.storageKey, today)
Taro.setStorageSync(adConfig.storageKey, today)
} catch (error) {
console.error('保存存储数据失败:', error)
}
......@@ -123,7 +114,7 @@ const handleAdClick = () => {
// 跳转到目标页面
// Taro.navigateTo({
// url: props.targetPage
// url: adConfig.targetPage
// }).catch(error => {
// console.error('页面跳转失败:', error)
// Taro.showToast({
......@@ -133,7 +124,7 @@ const handleAdClick = () => {
// })
// 触发点击事件
emit('click', props.targetPage)
emit('click', adConfig.targetPage)
}
/**
......
......@@ -145,9 +145,6 @@
<!-- 广告遮罩层 -->
<AdOverlay
ref="adOverlayRef"
:ad-image-url="adObj.adImageUrl"
:target-page="adObj.targetPage"
:storage-key="adObj.storageKey"
@close="handleAdClose"
@click="handleAdClick"
/>
......@@ -190,7 +187,7 @@ const familyCover = ref('')
const familyOwner = ref(false);
// 广告遮罩层数据
const adObj = ref({})
const adOverlayRef = ref(null)
/**
......@@ -401,15 +398,6 @@ useDidShow(async () => {
if (familyAlbumRef.value) {
familyAlbumRef.value.refreshData();
}
// TODO: 获取广告信息
if (!adOverlayRef.value.hasShownToday()) {
adObj.value = {
adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg',
targetPage: '/pages/Dashboard/index',
storageKey: 'dashboard_ad_overlay',
}
}
})
useReady(async () => {
......
<!--
* @Date: 2025-08-27 17:43:45
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-13 01:40:20
* @LastEditTime: 2025-09-13 08:58:04
* @FilePath: /lls_program/src/pages/Welcome/index.vue
* @Description: 文件描述
-->
......@@ -136,9 +136,6 @@
<!-- 广告遮罩层 -->
<AdOverlay
ref="adOverlayRef"
:ad-image-url="adObj.adImageUrl"
:target-page="adObj.targetPage"
:storage-key="adObj.storageKey"
@close="handleAdClose"
@click="handleAdClick"
/>
......@@ -175,7 +172,7 @@ const navigateTo = (url) => {
};
// 广告遮罩层数据
const adObj = ref({})
const adOverlayRef = ref(null)
/**
......@@ -218,15 +215,6 @@ useDidShow(async () => {
hasProfile.value = userInfo.value.nickname && userInfo.value.birth_date && userInfo.value.wheelchair_needed !== null;
userAge.value = userInfo.value.birthday;
}
// TODO: 获取广告信息
if (!adOverlayRef.value.hasShownToday()) {
adObj.value = {
adImageUrl: 'https://cdn.ipadbiz.cn/lls_prog/images/%E5%8D%97%E4%BA%AC%E8%B7%AF%E5%95%86%E5%9C%88.jpeg',
targetPage: '/pages/Dashboard/index',
storageKey: 'dashboard_ad_overlay',
}
}
});
const handleNavigate = (url) => {
......