Commit 6f2a1424 authored by 王炽's avatar 王炽

首页图层效果处理

parent 43d6d708
...@@ -94,8 +94,9 @@ ...@@ -94,8 +94,9 @@
left: 50%; left: 50%;
top: 15rpx; top: 15rpx;
transform: translateX(-50%); transform: translateX(-50%);
width: 96%; width: 100%;
height: 86%; height: 100%;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.2);
} }
} }
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
<view class="item_cangguan_img1" <view class="item_cangguan_img1"
:style="`background-image: url(${item.imgUrl}); background-size: 707rpx auto; background-repeat: no-repeat;`" :style="`background-image: url(${item.imgUrl}); background-size: 707rpx auto; background-repeat: no-repeat;`"
mode="widthFix"> mode="widthFix">
<image class="item_cangguan_img" :src="`${item.imgUrl}`" mode="widthFix"></image> <image class="item_cangguan_img" :src="`${item.imgUrl}`" mode="widthFix" @load="(e) => handleImageLoad(e, item, index)"></image>
<!-- <image class="item_cangguan_img_up" :src="`${item.imgUrl}`" mode="aspectFill"></image> --> <image class="item_cangguan_img_up" :src="`${item.imgUrl}`" mode="aspectFill" :style="`width: ${item.targetWidth - 30}rpx; height: ${item.targetHeight - 126}rpx;`"></image>
</view> </view>
<view class="item_cangguan_bottom"> <view class="item_cangguan_bottom">
...@@ -302,21 +302,16 @@ const handleScrollToLower_shoucang = async () => { ...@@ -302,21 +302,16 @@ const handleScrollToLower_shoucang = async () => {
const handleImageLoad = (e, item, index) => { const handleImageLoad = (e, item, index) => {
// 获取图片的实际尺寸 // 获取图片的实际尺寸
const { width, height } = e.detail; const { width, height } = e.detail;
console.log('width=', width);
console.log('height=', height);
// 计算图片在360rpx宽度下的实际高度 // 计算图片在360rpx宽度下的实际高度
// 360rpx 转换为 px (假设 1rpx = 0.5px,根据实际设备调整) // 360rpx 转换为 px (假设 1rpx = 0.5px,根据实际设备调整)
const rpxToPx = 0.5; const targetWidth = 707;
const targetWidth = 360 * rpxToPx; const rpxToPx = targetWidth / width;
const scale = targetWidth / width; const targetHeight = height * rpxToPx;
const scaledHeight = height * scale;
// 设置列表项的高度(图片高度 + 其他内容高度) item.targetWidth = targetWidth;
// 这里可以根据实际需要调整其他内容的高度 item.targetHeight = targetHeight;
const otherContentHeight = 120; // 其他内容的预估高度
item.itemHeight = scaledHeight + otherContentHeight;
console.log(`图片 ${index} 加载完成,设置高度为: ${item.itemHeight}px`); console.log(`图片 ${index} 加载完成,设置宽度为: ${item.targetWidth}px, 设置高度为:${item.targetHeight}px`);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment