var utils = require('../../utils/util'); const app = getApp() Page({ data: { index: 0, indexPage: 1, floorstatus: false, childNav: [],//首页配置返回 tabs: [ { key: 'tab1', title: 'Tab 1', }, { key: 'tab2', title: 'Tab 2', }, { key: 'tab3', title: 'Tab 3', }, { key: 'tab4', title: 'Tab 4', }, ], }, onLoad: function (options) { const temp = Number(options.state) + 1 this.setData({ key: 'tab' + temp, index: options.state, childNav: JSON.parse(options.childNav), }) }, onShow: function (options) { this.setData({ indexPage:1 }) this.selectComponent("#state-" + this.data.index).getItemList(1, this.data.index, 0) }, onReachBottom: function () { this.setData({ indexPage: this.data.indexPage + 1 }) this.selectComponent("#state-" + this.data.index).getItemList(this.data.indexPage,this.data.index,1) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function (options) { this.selectComponent("#state-" + this.data.index).getItemList(1, this.data.index, 0) wx.stopPullDownRefresh(); }, onChange(e) { console.log('onChange', e) this.setData({ current: e.detail.key, }) }, onTabsChange(e) { const {key} = e.detail const index = this.data.tabs.map((n) => n.key).indexOf(key) this.setData({ key, index, indexPage: 1 }) this.selectComponent("#state-" + this.data.index).getItemList(this.data.indexPage,this.data.index,0) }, onSwiperChange(e) { console.log('onSwiperChange', e) const {current: index, source} = e.detail const {key} = this.data.tabs[index] if (!!source) { this.setData({ key, index, }) } }, // 获取滚动条当前位置 onPageScroll: function (e) { if (e.scrollTop > 100) { this.setData({ floorstatus: true }); } else { this.setData({ floorstatus: false }); } }, //回到顶部 goTop: function (e) { // 一键回到顶部 if (wx.pageScrollTo) { wx.pageScrollTo({ scrollTop: 0 }) } else { wx.showModal({ title: '提示', content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' }) } } })