Commit b574b857 by zhangquan

优化吸顶

1 parent 0e951bfd
...@@ -21,7 +21,6 @@ Component({ ...@@ -21,7 +21,6 @@ Component({
navList:['数字无忧权益卡'], navList:['数字无忧权益卡'],
activeNavIdx: 0, //特色产品 activeNavIdx: 0, //特色产品
tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'], tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'],
heightArr:[],
curTabIdx:0, //适用产品 curTabIdx:0, //适用产品
actNum: 0, //场景 actNum: 0, //场景
showAuth: false, showAuth: false,
...@@ -29,10 +28,11 @@ Component({ ...@@ -29,10 +28,11 @@ Component({
}, },
lifetimes:{ lifetimes:{
ready: function (){ ready: function (){
this.getImgHeight() wx.$eventbus.on('evt_page_scroll',(e)=>{
wx.$eventbus.on('evt_page_scroll',async (e)=>{
// console.log(e) // console.log(e)
let heightTop = this.data.headerHeight// 90 场景高度,8 场景margin-bottom
wx.$util.getViewInfo('.header',async (res)=> {
let heightTop = res.height
let prodArr = await this.getHeight('.prod-wrap') let prodArr = await this.getHeight('.prod-wrap')
heightTop += prodArr[0].height heightTop += prodArr[0].height
let imgArr = await this.getHeight('.img-item') let imgArr = await this.getHeight('.img-item')
...@@ -48,6 +48,7 @@ Component({ ...@@ -48,6 +48,7 @@ Component({
}) })
} }
}) })
})
}, },
}, },
...@@ -85,18 +86,18 @@ Component({ ...@@ -85,18 +86,18 @@ Component({
activeNavIdx:this.data.isShare ? this.data.navIdx : 0, activeNavIdx:this.data.isShare ? this.data.navIdx : 0,
tab tab
}) })
this.getImgHeight();
}, },
}, },
methods: { methods: {
async changeTab(e){ changeTab(e){
let {idx} = e.currentTarget.dataset let {idx} = e.currentTarget.dataset
this.setData({ this.setData({
curTabIdx: idx curTabIdx: idx
}) })
this.data.throttle = true this.data.throttle = true
let heightTop = this.data.headerHeight + 90 - 16 - 46 // 90 场景高度,16 可能是误差 , 46 tab高度 wx.$util.getViewInfo('.header',async (res)=> {
let heightTop = res.height
let prodArr = await this.getHeight('.prod-wrap') let prodArr = await this.getHeight('.prod-wrap')
heightTop += prodArr[0].height heightTop += prodArr[0].height
let imgArr = await this.getHeight('.img-item') let imgArr = await this.getHeight('.img-item')
...@@ -110,6 +111,7 @@ Component({ ...@@ -110,6 +111,7 @@ Component({
setTimeout(()=>{ setTimeout(()=>{
this.data.throttle = false this.data.throttle = false
},500) },500)
})
}, },
getHeight(cla){ getHeight(cla){
return new Promise((resolve,reject)=>{ return new Promise((resolve,reject)=>{
...@@ -118,7 +120,6 @@ Component({ ...@@ -118,7 +120,6 @@ Component({
resolve(rect) resolve(rect)
}).exec() }).exec()
}) })
}, },
changeNav(event){ changeNav(event){
this.setData({ this.setData({
...@@ -168,59 +169,6 @@ Component({ ...@@ -168,59 +169,6 @@ Component({
authSuccess(){ authSuccess(){
this.toDown() this.toDown()
}, },
toSetting(){
return new Promise((resolve,reject)=>{
wx.getSetting({
success: (res)=> {
if(res.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.openSetting({
success :(resp)=> {
if(resp.authSetting['scope.writePhotosAlbum']){
resolve(true)
}else{
wx.showToast({
title: "下载视频前需要您授权'添加到相册'权限",
icon: "none",
duration: 2500,
});
}
}
})
}
}
})
})
},
getImgHeight(){
let query = wx.createSelectorQuery().in(this)
let heightArr = []
let s = 0
query.selectAll('.img-item').boundingClientRect((react) => {
react.forEach(item => {
s += item.height
heightArr.push(s)
})
this.data.heightArr = heightArr
}).exec()
},
getImgHeight() {
let query = wx.createSelectorQuery().in(this);
let heightArr = [];
let s = 0;
query
.selectAll(".img-item")
.boundingClientRect((react) => {
react.forEach((item) => {
s += item.height;
heightArr.push(s);
});
this.data.heightArr = heightArr;
this.data.allHeight = heightArr[heightArr.length - 1];
})
.exec();
},
toSharePage() { toSharePage() {
let { actNum, activeNavIdx ,senceData} = this.data; let { actNum, activeNavIdx ,senceData} = this.data;
wx.$router.go("checkProduct", { actNum, activeNavIdx ,senceData, fromLocal:1}); wx.$router.go("checkProduct", { actNum, activeNavIdx ,senceData, fromLocal:1});
......
...@@ -151,6 +151,12 @@ ...@@ -151,6 +151,12 @@
.project-wrap { .project-wrap {
background-color: #F5F7FB; background-color: #F5F7FB;
.sticky-area{
position: sticky;
position: -webkit-sticky;
z-index: 2;
background-color: #F5F7FB;
}
} }
.project-img { .project-img {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</view> </view>
</view> </view>
<view class="project-wrap"> <view class="project-wrap">
<view style="position: sticky;top: {{headerHeight}}px ;z-index: 2;background-color: #F5F7FB;"> <view class="sticky-area" style="top: {{headerHeight}}px">
<!-- <tab openScroll="{{true}}" tab="{{tab}}" index="{{curTabIdx}}" bindclick="changeTab"></tab> --> <!-- <tab openScroll="{{true}}" tab="{{tab}}" index="{{curTabIdx}}" bindclick="changeTab"></tab> -->
<scroll-view enhanced="{{true}}" show-scrollbar="{{false}}" scroll-left="{{curTabIdx*46}}" class="tab-box" scroll-x enable-flex scroll-with-animation > <scroll-view enhanced="{{true}}" show-scrollbar="{{false}}" scroll-left="{{curTabIdx*46}}" class="tab-box" scroll-x enable-flex scroll-with-animation >
<block wx:for="{{tab}}" wx:key="index"> <block wx:for="{{tab}}" wx:key="index">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!