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.
87 lines
2.9 KiB
87 lines
2.9 KiB
const app = getApp()
|
|
const event = require('../../utils/event.js')
|
|
const request = require('../../utils/request') //导入模块
|
|
const storage = require('../../utils/storage')
|
|
|
|
Page({
|
|
data: {
|
|
TabList: [
|
|
{ index: 0, value: 'article', badge: 0, name: '情报' },
|
|
{ index: 1, value: 'mall', badge: 0, name: '交易' },
|
|
{ index: 2, value: 'home', badge: 0, name: '我的' }
|
|
],
|
|
pageIndex: 1,
|
|
safeBottom: app.globalData.safeBottom
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
const updateManager = wx.getUpdateManager()
|
|
updateManager.onCheckForUpdate(function (res) {
|
|
// 请求完新版本信息的回调
|
|
// console.log('updateManager>>>' + res.hasUpdate)
|
|
})
|
|
updateManager.onUpdateReady(function () {
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
updateManager.applyUpdate()
|
|
})
|
|
if(app.inited){
|
|
this.setData({fragment: app.globalData.safeFragmentHeight + app.globalData.statusBarHeight - 100, safeBottom: app.globalData.safeBottom })
|
|
} else{
|
|
var devJson = storage.get('ztbdev')
|
|
if(devJson){
|
|
var devInfo = JSON.parse(devJson)
|
|
app.globalData.statusBarHeight =devInfo.statusBarHeight
|
|
app.globalData.safeBottom = devInfo.safeBottom
|
|
app.globalData.safeFragmentHeight = devInfo.safeFragmentHeight
|
|
app.globalData.fragmentHeight = devInfo.fragmentHeight
|
|
app.globalData.windowWidth = devInfo.windowWidth
|
|
app.globalData.isIPhoneX = devInfo.isIPhoneX
|
|
app.globalData.isIos = devInfo.isIos
|
|
app.globalData.dev = devInfo.dev
|
|
app.globalData.CustomBar = devInfo.CustomBar
|
|
app.globalData.Custom = devInfo.Custom
|
|
this.setData({fragment: app.globalData.safeFragmentHeight + app.globalData.statusBarHeight - 100, safeBottom: app.globalData.safeBottom })
|
|
}
|
|
}
|
|
event.on('EventMessage', this, this.onEvent)
|
|
if(!app.globalData.userInfo.mobile){
|
|
request.get('/recycle-service/user/get/base-info').then(result => {
|
|
app.globalData.userInfo = result.data
|
|
})
|
|
}
|
|
},
|
|
//事件处理函数
|
|
onNavChange(e) {
|
|
// 处理用户的登录校验
|
|
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) })
|
|
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value)
|
|
if (pageView) {
|
|
pageView.onRestart()
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value)
|
|
if (pageView) {
|
|
pageView.onRestart()
|
|
}
|
|
},
|
|
onEvent: function (message) {
|
|
if(message.what == 250){
|
|
this.setData({ pageIndex: 0 })
|
|
}
|
|
},
|
|
stopTouchMove: function(e){
|
|
return false
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
event.remove('EventMessage', this)
|
|
}
|
|
})
|