var utils = require('../../utils/util'); const app = getApp() Page({ data: { index: 0, indexPage: 1, currenttab: 'new', floorstatus: false, clear: 0,//0清除数据 1不清除 date: utils.formatTimestamp(new Date()), 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) { console.log('options', this.data.tabs[options.state].key) const key = this.data.tabs[options.state].key this.setData({ current: this.data.tabs[options.state].key, index: options.state, date: utils.formatTimestamp(new Date()), indexPage: 1, clear: 0, key, childNav: JSON.parse(options.childNav) }) console.log(this.data) }, onShow: function (options) { this.selectComponent("#state-" + this.data.index).getIssueList(this.data) }, onReachBottom: function () { this.setData({ indexPage: this.data.indexPage + 1, clear: 1//上拉事件 不清除数据 }) this.selectComponent("#state-" + this.data.index).getIssueList(this.data) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function (options) { this.setData({ date: utils.formatTimestamp(new Date()), indexPage: 1, clear: 0 }) this.selectComponent("#state-" + this.data.index).getIssueList(this.data) wx.stopPullDownRefresh(); }, onChange(e) { console.log('onChange', e) this.setData({ current: e.detail.key, }) }, onTabsChange(e) { console.log('onTabsChange', e) const { key } = e.detail const index = this.data.tabs.map((n) => n.key).indexOf(key) console.log(index) this.setData({ key, index, indexPage: 1, indexPage: 1, clear: 0, date: utils.formatTimestamp(new Date()) }) this.selectComponent("#state-" + this.data.index).getIssueList(this.data) }, onSwiperChange(e) { console.log('onSwiperChange', e) const { current: index, source } = e.detail const { key } = this.data.tabs[index] if (!!source) { this.setData({ key, index, }) } }, newhot: function (e) { let currenttab = e.currentTarget.dataset.case this.setData({ currenttab: currenttab, indexPage: 1, clear: 0, date: utils.formatTimestamp(new Date()) }) console.log(this.data.currenttab) this.selectComponent("#state-" + this.data.index).getIssueList(this.data) }, // 获取滚动条当前位置 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: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' }) } } })