Commit f93e22b743bf9a7a733ed563cdd395ff2313a802
1 parent
8f151bd4
判断顶部的关注公众号的组件的显示
Showing
2 changed files
with
15 additions
and
28 deletions
pages/index/index/index.js
@@ -88,33 +88,8 @@ Page({ | @@ -88,33 +88,8 @@ Page({ | ||
88 | }, | 88 | }, |
89 | 89 | ||
90 | onLoad: async function (tt) { | 90 | onLoad: async function (tt) { |
91 | - // onLoad生命周期内判断 | ||
92 | - let obj = wx.getLaunchOptionsSync(); | ||
93 | - //扫码登陆,强行 | ||
94 | - if(tt.scancode_time){ | ||
95 | - this.setData({is_ok_h5:1}) | ||
96 | - wx.setStorageSync('launch', obj.scene); | ||
97 | - }else{ | ||
98 | - var cache_scene= wx.setStorageSync('launch'); | ||
99 | - //看一下有没有缓存,没有缓存,或者缓存的值不一样,就开始判断公众号关注组件 | ||
100 | - if(!cache_scene){ | ||
101 | - if (obj.scene === 1011 || obj.scene === 1012 || obj.scene === 1013 || obj.scene === 1017 || | ||
102 | - obj.scene === 1047 ||obj.scene === 1089 || obj.scene === 1038 || tt.scancode_time) { | ||
103 | - this.setData({is_ok_h5:1}) | ||
104 | - wx.setStorageSync('launch', obj.scene); | ||
105 | - }else{ | ||
106 | - this.setData({is_ok_h5:0}) | ||
107 | - } | ||
108 | - }else{ | ||
109 | - this.setData({is_ok_h5:0}) | ||
110 | - } | ||
111 | - | ||
112 | - } | ||
113 | - | ||
114 | - | ||
115 | - | ||
116 | 91 | ||
117 | - var th = this; | 92 | + var th = this; |
118 | var first_leader = tt.first_leader; | 93 | var first_leader = tt.first_leader; |
119 | if (!first_leader && tt.scene) { | 94 | if (!first_leader && tt.scene) { |
120 | var first_leader_str = decodeURIComponent(tt.scene); | 95 | var first_leader_str = decodeURIComponent(tt.scene); |
@@ -479,6 +454,18 @@ Page({ | @@ -479,6 +454,18 @@ Page({ | ||
479 | }, 1500) | 454 | }, 1500) |
480 | 455 | ||
481 | 456 | ||
457 | + setTimeout(function () { | ||
458 | + const query = wx.createSelectorQuery(); | ||
459 | + query.select('#off_top').boundingClientRect(); | ||
460 | + query.exec((res) => { | ||
461 | + if(res && res[0].height>0){ | ||
462 | + th.setData({is_ok_h5:1}); | ||
463 | + } | ||
464 | + }) | ||
465 | + },2000); | ||
466 | + | ||
467 | + | ||
468 | + | ||
482 | }, | 469 | }, |
483 | //当隐藏的时候就关闭计时器 | 470 | //当隐藏的时候就关闭计时器 |
484 | onHide: function () { | 471 | onHide: function () { |
pages/index/index/index.wxml
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | 16 | ||
17 | <view class="top-bar"> | 17 | <view class="top-bar"> |
18 | <!-- 顶部关注公众号 --> | 18 | <!-- 顶部关注公众号 --> |
19 | - <view wx:if="{{is_gz_h5 && is_ok_h5}}"><official-account></official-account></view> | 19 | + <view id="off_top" wx:if="{{is_gz_h5}}"><official-account></official-account></view> |
20 | 20 | ||
21 | <!-- 控制要不要显示顶部门店选择 --> | 21 | <!-- 控制要不要显示顶部门店选择 --> |
22 | <block wx:if="{{is_topstore}}"> | 22 | <block wx:if="{{is_topstore}}"> |
@@ -414,7 +414,7 @@ | @@ -414,7 +414,7 @@ | ||
414 | <!-- 置顶层 --> | 414 | <!-- 置顶层 --> |
415 | <view class="dis_top"> | 415 | <view class="dis_top"> |
416 | <!-- 关注公众号的显示 --> | 416 | <!-- 关注公众号的显示 --> |
417 | - <view wx:if="{{is_gz_h5 && is_ok_h5}}"><official-account></official-account></view> | 417 | + <view id="off_top" wx:if="{{is_gz_h5}}"><official-account ></official-account></view> |
418 | 418 | ||
419 | <block wx:for="{{template_arr}}" > | 419 | <block wx:for="{{template_arr}}" > |
420 | <block wx:if="{{item.content.is_top==1}}"> | 420 | <block wx:if="{{item.content.is_top==1}}"> |