微信小程序,滚动标记消息已读

记录。

滚动的时候去找dom,然后看top是否小于某一个高度(屏幕可用高度)为已读,进行标记。

 

<scroll-view scroll-y scroll-into-view="{{toItemView}}" bindscroll="scrolltoupper">
<view wx:for="{{10}}"  id="ItemView{{index}}">
</view>   
</scroll-view>

  

// 获取滚动条当前位置
  scrolltoupper: function (e) {
    let that =this;
    var Lists = this.createSelectorQuery().selectAll(".WaitingTag").boundingClientRect();
    Lists.exec(function (res) {
      res[0].forEach((item,index) => {
        //检查是否已读,top在小于屏幕可用范围内为已读
        if(item.top<=(that.data.windowHeight-that.data.CustomBar-200))//一个框框最小400rpx
        {
          if(that.data.readList.indexOf(item.id)<0){
            that.data.readList.push(item.id);
            var list=that.data.readList;
            that.setData({
              readList:list
            })
        //设置已读操作。。。
         } } }); }) },

  

posted @ 2022-05-16 14:17  小杨观世界  阅读(315)  评论(0编辑  收藏  举报