小程序 模拟今日头条导航栏,点击锚点跳转对应楼层

使用场景,顶部导航的个数不确定,会有超出屏幕的情况,在一行展示,每点击一个导航的tab会判断是否向左或者像右滚动一个距离,以使当前的点击的导航能看到。同时点击导航会锚点跳转对应楼层,当前导航会变为激活状态。滚动屏幕,滚动到对应楼层,对应导航变为激活状态。

1.代码实现

1.1wxml

<!-- 楼盘相册 -->
<scroll-view class='xcnyTab' scroll-x scroll-left="{{tabScroll}}" scroll-with-animation="true">
  <view wx:for='{{xcnyHead}}' class='xcnyTabLi {{currentTab == index ? "on" : ""}}' data-current="{{index}}" bindtap='clickMenu'>
    {{item}}
    <view class='xcnyTabLi-line'></view>
  </view>
</scroll-view>
<!-- 所有种类 -->
<scroll-view scroll-y style='height:{{ht}}px;' scroll-with-animation="true" bindscroll="scrollRight" scroll-into-view="{{toViewRt}}">
  <view class='xcnyAll'>
    <!-- vr -->
    <!-- a_type (vr: 11) (视频: 12)  (其他图片) -->
    <block wx:for="{{xcnyList}}" wx:for-item="list" wx:for-index="listidx">
      <view class='xcnyAll-title' id='t{{listidx}}'>{{list.a_name}}</view>
      <view class='xcnyAllList {{list.flag==1?"":"h523hidden"}}'>
        <view class='xcnyAllList-wrap clearfix'>
          <block>
            <view class='xcnyAllLi' wx:for="{{list.a_photos}}" data-listidx="{{listidx}}" data-index="{{index}}" bindtap='godetail'>
              <image class='xcnyAllLi-img' src='{{item.p_thumb}}'></image>
              <!-- vr:11 -->
              <view wx:if="{{list.a_type==11}}" class='xcnyAllLi-vr'></view>
              <!-- 视频: 12 -->
              <view wx:if="{{list.a_type==12}}" class='xcnyAllLi-video'></view>
            </view>
          </block>
          <block wx:if="{{12<list.a_photos.length}}">
            <view class='xcnyAllLi-more' data-listidx="{{listidx}}" wx:if="{{!list.flag}}" bindtap='getmore'></view>
          </block>
        </view>
      </view>
    </block>
  </view>
</scroll-view>

1.2wxss

.xcnyTab{
  width: 100%;
  white-space: nowrap;
  border-top: 1rpx solid #f1f1f1;
  border-bottom: 1rpx solid #f1f1f1;
}

.xcnyTabLi{
  height: 80rpx;
  display: inline-block;
  width: 18.18%;
  text-align: center;
  position: relative;
  font-size: 28rpx;
  color: #404040;
  line-height: 80rpx;
  
}

.xcnyTabLi.on{
  color: #ff7500;
}

.xcnyTabLi.on .xcnyTabLi-line{
  width: 36rpx;
  height: 5rpx;
  background-color: #ff7500;
  position: absolute;
  left: 50%;
  margin-left: -18rpx;
  top:60rpx;
}

/* 所有种类 */
.xcnyAll{
  width: 716rpx;
  margin: 0 auto;
}

.xcnyAll-title{
  font-size: 32rpx;
  color: #8a8a8a;
  line-height: 34rpx;
  padding-top: 40rpx;
}

.xcnyAllList{
  width: 100%;
  overflow: hidden;
  margin-top: 25rpx;
  position: relative;
}

.xcnyAllList.h523hidden{
  max-height: 523rpx;
  overflow: hidden;
}


.xcnyAllList-wrap{
  width: 716rpx;
}

.xcnyAllLi-more{
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHQAAAAXCAYAAADa+mvTAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFk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VIZFobPyfkGMvHRkeYjRvyRbj7BFFXna8458w6Vz1HVrxUay34JRdWKYcE32gzjw18pJebwJcb6J8AAooj0Qjt0jkQAAAAASUVORK5CYII=);
  background-repeat: no-repeat;
  background-position: center;
  background-size:116rpx 23rpx;
  position: absolute;
  right: 18rpx;
  bottom: 2rpx;
  width: 169rpx;
  height: 169rpx;
  background-color: gray;
}

.xcnyAllLi{
  width: 165rpx;
  height: 165rpx;
  float: left;
  margin-right:14rpx;
  position: relative;
  margin-bottom: 14rpx;
}

.xcnyAllLi-img{
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.xcnyAllLi-vr,.xcnyAllLi-video{
  background-repeat: no-repeat;
  background-position: center;
  background-size:80rpx 80rpx;
  width:80rpx;
  height:80rpx;
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left:-40rpx;
  margin-top:-40rpx;
}

.xcnyAllLi-vr{
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cD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VPb2toq0JwzMzO3rlmz5iVlhbd69eo+HZD1EjpBt2fJWjSkXvhpwufzLXg8XjaFOG5IPnbixIl/BgUFfadM8DIyMt6eM2fOYmnysSKBQOBP7krDs97nudPfISkNl8vda21t/Sdpb82PjIzciW3yTAbn6+trnJaWhvR3fZFFVVVVenV1dQQ6y+e530gkYFzo6Oi4A6vnyWvvPHPmzKGQkJBTTEzAiIEBqnULkICxp6ennWpdDLkue4dz3xFLAWpra5uG2BnX2PGenp5+ELvemZACFGOb8+bNeyQFKEJVRFvDvf9IJ6FdjuwW/ZLQlpORPooN3IpIQoupicDAQCShtcNr0iS0CS4uLikj9Ry5pEEmu7gBySv6p0GmHu7c7t27c0cjDfKSJUumu7u7z3gsDXIq/SUwOg1yf7l48aIJ+VarH0/EjT3JZHsKzp8/X7R9+/ZfxGJxz3CeY25urrFy5cqXqXNwI8/AE5GE7D1ZIu6GhobPp02bJpfOTaGp4DGRjmwYFLSXV5JQ8xJjEwv2rNBlV3l5eZcszLKzs9NxcnIywOJGMhPm9JoNBfp2KpsK/mnS78cIArDf1sDAYER+jIB6fCHWqkgkkiyV+zGCQXxJjr6+/utk8J2f8nMY2rLailqFP3I9WilWFct+DoM6puI7d+78MNS4VR7yXwEGAOZTZpd+3FnDAAAAAElFTkSuQmCC);
}

3.js

var that;
var windowWidth = 0;
var windowHeight = 0;
// 滚动的高度
var scrolltop = 0;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    oldarr: [{
        a_name: "类目1",
        a_type: 11,
        a_photos: [{
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/5.jpg",
        }],
      },
      {
        a_name: "类目2",
        a_type: 7,
        a_photos: [{
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }]
      },
      {
        a_name: "类目3",
        a_type: 7,
        a_photos: [{
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }]
      },
      {
        a_name: "类目4",
        a_type: 7,
        a_photos: [{
          p_thumb: "https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640"
        }]
      },
      {
        a_name: "类目5",
        a_type: 12,
        a_photos: [{
          p_thumb: "https://images.unsplash.com/photo-1551446591-142875a901a1?w=640"
        }]
      },
      {
        a_name: "类目6",
        a_type: 7,
        a_photos: [{
          p_thumb: "https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640"
        }, {
          p_thumb: "https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640"
        }, {
          p_thumb: "https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640"
        }]
      },
      {
        a_name: "类目7",
        a_type: 7,
        a_photos: [{
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/2.jpg"
        }]
      },
      {
        a_name: "类目8",
        a_type: 7,
        a_photos: [{
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/5.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/5.jpg"
        }, {
          p_thumb: "http://demo.sc.chinaz.com/Files/DownLoad/webjs1/201801/jiaoben5647/img/5.jpg"
        }]
      }
    ],
    xcnyHead: [],
    xcnyList: [],
    tabScroll: 0,
    currentTab: 0,
    windowHeight: '',
    // 监听各个种类的距离顶部的高度
    element: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onl oad: function(options) {
    that = this;
    wx.getSystemInfo({ // 获取当前设备的宽高,文档有
      success: (res) => {
        windowWidth = res.windowWidth;
        windowHeight = res.windowHeight;
        that.setData({
          ht: (windowHeight - 41)
        });
      },
    });

    that.getphoto();
  },

  // 获取位置
  getTitleTop(scrolltop = 0, cb = '') {
    //获取导航的初始位置
    const query = wx.createSelectorQuery()
    query.selectAll('.xcnyAll-title').boundingClientRect();
    query.exec(function(res) {
      res = res[0]
      var arr = [];
      for (var i = 0; i < res.length; i++) {
        arr.push(res[i].top + scrolltop - 42)
      }
      that.setData({
        element: arr
      });

    });

    if (typeof cb == "function") {
      cb(scrolltop);
    }
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    that.setData({
      toViewRt: 't' + that.data.currentTab
    });
  },
  // 点击tab
  clickMenu: function(e) {
    //获取当前tab的index
    var current = e.currentTarget.dataset.current;
    var type = e.currentTarget.dataset.type;
    var tabWidth = windowWidth / 5;
    // 导航tab共5个,获取一个的宽度
    that.setData({
      tabScroll: (current - 2) * tabWidth //使点击的tab始终在居中位置
    })
    if (that.data.currentTab == current) {
      return false
    } else {
      that.setData({
        currentTab: current,
        toViewRt: 't' + current
      })
    }
  },

  // 滚动右侧菜单
  scrollRight(e) {
    scrolltop = e.detail.scrollTop;

    var element = that.data.element;
    var elementIndex = getTimeIndex(element, scrolltop);

    that.setData({
      currentTab: elementIndex,
      tabScroll: (elementIndex - 2) * (windowWidth / 5)
    });

  },

  // 效果图点击查看更多
  getmore(e) {
    var listidx = e.currentTarget.dataset.listidx;
    var key = 'xcnyList[' + listidx + '].flag'

    that.setData({
      [key]: 1
    }, () => {
      // 当全部展开时,需要重新获取各个楼层的高度
      that.getTitleTop(scrolltop);
    });
  },

  // 进入查看大图,a_type (vr: 11) (视频: 12)  (其他图片)
  godetail(e) {
    var listidx = e.currentTarget.dataset.listidx;
    var index = e.currentTarget.dataset.index;
    var xcnyList = that.data.xcnyList;
    // 类型
    var a_type = xcnyList[listidx].a_type;
    // 资源地址
    var url = xcnyList[listidx].a_photos[index].p_url;

    if (a_type == 11) {
      console.log()
    } else {
      console.log()
    }
  },
  // 楼盘相册
  getphoto() {
    var res = that.data.oldarr;
    console.log(res)
    if (res.length) {
      var xcnyHead = [];
      var xcnyList = [];
      for (var i = 0; i < res.length; i++) {
        if (res[i].a_photos.length) {
          res[i]['flag'] = 0;
          xcnyHead.push(res[i].a_name);
          xcnyList.push(res[i]);
        }
      }

      that.setData({
        xcnyHead: xcnyHead,
        xcnyList: xcnyList
      }, () => {
        // 获取位置
        //获取导航的初始位置
        that.getTitleTop();
      });

    }
  }
})

// 判断在数组哪两项之间
function getTimeIndex(timeArr, time) {
  var timeIndex = -1;
  for (var i = 0; i < timeArr.length; i++) {
    if (timeArr[i] > time) {
      timeIndex = i - 1;
      break;
    }
  }
  return timeIndex;
}

1.4 效果

小程序 模拟今日头条导航栏,点击锚点跳转对应楼层

2.说明

2.1 思路:

2.1.1这里需要建立两层数组,外层(包含标题)和内层(内层需要循环的部分),先通过循环把外层标题提取出来组成顶部的导航栏;

2.1.2通过scroll-view布局,通过它实现锚点跳转。不同尺寸的屏幕,尺寸需要做一个换算,获取屏幕宽高对于现在的做一个适配;

2.1.3因为有展开动作(查看更多),所以当展开时需要重新计算元素距离顶部的高度,可以把获取高度封装为一个方法,最开始计算一次,点击展开和收起再计算一次;

2.1.3在滚动过程中需要判断当前滚动到第几个,从而计算顶部tab切换到第几个为激活状态;

2.1.4 在滚动到最底部时,并没有切换到最后一个是正常现象,没有到达它的条件;

2.2说明

2.2.1 触屏导航详见:https://blog.csdn.net/hangGe0111/article/details/88971087

上一篇:_start可以是thumb函数吗?


下一篇:解决手机拍照,照片在PC浏览器旋转