Browse Source

fix:业主端首次加载首页显示异常

master
liujiangyong 1 year ago
parent
commit
9d77025124
  1. 37
      weapp/pages/index/index.js

37
weapp/pages/index/index.js

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