diff --git a/weapp/pages/index/index.js b/weapp/pages/index/index.js index 8f8bbb0..b922663 100644 --- a/weapp/pages/index/index.js +++ b/weapp/pages/index/index.js @@ -15,7 +15,7 @@ Page({ isShowCallout: false, }, - setMarkers (project, todayRecord) { + setMarkers(project, todayRecord) { const markers = project.map(p => { let todayCount = 0; todayRecord.forEach(r => { @@ -42,7 +42,7 @@ Page({ }, // 获取结构物和今日巡检次数 - getData () { + getData() { const that = this; wx.showLoading({ title: '加载中' }) const promiseArr = []; @@ -64,18 +64,18 @@ Page({ }) }, - showCallout () { + showCallout() { this.setData( { isShowCallout: !this.data.isShowCallout }, () => { this.setMarkers(this.data.markers, this.data.todayRecord); } ); }, - onRefresh () { + onRefresh() { this.getData(); }, - onMarkerTap (e) { + onMarkerTap(e) { const describe = this.data.project.find(p => p.id === e.detail.markerId).describe || ''; wx.navigateTo({ url: `/package/pointsStatus/pointsStatus?projectId=${e.detail.markerId}&describe=${describe}` }) }, @@ -83,7 +83,7 @@ Page({ /** * 生命周期函数--监听页面加载 */ - onLoad (options) { + onLoad(options) { const userInfo = wx.getStorageSync('userInfo'); if (!userInfo || !userInfo.id) { wx.reLaunch({ @@ -95,61 +95,68 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady () { + onReady() { }, /** * 生命周期函数--监听页面显示 */ - onShow () { + onShow() { const userInfo = wx.getStorageSync('userInfo'); if (!userInfo || !userInfo.id) { wx.reLaunch({ url: '/pages/login/login' }); - } else { - this.getData(); - if (typeof this.getTabBar === 'function' && this.getTabBar()) { - this.getTabBar().setData({ - selected: 0 - }) - } + return + } + const userRole = wx.getStorageSync('userRole'); + if (userRole && userRole.includes('管理')) { + wx.reLaunch({ + url: '/pages/home/home' + }); + return + } + this.getData(); + if (typeof this.getTabBar === 'function' && this.getTabBar()) { + this.getTabBar().setData({ + selected: 0 + }) } }, /** * 生命周期函数--监听页面隐藏 */ - onHide () { + onHide() { }, /** * 生命周期函数--监听页面卸载 */ - onUnload () { + onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh () { + onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ - onReachBottom () { + onReachBottom() { }, /** * 用户点击右上角分享 */ - onShareAppMessage () { + onShareAppMessage() { } }) \ No newline at end of file