hookehuyr

refactor(AdOverlay): 移除滚动容器并优化关闭按钮样式

将广告图片容器从 scroll-view 改为普通 view 以简化结构
调整关闭按钮位置和样式,增加背景模糊效果
...@@ -7,10 +7,9 @@ ...@@ -7,10 +7,9 @@
7 > 7 >
8 <view class="overlay-body"> 8 <view class="overlay-body">
9 <view class="overlay-content"> 9 <view class="overlay-content">
10 - <!-- 广告图片容器 - 支持滚动 --> 10 + <!-- 广告图片容器 -->
11 - <scroll-view 11 + <view
12 - class="ad-scroll-container" 12 + class="ad-image-container"
13 - scroll-y
14 @tap="handleAdClick" 13 @tap="handleAdClick"
15 > 14 >
16 <image 15 <image
...@@ -19,11 +18,11 @@ ...@@ -19,11 +18,11 @@
19 class="ad-image" 18 class="ad-image"
20 alt="广告图片" 19 alt="广告图片"
21 /> 20 />
22 - </scroll-view> 21 + </view>
23 22
24 <!-- 关闭按钮 --> 23 <!-- 关闭按钮 -->
25 <view class="close-button" @tap="handleClose"> 24 <view class="close-button" @tap="handleClose">
26 - <Close size="24" class="close-icon" /> 25 + <Close size="16" class="close-icon" />
27 </view> 26 </view>
28 </view> 27 </view>
29 </view> 28 </view>
...@@ -52,6 +51,7 @@ const emit = defineEmits(['close', 'click']) ...@@ -52,6 +51,7 @@ const emit = defineEmits(['close', 'click'])
52 51
53 // 响应式数据 52 // 响应式数据
54 const visible = ref(false) 53 const visible = ref(false)
54 +const showCloseButton = ref(true)
55 55
56 /** 56 /**
57 * 获取今天的日期字符串(YYYY-MM-DD格式) 57 * 获取今天的日期字符串(YYYY-MM-DD格式)
...@@ -194,6 +194,7 @@ onMounted(async () => { ...@@ -194,6 +194,7 @@ onMounted(async () => {
194 justify-content: center; 194 justify-content: center;
195 padding: 40rpx; 195 padding: 40rpx;
196 box-sizing: border-box; 196 box-sizing: border-box;
197 + position: relative;
197 } 198 }
198 199
199 .overlay-content { 200 .overlay-content {
...@@ -204,46 +205,46 @@ onMounted(async () => { ...@@ -204,46 +205,46 @@ onMounted(async () => {
204 width: 80vw; 205 width: 80vw;
205 max-width: 600rpx; 206 max-width: 600rpx;
206 height: 100%; 207 height: 100%;
207 - max-height: calc(100vh - 80rpx); 208 + position: relative;
208 } 209 }
209 210
210 -.ad-scroll-container { 211 +.ad-image-container {
211 width: 100%; 212 width: 100%;
212 - max-height: calc(100vh - 200rpx); // 预留关闭按钮和间距的空间
213 border-radius: 16rpx; 213 border-radius: 16rpx;
214 overflow: hidden; 214 overflow: hidden;
215 box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.3); 215 box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.3);
216 cursor: pointer; 216 cursor: pointer;
217 - margin-bottom: 40rpx; 217 + position: relative;
218 - // 移除背景色,避免白边
219 - // background-color: #fff;
220 } 218 }
221 219
222 .ad-image { 220 .ad-image {
223 width: 100%; 221 width: 100%;
224 display: block; 222 display: block;
225 - min-height: 200rpx; // 设置最小高度 223 + min-height: 200rpx;
226 - // 移除图片的圆角,让容器的圆角生效
227 border-radius: 16rpx; 224 border-radius: 16rpx;
228 - // 确保图片完全填充容器
229 object-fit: cover; 225 object-fit: cover;
230 - // 移除可能的边距和边框
231 margin: 0; 226 margin: 0;
232 padding: 0; 227 padding: 0;
233 border: none; 228 border: none;
234 - // 确保图片垂直对齐
235 vertical-align: top; 229 vertical-align: top;
236 } 230 }
237 231
238 .close-button { 232 .close-button {
239 - width: 60rpx; 233 + position: fixed;
240 - height: 60rpx; 234 + bottom: 60rpx;
235 + left: 50%;
236 + transform: translateX(-50%);
237 + width: 80rpx;
238 + height: 80rpx;
239 + background-color: rgba(0, 0, 0, 0.6);
241 border-radius: 50%; 240 border-radius: 50%;
242 display: flex; 241 display: flex;
243 align-items: center; 242 align-items: center;
244 justify-content: center; 243 justify-content: center;
244 + z-index: 1001;
245 + backdrop-filter: blur(10rpx);
245 cursor: pointer; 246 cursor: pointer;
246 - flex-shrink: 0; // 防止被压缩 247 + flex-shrink: 0;
247 } 248 }
248 249
249 .close-icon { 250 .close-icon {
...@@ -251,7 +252,7 @@ onMounted(async () => { ...@@ -251,7 +252,7 @@ onMounted(async () => {
251 } 252 }
252 253
253 /* 点击效果 */ 254 /* 点击效果 */
254 -.ad-scroll-container:active { 255 +.ad-image-container:active {
255 transform: scale(0.98); 256 transform: scale(0.98);
256 transition: transform 0.1s ease; 257 transition: transform 0.1s ease;
257 } 258 }
......