From f93e22b743bf9a7a733ed563cdd395ff2313a802 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Fri, 31 Dec 2021 09:53:50 +0800 Subject: [PATCH] 判断顶部的关注公众号的组件的显示 --- pages/index/index/index.js | 39 +++++++++++++-------------------------- pages/index/index/index.wxml | 4 ++-- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/pages/index/index/index.js b/pages/index/index/index.js index 21e5bed..180b8d5 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -88,33 +88,8 @@ Page({ }, onLoad: async function (tt) { - // onLoad生命周期内判断 - let obj = wx.getLaunchOptionsSync(); - //扫码登陆,强行 - if(tt.scancode_time){ - this.setData({is_ok_h5:1}) - wx.setStorageSync('launch', obj.scene); - }else{ - var cache_scene= wx.setStorageSync('launch'); - //看一下有没有缓存,没有缓存,或者缓存的值不一样,就开始判断公众号关注组件 - if(!cache_scene){ - if (obj.scene === 1011 || obj.scene === 1012 || obj.scene === 1013 || obj.scene === 1017 || - obj.scene === 1047 ||obj.scene === 1089 || obj.scene === 1038 || tt.scancode_time) { - this.setData({is_ok_h5:1}) - wx.setStorageSync('launch', obj.scene); - }else{ - this.setData({is_ok_h5:0}) - } - }else{ - this.setData({is_ok_h5:0}) - } - - } - - - - var th = this; + var th = this; var first_leader = tt.first_leader; if (!first_leader && tt.scene) { var first_leader_str = decodeURIComponent(tt.scene); @@ -479,6 +454,18 @@ Page({ }, 1500) + setTimeout(function () { + const query = wx.createSelectorQuery(); + query.select('#off_top').boundingClientRect(); + query.exec((res) => { + if(res && res[0].height>0){ + th.setData({is_ok_h5:1}); + } + }) + },2000); + + + }, //当隐藏的时候就关闭计时器 onHide: function () { diff --git a/pages/index/index/index.wxml b/pages/index/index/index.wxml index 8404648..ba0ca97 100644 --- a/pages/index/index/index.wxml +++ b/pages/index/index/index.wxml @@ -16,7 +16,7 @@ - + @@ -414,7 +414,7 @@ - + -- libgit2 0.21.4