diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index e77ad9b0..f2554ee0 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -90,6 +90,10 @@ async function wxLogin(ctx, next) { delete: false, }, attributes: { exclude: ['password', 'delete'] }, + include: [{ + attributes: ["resourceId", "isshow"], + model: models.UserResource + }] }); if (!userRes) { ctx.status = 400; diff --git a/weapp/src/pages/home/index.jsx b/weapp/src/pages/home/index.jsx index e6a155d2..2479777a 100644 --- a/weapp/src/pages/home/index.jsx +++ b/weapp/src/pages/home/index.jsx @@ -43,52 +43,65 @@ const Index = () => { }) } + function judgeRight (code) { + return userInfo && userInfo.userResources && userInfo.userResources.some(item => item.resourceId === code) + } + return ( - - - 巡 查 上 报 - toPatrolView('patrol') - : () => toPatrol('patrol') - }> - {isSuperAdmin ? '查看' : '填报'} - - - - - 养 护 上 报 - toPatrolView('conserve') - : () => toPatrol('conserve') - }> - {isSuperAdmin ? '查看' : '填报'} - - - - - 在 建 道 路 - toPatrolView('road') - : () => toPatrol('road') - }> - {isSuperAdmin ? '查看' : '填报'} - - - - - 异 常 反 馈 - toPatrolView('anomaly') - : () => toPatrol('anomaly') - }> - {isSuperAdmin ? '查看' : '填报'} - - + { + judgeRight('WXPATROLREPOR') ? + + 巡 查 上 报 + toPatrolView('patrol') + : () => toPatrol('patrol') + }> + {isSuperAdmin ? '查看' : '填报'} + + + : '' + } + { + judgeRight('WXMAINTENANCEREPORT') ? + + 养 护 上 报 + toPatrolView('conserve') + : () => toPatrol('conserve') + }> + {isSuperAdmin ? '查看' : '填报'} + + : '' + } + { + judgeRight('WXBUILDINGROAD') ? + + 在 建 道 路 + toPatrolView('road') + : () => toPatrol('road') + }> + {isSuperAdmin ? '查看' : '填报'} + + : '' + } + { + judgeRight('WXFEEDBACKMANAGE') ? + + 异 常 反 馈 + toPatrolView('anomaly') + : () => toPatrol('anomaly') + }> + {isSuperAdmin ? '查看' : '填报'} + + : '' + } {/* { isSuperAdmin && diff --git a/weapp/src/pages/user/index.jsx b/weapp/src/pages/user/index.jsx index 83c5c9c2..5472a55a 100644 --- a/weapp/src/pages/user/index.jsx +++ b/weapp/src/pages/user/index.jsx @@ -52,6 +52,10 @@ const Index = ({ ...props }) => { }) } + function judgeRight (code) { + return userInfo && userInfo.userResources && userInfo.userResources.some(item => item.resourceId === code) + } + return ( @@ -64,38 +68,48 @@ const Index = ({ ...props }) => { - toPatrolReport('patrol') : () => toMyReport('patrol')}> - - - {isSuperAdmin ? '巡查上报' : '巡查上报'} - - - - - toPatrolReport('conserve') : () => toMyReport('conserve')}> - - - {isSuperAdmin ? '养护上报' : '养护上报'} - - - - - toPatrolReport('road') : () => toMyReport('road')}> - - - {isSuperAdmin ? '在建道路上报' : '在建道路'} - - - - - toPatrolReport('anomaly') : () => toMyReport('anomaly')}> - - - {isSuperAdmin ? '异常反馈上报' : '异常反馈'} - - - - + { + judgeRight('WXPATROLREPOR') ? + toPatrolReport('patrol') : () => toMyReport('patrol')}> + + + {isSuperAdmin ? '巡查上报' : '巡查上报'} + + + : '' + } + { + judgeRight('WXMAINTENANCEREPORT') ? + toPatrolReport('conserve') : () => toMyReport('conserve')}> + + + {isSuperAdmin ? '养护上报' : '养护上报'} + + + + : '' + } + { + judgeRight('WXBUILDINGROAD') ? + toPatrolReport('road') : () => toMyReport('road')}> + + + {isSuperAdmin ? '在建道路上报' : '在建道路'} + + + : '' + } + { + judgeRight('WXFEEDBACKMANAGE') ? + toPatrolReport('anomaly') : () => toMyReport('anomaly')}> + + + {isSuperAdmin ? '异常反馈上报' : '异常反馈'} + + + + : '' + } 修改密码