顶部吸附

parent 2ee28736
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
></search> ></search>
<view class="head"> <view class="head">
<view class="top" :style="{ backgroundImage: topBg }"></view> <view class="top" :style="{ backgroundImage: topBg }"></view>
<view class="bootom"> <view class="bootom" :style="{ top }">
<view class="bootom-top"> <view class="bootom-top">
<view class="option" @tap="locationFiltering(0)"> <view class="option" @tap="locationFiltering(0)">
<text :class="{ rotate: rotate }">全部烧烤烤肉</text> <text :class="{ rotate: rotate }">全部烧烤烤肉</text>
...@@ -98,6 +98,7 @@ const cardData = ref([]); ...@@ -98,6 +98,7 @@ const cardData = ref([]);
const backgroundBox = ref(''); const backgroundBox = ref('');
const backIcon = ref('white'); const backIcon = ref('white');
const title = ref(''); const title = ref('');
const top = ref(null);
let total; let total;
const paramsId = { const paramsId = {
parentId: null, parentId: null,
...@@ -116,11 +117,20 @@ onLoad((options) => { ...@@ -116,11 +117,20 @@ onLoad((options) => {
const { categoryId, place } = options; const { categoryId, place } = options;
paramsId.parentId = categoryId; paramsId.parentId = categoryId;
getByParentIdData(); getByParentIdData();
getTop();
getByType({ place }).then((res) => { getByType({ place }).then((res) => {
topBg.value = `url(${import.meta.env.VITE_APP_IMG_URL + res.data[0].imgUrl})`; topBg.value = `url(${import.meta.env.VITE_APP_IMG_URL + res.data[0].imgUrl})`;
}); });
}); });
// 获取位置板块贴合高度
const getTop = () => {
xma.xh.getMenuButtonBoundingClientRect({
success(res) {
top.value = (res.top + res.bottom) / 2 + 25 + 'px';
},
});
};
const refresh = () => { const refresh = () => {
delete listParams.distance; delete listParams.distance;
delete listParams.area; delete listParams.area;
...@@ -295,7 +305,7 @@ page { ...@@ -295,7 +305,7 @@ page {
justify-content: space-around; justify-content: space-around;
border-radius: 6rpx; border-radius: 6rpx;
background: #ffffff; background: #ffffff;
position: relative; position: sticky;
.bootom-top { .bootom-top {
display: flex; display: flex;
align-items: center; align-items: center;
......
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