纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

57 lines
1.6 KiB

// pages/stock/index.js
const request = require('../../../utils/request') //导入模块
const app = getApp()
Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
/**
* 页面的初始数据
*/
data: {
height: app.globalData.safeFragmentHeight - 190,
firstShow: false,
tabList: [ '热门', '纸品价格', '车辆排队', '纸厂扣点' ],
tabIndex: 0
},
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight - 190 })
}
},
methods: {
onRestart: function () {
var fragment = this.selectComponent('#fragment' + this.data.tabIndex)
if (fragment) {
fragment.onRestart()
}
if (!this.data.firstShow) {
this.setData({tabList: this.data.tabList})
// /article-category/get/article-category-list 查询所有文章分类
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
}
}
})