Commit 1f50d33a by 侯体倬

首页沉侵式优化

parent 13680ef1
...@@ -85,6 +85,7 @@ export default { ...@@ -85,6 +85,7 @@ export default {
height: 100%; height: 100%;
background: linear-gradient(rgba(0, 0, 0, 0) 10%, rgb(255, 255, 255) 40%); background: linear-gradient(rgba(0, 0, 0, 0) 10%, rgb(255, 255, 255) 40%);
} }
transition: background-color .5s;
} }
.ThemeDataPlant::before { .ThemeDataPlant::before {
......
<template> <template>
<div class="CustomNav"> <div class="CustomNav" :style="zIndexStyle">
<div class="navFixedBg" :style="{ 'height': navHeight + 'px' }"> <div class="navFixedBg" :style="navFixedBgStyle"></div>
</div> <div class="navBg" :style="navBgStyle">
<div class="navBg" <div class="content" :style="contentStyle">{{showShopName}}</div>
:style="{ 'height': navHeight + 'px', background: 'rgba(255,255,255,' + (customBgOpacity ? bgOpacity : 1) + ')' }">
<div class="content" :style="{ 'top': navTop + 'px', height: navConHeight + 'px' }">
{{ title || shopName }}
</div>
</div> </div>
</div> </div>
</template> </template>
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
const app = getApp(); let navHeight, navTop, navConHeight;
const { log } = app;
export default { export default {
name: "CustomNav", name: "CustomNav",
props: { props: {
...@@ -28,64 +23,78 @@ export default { ...@@ -28,64 +23,78 @@ export default {
}, },
data() { data() {
return { return {
navHeight: 0, shopName: ' ',
navTop: 0,
navConHeight: 0,
bgOpacity: 0, bgOpacity: 0,
zIndexStyle: '',
navFixedBgStyle: '',
navBgStyle: '',
contentStyle: ''
} }
}, },
components: {}, created() {
computed: {
shopName() {
// let shopName = app.globalData && app.globalData.shopInfo && app.globalData.shopInfo.shopName;
let shopName = wx.getStorageSync("shopName");
return shopName || "";
},
listHeight() {
return `calc(100vh - ${this.navConHeight}px - ${this.navTop}px - 0.5rem )`
},
topBgHeight() {
return `calc(2rem + ${this.navTop}px)`
},
topHeight() {
return `calc(2rem + ${this.navTop}px)`
}
},
created() { },
onLoad() {
this.getNavbarInfo(); this.getNavbarInfo();
}, this.initialize();
onShow() {
},
onReady() {
},
onHide() {
},
onUnload() {
}, },
onPageScroll(el) { onPageScroll(el) {
this.getScroll(el); this.getScroll(el);
}, },
mounted() { }, watch: {
customBgOpacity() {
wx.nextTick(() => {
this.initialize();
this.$forceUpdate();
})
}
},
computed: {
showShopName() {
return this.shopName;
}
},
methods: { methods: {
initialize() {
this.setShopName();
this.setZIndexStyle();
this.setNavFixedBgStyle();
this.setNavBgStyle();
this.setContentStyle();
},
getScroll(el) { getScroll(el) {
let opacity = (el.scrollTop / 100).toFixed(1) - 0; let opacity = (el.scrollTop / 100).toFixed(1) - 0;
this.bgOpacity = opacity > 1 ? 1 : opacity; this.bgOpacity = opacity > 1 ? 1 : opacity;
this.setNavBgStyle();
this.setContentStyle();
}, },
getNavbarInfo() { getNavbarInfo() {
let menuInfo = wx.getMenuButtonBoundingClientRect(); const { height, top } = wx.getMenuButtonBoundingClientRect();
console.log(menuInfo, '-menuInfo') const { statusBarHeight } = wx.getSystemInfoSync()
let res = wx.getSystemInfoSync() navTop = statusBarHeight;
console.log(res, '-getSystemInfoSync') navHeight = (statusBarHeight + height + (top - statusBarHeight) * 2);
this.navTop = res.statusBarHeight; navConHeight = (height + (top - statusBarHeight) * 2);
this.navHeight = (res.statusBarHeight + menuInfo.height + (menuInfo.top - res.statusBarHeight) * 2) },
this.navConHeight = (menuInfo.height + (menuInfo.top - res.statusBarHeight) * 2); setShopName() {
console.log(this.navTop, this.navHeight, this.navConHeight, '-this.navConHeight') this.shopName = this.title || wx.getStorageSync("shopName");
} },
setZIndexStyle() {
this.zIndexStyle = `z-index: ${this.customBgOpacity ? 9991 : 9999};`;
},
setNavFixedBgStyle() {
this.navFixedBgStyle = `height:${this.customBgOpacity ? navTop : navHeight}px;`;
},
setNavBgStyle() {
this.navBgStyle = `
height: ${navHeight}px;
background:rgba(255, 255, 255, ${this.customBgOpacity ? this.bgOpacity : 1});
`;
},
setContentStyle() {
this.contentStyle = `
top: ${navTop}px;
height: ${navConHeight}px;
opacity: ${this.customBgOpacity ? this.bgOpacity : 1};
`;
},
} }
} }
</script> </script>
...@@ -93,7 +102,6 @@ export default { ...@@ -93,7 +102,6 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.CustomNav { .CustomNav {
position: relative; position: relative;
z-index: 9999;
.navFixedBg { .navFixedBg {
width: 100%; width: 100%;
......
...@@ -116,6 +116,8 @@ export default { ...@@ -116,6 +116,8 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.storeAddr { .storeAddr {
position: relative;
z-index: 9992;
padding: 6px 12px; padding: 6px 12px;
justify-content: space-between; justify-content: space-between;
......
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