var widths=0; var lengs=0; var shus=0; var app=getApp(); Page({ /** * 页面的初始数据 */ data: { imgUrl:app.globalData.imgUrl, URL:app.globalData.url, winHeight: '100%', toView: 'zxzs01',//锚点跳转的ID actionView: 'zxzs01',//控制导航显示 zxzs01Top: 0, zxzs02Top: 0, zxzs03Top: 0, zxzs04Top: 0, zxzs05Top: 0, zxzs06Top: 0, zxzs07Top: 0, zxzs08Top: 0, navScrollLeft:0, isdlt:'', swiperNav: {   i: 0,   arr: ['zxzs01','zxzs02','zxzs03','zxzs04','zxzs05','zxzs06','zxzs07','zxzs08']  }, datalist:[] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; widths = wx.getSystemInfoSync().windowWidth; lengs = this.data.swiperNav.arr.length; wx.getSystemInfo({ success: function (res) { that.setData({ winHeight:res.windowHeight-(res.windowWidth*90/750)-229+'px' }) } }); wx.showLoading({ title: '加载中', }) utils.$get({ url: app.globalData.webUrl+'api/tool/decohelper_struc', header: { 'Authorization':'bearer '+app.globalData.token }, dataType: 'json', success(res) { console.log(res.data) if(res.data.code==0){ wx.hideLoading(); that.setData({ datalist:res.data.data }) } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, onReady(){ new Promise(resolve => { let query = wx.createSelectorQuery().in(this); setTimeout(() => { query.select('#zxzs01').boundingClientRect(); query.select('#zxzs02').boundingClientRect(); query.select('#zxzs03').boundingClientRect(); query.select('#zxzs04').boundingClientRect(); query.select('#zxzs05').boundingClientRect(); query.select('#zxzs06').boundingClientRect(); query.select('#zxzs07').boundingClientRect(); query.select('#zxzs08').boundingClientRect(); query.exec(function (res) { resolve(res); }); },3000); }).then(res => { this.setData({ zxzs01Top: res[0].top, zxzs02Top: res[1].top-res[0].top, zxzs03Top: res[2].top-res[0].top, zxzs04Top: res[3].top-res[0].top, zxzs05Top: res[4].top-res[0].top, zxzs06Top: res[5].top-res[0].top, zxzs07Top: res[6].top-res[0].top, zxzs08Top: res[7].top-res[0].top }); }); }, toViewClick(e) { console.log(e) this.setData({ toView: e.currentTarget.dataset.hash, actionView: e.currentTarget.dataset.hash }) }, disx(i){ var disX = (i - 1) * widths / (lengs-2); if (i != this.data.swiperNav.i) {   this.setData({    'swiperNav.i': i   })  }  this.setData({   'swiperNav.x': disX  }) }, scrollTo(e){ let scrollTop = e.detail.scrollTop+100; console.log(scrollTop) if(scrollTop >= this.data.zxzs08Top){ shus=7; this.setData({ actionView: 'zxzs08' }) }else if(scrollTop >= this.data.zxzs07Top){ shus=6; this.setData({ actionView: 'zxzs07' }) }else if(scrollTop >= this.data.zxzs06Top){ shus=5; this.setData({ actionView: 'zxzs06' }) }else if(scrollTop >= this.data.zxzs05Top){ shus=4; this.setData({ actionView: 'zxzs05' }) }else if(scrollTop >= this.data.zxzs04Top){ shus=3; this.setData({ actionView: 'zxzs04' }) }else if(scrollTop >= this.data.zxzs03Top){ shus=2; this.setData({ actionView: 'zxzs03' }) }else if(scrollTop >= this.data.zxzs02Top){ shus=1; this.setData({ actionView: 'zxzs02' }) }else{ shus=0; this.setData({ actionView: 'zxzs01' }) } this.disx(shus); }, editorbtn(e){ if(!this.data.isdlt){ this.setData({ isdlt:e.currentTarget.dataset.title }) }else{ this.setData({ isdlt:'' }) } }, deletebtn(e){ console.log(e.currentTarget.dataset.title) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ })