返回顶部组件

This commit is contained in:
2024-01-24 15:49:01 +08:00
parent 927e7cc69a
commit 221dc8d033
5 changed files with 63 additions and 5 deletions

View File

@@ -20,6 +20,6 @@
<style> <style>
/*每个页面公共css */ /*每个页面公共css */
@import '@/common/style/reset.css'; @import '@/common/style/reset.css';
@import '@/common/style/uni.css'; /* @import '@/common/style/uni.css'; */
@import '@/common/style/layout.css'; @import '@/common/style/layout.css';
</style> </style>

View File

@@ -110,8 +110,9 @@ uni-button:after {
top: calc(var(--status-bar-height) + 72rpx); top: calc(var(--status-bar-height) + 72rpx);
width: 100%; width: 100%;
height: auto; height: auto;
padding: 0rpx 14rpx 108rpx 14rpx; padding: 20rpx 14rpx 140rpx 14rpx;
background: linear-gradient(to bottom, #ff6400 0%, #fee4d7 30%, #f6f6f6 100%) /* background: linear-gradient(to bottom, #ff6400 0%, #fee4d7 30%, #f6f6f6 100%) */
background-color: #f6f6f6;
} }
.zd_wrapper { .zd_wrapper {
width: 100%; width: 100%;

View File

@@ -54,7 +54,8 @@
_fj() _fj()
position fixed position fixed
_wh(100%, calc(var(--status-bar-height) + 72rpx)) _wh(100%, calc(var(--status-bar-height) + 72rpx))
background: linear-gradient(to bottom, #ff6800 0%, #ff6400 100%) // background: linear-gradient(to bottom, #ff6800 0%, #ff6400 100%)
background-color $red
z-index 200 z-index 200
padding var(--status-bar-height) 20rpx 0 padding var(--status-bar-height) 20rpx 0
.page_name .page_name

49
components/upTop.vue Normal file
View File

@@ -0,0 +1,49 @@
<template>
<view class="back-top" @tap="toTop" v-show="showBtn">
<uni-icons class="zd_icon_wraper" type="arrow-up" size="30"></uni-icons>
</view>
</template>
<script>
export default {
name:"upTop",
data() {
return {
showBtn: false
};
},
props: {
scrollTop: {
type: Number,
default: 0
}
},
methods: {
topData(e) {
this.showBtn = e > 50
},
// 返回顶部
toTop() {
uni.pageScrollTo({
scrollTop: 0,
duration: 100
})
}
}
}
</script>
<style lang="stylus" scoped>
.back-top
position: fixed;
z-index: 9999;
right: 20rpx;
bottom: 150rpx;
background-color: #fff;
width: 80rpx;
height: 80rpx;
line-height: 80rpx;
border-radius: 50%;
text-align: center;
box-shadow: 0 4rpx 16rpx rgba(28,31,35,.3);
</style>

View File

@@ -140,20 +140,24 @@
</view> </view>
</view> </view>
<view v-if="active" class="msg_mask"></view> <view v-if="active" class="msg_mask"></view>
<up-top ref="UT" :scrollTop="top"></up-top>
</view> </view>
</template> </template>
<script> <script>
import NavBar from '@/components/NavBar.vue' import NavBar from '@/components/NavBar.vue'
import SearchBox from '@/components/SearchBox.vue' import SearchBox from '@/components/SearchBox.vue'
import UpTop from '@/components/upTop.vue'
import {queryProductArea, feedingQueryMaterialInfo, feedingConfirm, feedingQueryPoint, feedingHandleConfirm, feedingVehicleReturn} from '@/utils/getData2.js' import {queryProductArea, feedingQueryMaterialInfo, feedingConfirm, feedingQueryPoint, feedingHandleConfirm, feedingVehicleReturn} from '@/utils/getData2.js'
export default { export default {
components: { components: {
NavBar, NavBar,
SearchBox SearchBox,
UpTop
}, },
data() { data() {
return { return {
top: 0,
val1: '', val1: '',
val2: '', val2: '',
options: [], options: [],
@@ -181,6 +185,9 @@
btn_active: false btn_active: false
}; };
}, },
onPageScroll(e) {
this.$refs.UT.topData(e.scrollTop)
},
created () { created () {
this._queryProductArea() this._queryProductArea()
}, },