// pages/info/roadInfo/index.js let device = wx.getSystemInfoSync(); const ratio = device.windowWidth / 750; import commonApi from "../../../utils/https/common" import util from "../../../utils/util" Page({ /** * 页面的初始数据 */ data: { fixed:false, type:1, top:0, info:null }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let rect = wx.getMenuButtonBoundingClientRect(); let height = (rect.top - device.statusBarHeight) * 2 + rect.height + device.statusBarHeight; console.log(height) this.setData({ top:height }) commonApi._post("scene/detail",{ id:options.id }).then(res=>{ this.setData({ info:res.data }) }) }, changeMenu:function(e){ let index = e.currentTarget.dataset.index,that = this; const query=wx.createSelectorQuery(); //创建节点查询器 query.select("#box"+index).boundingClientRect() //选择toViewid获取位置信息 query.selectViewport().scrollOffset() //获取页面查询位置的 query.exec(function(res) { let scrollTop = res[0].top + res[1].scrollTop - 110 * ratio - that.data.top; wx.pageScrollTo({ scrollTop: scrollTop + 4, duration: 0 }) that.setData({ type:index }) }) }, onPageScroll:function(e){ let that = this,height = this.data.top; let topHeight = height; // 滚动时判断滚动到哪个部分了 const query=wx.createSelectorQuery(); //创建节点查询器 query.select("#box1").boundingClientRect() //选择toViewid获取位置信息 query.select("#box2").boundingClientRect() //选择toViewid获取位置信息 query.select("#box3").boundingClientRect() //选择toViewid获取位置信息 let minHeight = that.data.fixed?(110 * ratio + height): topHeight; query.exec(function(res) { if(res[2].top