index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* 操作权限验证
  2. * str 为权限字符 用于匹配操作角色的字符
  3. * str === performEvacuation 应急疏散操作权限
  4. * str === checkGentle 安全检查
  5. */
  6. export function controlsRestrictVerify(str) {
  7. if(str){
  8. let controlsRestrict = uni.getStorageSync('controlsRestrict');
  9. return controlsRestrict.indexOf(str) != -1;
  10. }else{
  11. return false
  12. }
  13. }
  14. /* 页面权限验证
  15. * str 为权限字符 用于匹配操作角色的字符
  16. */
  17. export function pageRestrictVerify(str) {
  18. if(str){
  19. let permissions = uni.getStorageSync('permissions')+'';
  20. return permissions.indexOf(str) != -1;
  21. }else{
  22. return false
  23. }
  24. }
  25. /* 硬件控制与视频监控权限验证(校级管理员/院级管理员/实验室管理员)
  26. subAdminId 传入的实验室管理员ID
  27. schoolId 校级管理员身份ID
  28. collegeId 院级管理员身份ID
  29. userInfo.position 当前用户身份ID (系统用户为NULL)
  30. userInfo.userId 当前用户userID
  31. */
  32. export function itoOrVideoLimits(subAdminId) {
  33. console.log('subAdminId',subAdminId)
  34. let userInfo = uni.getStorageSync('user');
  35. let schoolId = '1815293314666532865';
  36. let collegeId = '1815336278075838465';
  37. if(userInfo.position == null){
  38. //如果是管理员(系统用户)
  39. return true
  40. }else if(userInfo.position == schoolId || userInfo.position == collegeId){
  41. //如果是校级管理员/院级管理员
  42. return true
  43. }else if(userInfo.userId == subAdminId){
  44. //如果当前用户userId 与 管理员ID相等
  45. return true
  46. }else{
  47. return false
  48. }
  49. }