纸通宝SAAS仓库
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.
 

75 lines
2.7 KiB

// pages/administ/index.js
import Scene from './scene'
import { getMessageList } from "../../api/saas"
const event = require('../../utils/event')
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
safeBottom: app.globalData.safeBottom,
fragment: app.globalData.safeFragmentHeight,
tabList: [
{ index: 2, value: 'agent', badge: 0, name: '代卖', blue: '/assets/tabbar/mall-blue.png', gray: '/assets/tabbar/mall-gray.png' },
// { index: 0, value: 'message', badge: 0, name: '消息', blue: '/assets/tabbar/mall-blue.png', gray: '/assets/tabbar/mall-gray.png' },
{ index: 1, value: 'work', badge: 0, name: '工作台', blue: '/assets/tabbar/process-blue.png', gray: '/assets/tabbar/process-gray.png' },
{ index: 3, value: 'home', badge: 0, name: '我的', blue: '/assets/tabbar/home-blue.png', gray: '/assets/tabbar/home-gray.png' }
],
tabIndex: 1,
zIndex: 9,
setInter: null
},
/************************************** 初始化流程 ********************************************/
onLoad: function (options) {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate()
updateManager.onUpdateReady(function () {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
})
// event.on('TabMessage', this, this.onEvent)
this.setData({fragment: (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight), safeBottom: app.globalData.safeBottom })
this.data.setInter = setInterval(this.fetchMessage, 10000)
},
/************************************** 生命周期函数--监听页面初次渲染完成 ********************************************/
onShow: function () {
var pageView = this.selectComponent('#' + this.data.tabList[this.data.tabIndex].value)
if (pageView) {
pageView.onRestart()
}
},
onChange: function ({detail}) {
this.setData({ tabIndex: detail })
this.onShow()
},
stopTouchMove: function(e){
return false
},
onEvent: function (message) {
if (message.what == 99) {
}
},
fetchMessage: function(){
getMessageList({ productType: 'ZTB_FACTORY', status: 0 }).then(result => {
if(result.data && result.data.records && result.data.records.length){
let pages = getCurrentPages() //当前页面栈
let nowPage = pages[pages.length - 1] //当前页面
if(nowPage.onNotice){
nowPage.onNotice(result.data.records[0])
}
}
}).catch(err => {
})
},
onPopupChange: function({detail}){
this.setData({zIndex: detail})
},
onUnload: function(){
if(this.data.setInter) {
clearInterval(this.data.setInter)
this.data.setInter = null
}
}
})