Browse Source

权限控制

dev
巴林闲侠 2 years ago
parent
commit
1858235eb6
  1. 4
      api/app/lib/controllers/auth/index.js
  2. 27
      weapp/src/pages/home/index.jsx
  3. 26
      weapp/src/pages/user/index.jsx

4
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;

27
weapp/src/pages/home/index.jsx

@ -43,9 +43,14 @@ const Index = () => {
})
}
function judgeRight (code) {
return userInfo && userInfo.userResources && userInfo.userResources.some(item => item.resourceId === code)
}
return (
<View className='page'>
{
judgeRight('WXPATROLREPOR') ?
<View className='card fill'>
<View className='title'> </View>
<View className='btn' onClick={
@ -56,7 +61,10 @@ const Index = () => {
{isSuperAdmin ? '查看' : '填报'}
</View>
</View>
: ''
}
{
judgeRight('WXMAINTENANCEREPORT') ?
<View className='card fill'>
<View className='title'> </View>
<View className='btn' onClick={
@ -66,8 +74,10 @@ const Index = () => {
}>
{isSuperAdmin ? '查看' : '填报'}
</View>
</View>
</View> : ''
}
{
judgeRight('WXBUILDINGROAD') ?
<View className='card fill_road'>
<View className='title'> </View>
<View className='btn' onClick={
@ -77,8 +87,10 @@ const Index = () => {
}>
{isSuperAdmin ? '查看' : '填报'}
</View>
</View>
</View> : ''
}
{
judgeRight('WXFEEDBACKMANAGE') ?
<View className='card fill_anomaly'>
<View className='title'> </View>
<View className='btn' onClick={
@ -88,7 +100,8 @@ const Index = () => {
}>
{isSuperAdmin ? '查看' : '填报'}
</View>
</View>
</View> : ''
}
{/* {
isSuperAdmin &&

26
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 (
<View className='page'>
<View className='myBox'>
@ -64,14 +68,18 @@ const Index = ({ ...props }) => {
</View>
</View>
{
judgeRight('WXPATROLREPOR') ?
<View className='box' onClick={isSuperAdmin ? () => toPatrolReport('patrol') : () => toMyReport('patrol')}>
<Image className='box-img' src={reportImg} />
<View className='box-txt'>
{isSuperAdmin ? '巡查上报' : '巡查上报'}
</View>
<Image className='img' src={moreImg} />
</View>
</View> : ''
}
{
judgeRight('WXMAINTENANCEREPORT') ?
<View className='box' onClick={isSuperAdmin ? () => toPatrolReport('conserve') : () => toMyReport('conserve')}>
<Image className='box-img' src={reportImg} />
<View className='box-txt'>
@ -79,15 +87,20 @@ const Index = ({ ...props }) => {
</View>
<Image className='img' src={moreImg} />
</View>
: ''
}
{
judgeRight('WXBUILDINGROAD') ?
<View className='box' onClick={isSuperAdmin ? () => toPatrolReport('road') : () => toMyReport('road')}>
<Image className='box-img' src={reportImg} />
<View className='box-txt'>
{isSuperAdmin ? '在建道路上报' : '在建道路'}
</View>
<Image className='img' src={moreImg} />
</View>
</View> : ''
}
{
judgeRight('WXFEEDBACKMANAGE') ?
<View className='box' onClick={isSuperAdmin ? () => toPatrolReport('anomaly') : () => toMyReport('anomaly')}>
<Image className='box-img' src={reportImg} />
<View className='box-txt'>
@ -95,7 +108,8 @@ const Index = ({ ...props }) => {
</View>
<Image className='img' src={moreImg} />
</View>
: ''
}
<View className='box' onClick={changePassword} style={{ marginTop: '2rpx' }}>
<Image className='box-img' src={pswdImg} />
<View className='box-txt'>修改密码</View>

Loading…
Cancel
Save