// pages/stock/index.js const util = require('../../../utils/util') const app = getApp() Component({ options: { addGlobalClass: true, multipleSlots: true }, /** * 页面的初始数据 */ data: { height: app.globalData.safeFragmentHeight - 190, safeBottom: app.globalData.safeBottom, firstShow: false, tabList: [ '热门', '纸品价格', '车辆排队', '纸厂扣点' ], tabIndex: 0 }, methods: { onLoad:function(){ this.onRestart() }, onRestart: function () { var fragment = this.selectComponent('#fragment' + this.data.tabIndex) if (fragment) { fragment.onRestart() } if (!this.data.firstShow) { this.setData({ height: app.globalData.safeFragmentHeight - 190, tabList: this.data.tabList, safeBottom: app.globalData.safeBottom}) // request.get('/information-center/article-category/get/article-category-list').then(result => { // for (let index = 0; index < result.data.length; index++) { // this.data.tabList[index + 1] = result.data[index].name // } // // this.setData({tabList: this.data.tabList}) // }).catch(err => { // //异常回调 // }) } this.data.firstShow = true }, onTabChange: function({detail}){ if(this.data.tabIndex == Number(detail.index)){ return } this.setData({ tabIndex: Number(detail.index) }) this.onRestart() }, stopTouchMove: function(e){ return false }, postMoment: function(){ util.navigateTo('/pages/article/publish/index') } } })