1. ホーム ページの検索ボックス リストのスクロールを上部に固定する必要があります。 2.
解決策
1. 下部のタブバーは 184px のカスタム高さです。
2. 上部のナビゲーションバーは 44px のカスタム高さです
。 3. 使用します。 uni.getSystemInfo を使用して、マウントされたライフ関数のステータス バーを取得します。高さ
4. 検索ボックスは、position:sticky; スティッキー配置を使用します
。5. 動的スタイルを使用し、上部の高さは、取得したステータス バーの高さ + 44 ピクセルです。
<template>
<view class="content">
<!-- 自定义navbar -->
<u-navbar back-text="首页" :border-bottom="true" back-icon-size="40"
:back-text-style="{ fontWeight: 600 }" height="44"></u-navbar>
<view class="search-wapper" :style="{top: `${statusBarHeight + 44}px`}">
<view class="search">
<u-search placeholder="搜索站点或者设备编号" disabled bg-color="#FFFFFF" @click="getFocus" :show-action="false">
</u-search>
<view class="classify" @click="setScreen">
<u-icon name="list" size="40"></u-icon>
</view>
</view>
</view>
<view class="list">
<view v-for="i in 10" class="item" :key="i">
<view class="item-A">
<view>城南信号塔站 | 中国电信荆州分公司</view>
<view @click="setScreen">
<u-icon name="arrow-right" size="35"></u-icon>
</view>
</view>
<view class="item-B">
系统输出电流:100.1 mA
</view>
<view class="item-C">
<view>铝空剩余容量:85.1%</view>
<view>运行·自动模式</view>
</view>
</view>
</view>
<screen :showModal="screenShow" @close="onclose"></screen>
<tabbar></tabbar>
</view>
</template>
<script>
import tabbar from '../../component/tabbar.vue';
import screen from '../../component/screen.vue'
export default {
components: {
tabbar,
screen,
},
data() {
return {
background: 'transparent',
searchVal: '',
screenShow: false,
statusBarHeight :'',
}
},
onPullDownRefresh() {
console.log('下拉刷新')
},
onReachBottom() {
console.log('触底了')
},
mounted() {
uni.getSystemInfo({
//获取系统信息
success: res => {
this.statusBarHeight = res.statusBarHeight//状态栏的高度
console.log(this.statusBarHeight)
},
fail(err) {
console.log(err);
}
})
},
methods: {
/*点击搜索*/
getFocus() {
console.log('点击搜索框')
uni.navigateTo({
url: '/pages/search-history/index'
})
},
/*点击筛选*/
setScreen() {
console.log('筛选')
this.screenShow = true;
},
/*popup回调*/
onclose(show) {
this.screenShow = show
}
}
}
</script>
<style lang="scss" scoped>
.content {
width: 100vw;
background: #F8FAFF;
box-sizing: border-box;
padding: 0rpx 44rpx 184rpx 46rpx;//底部tabbar高度是184rpx
}
.content /deep/ .u-icon-wrap u-icon {
display: none;
}
.content /deep/ .u-content {
box-shadow: 0px 4px 16px 2px rgba(106, 106, 106, 0.2);
}
.search-wapper {
height: 114rpx;
box-sizing: border-box;
display: flex;
align-items: center;
position: sticky;
background-color: #F8FAFF;
z-index: 100;
}
.search {
width: 100%;
position: relative;
}
.search /deep/ .u-icon-wrap u-icon {
display: inline-block;
}
.classify {
position: absolute;
right: 20rpx;
top: 50%;
transform: translateY(-50%);
z-index: 100;
}
.list {
width: 100%;
box-sizing: border-box;
flex: 1;
.item {
width: 96%;
height: 220rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 16rpx 2rpx rgba(106, 106, 106, 0.2);
border-radius: 36rpx;
margin: 10rpx auto 30rpx;
padding: 30rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #000000;
.item-A {
display: flex;
justify-content: space-between;
align-items: center;
}
.item-B {
}
.item-C {
display: flex;
justify-content: space-between;
align-items: center;
>view {
&:nth-child(2) {
font-weight: 600;
font-size: 24rpx;
color: #21C0D5;
font-size: 24rpx;
}
}
}
}
}
</style>