feat(AdOverlay): 将广告图片容器改为可滚动视图并优化样式
将静态广告图片容器替换为可垂直滚动的scroll-view,优化图片显示模式为widthFix 调整布局样式,包括高度、间距和图片容器样式,提升用户体验
Showing
1 changed file
with
30 additions
and
9 deletions
| ... | @@ -7,15 +7,19 @@ | ... | @@ -7,15 +7,19 @@ |
| 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 | - <view class="ad-image-container" @click="handleAdClick"> | 11 | + <scroll-view |
| 12 | + class="ad-scroll-container" | ||
| 13 | + scroll-y | ||
| 14 | + @click="handleAdClick" | ||
| 15 | + > | ||
| 12 | <image | 16 | <image |
| 13 | :src="adConfig.adImageUrl" | 17 | :src="adConfig.adImageUrl" |
| 14 | - mode="aspectFill" | 18 | + mode="widthFix" |
| 15 | class="ad-image" | 19 | class="ad-image" |
| 16 | alt="广告图片" | 20 | alt="广告图片" |
| 17 | /> | 21 | /> |
| 18 | - </view> | 22 | + </scroll-view> |
| 19 | 23 | ||
| 20 | <!-- 关闭按钮 --> | 24 | <!-- 关闭按钮 --> |
| 21 | <view class="close-button" @click="handleClose"> | 25 | <view class="close-button" @click="handleClose"> |
| ... | @@ -185,9 +189,11 @@ onMounted(async () => { | ... | @@ -185,9 +189,11 @@ onMounted(async () => { |
| 185 | <style lang="less"> | 189 | <style lang="less"> |
| 186 | .overlay-body { | 190 | .overlay-body { |
| 187 | display: flex; | 191 | display: flex; |
| 188 | - height: 100%; | 192 | + height: 100vh; |
| 189 | align-items: center; | 193 | align-items: center; |
| 190 | justify-content: center; | 194 | justify-content: center; |
| 195 | + padding: 40rpx; | ||
| 196 | + box-sizing: border-box; | ||
| 191 | } | 197 | } |
| 192 | 198 | ||
| 193 | .overlay-content { | 199 | .overlay-content { |
| ... | @@ -197,33 +203,48 @@ onMounted(async () => { | ... | @@ -197,33 +203,48 @@ onMounted(async () => { |
| 197 | justify-content: center; | 203 | justify-content: center; |
| 198 | width: 80vw; | 204 | width: 80vw; |
| 199 | max-width: 600rpx; | 205 | max-width: 600rpx; |
| 206 | + height: 100%; | ||
| 207 | + max-height: calc(100vh - 80rpx); | ||
| 200 | } | 208 | } |
| 201 | 209 | ||
| 202 | -.ad-image-container { | 210 | +.ad-scroll-container { |
| 203 | width: 100%; | 211 | width: 100%; |
| 212 | + max-height: calc(100vh - 200rpx); // 预留关闭按钮和间距的空间 | ||
| 204 | border-radius: 16rpx; | 213 | border-radius: 16rpx; |
| 205 | overflow: hidden; | 214 | overflow: hidden; |
| 206 | box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.3); | 215 | box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.3); |
| 207 | cursor: pointer; | 216 | cursor: pointer; |
| 208 | margin-bottom: 40rpx; | 217 | margin-bottom: 40rpx; |
| 218 | + // 移除背景色,避免白边 | ||
| 219 | + // background-color: #fff; | ||
| 209 | } | 220 | } |
| 210 | 221 | ||
| 211 | .ad-image { | 222 | .ad-image { |
| 212 | width: 100%; | 223 | width: 100%; |
| 213 | - height: 50vh; | ||
| 214 | display: block; | 224 | display: block; |
| 225 | + min-height: 200rpx; // 设置最小高度 | ||
| 226 | + // 移除图片的圆角,让容器的圆角生效 | ||
| 215 | border-radius: 16rpx; | 227 | border-radius: 16rpx; |
| 228 | + // 确保图片完全填充容器 | ||
| 229 | + object-fit: cover; | ||
| 230 | + // 移除可能的边距和边框 | ||
| 231 | + margin: 0; | ||
| 232 | + padding: 0; | ||
| 233 | + border: none; | ||
| 234 | + // 确保图片垂直对齐 | ||
| 235 | + vertical-align: top; | ||
| 216 | } | 236 | } |
| 217 | 237 | ||
| 218 | .close-button { | 238 | .close-button { |
| 219 | width: 60rpx; | 239 | width: 60rpx; |
| 220 | height: 60rpx; | 240 | height: 60rpx; |
| 221 | - // background-color: rgba(0, 0, 0, 0.6); | ||
| 222 | border-radius: 50%; | 241 | border-radius: 50%; |
| 223 | display: flex; | 242 | display: flex; |
| 224 | align-items: center; | 243 | align-items: center; |
| 225 | justify-content: center; | 244 | justify-content: center; |
| 226 | cursor: pointer; | 245 | cursor: pointer; |
| 246 | + flex-shrink: 0; // 防止被压缩 | ||
| 247 | + background-color: rgba(0, 0, 0, 0.5); | ||
| 227 | } | 248 | } |
| 228 | 249 | ||
| 229 | .close-icon { | 250 | .close-icon { |
| ... | @@ -231,7 +252,7 @@ onMounted(async () => { | ... | @@ -231,7 +252,7 @@ onMounted(async () => { |
| 231 | } | 252 | } |
| 232 | 253 | ||
| 233 | /* 点击效果 */ | 254 | /* 点击效果 */ |
| 234 | -.ad-image-container:active { | 255 | +.ad-scroll-container:active { |
| 235 | transform: scale(0.98); | 256 | transform: scale(0.98); |
| 236 | transition: transform 0.1s ease; | 257 | transition: transform 0.1s ease; |
| 237 | } | 258 | } | ... | ... |
-
Please register or login to post a comment