helper.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import * as config from '../config'
  2. const rolesList = []
  3. const getListByUserId = function() {
  4. let baseUrlNew = config.def().baseUrlNew
  5. var userInfo = uni.getStorageSync("userInfo")
  6. console.log("------",userInfo)
  7. if(userInfo){
  8. uni.request({
  9. url: baseUrlNew + '/roleMenu/query/getListByUserId',
  10. data: {
  11. userId: userInfo.id?userInfo.id:userInfo.data.id
  12. },
  13. method: 'GET',
  14. success: (res) => {
  15. if (res.statusCode === 200) {
  16. uni.setStorageSync("jurisdiction", res.data.data)
  17. let list = getUserAllRoles(res.data.data);
  18. uni.setStorageSync("rolesList", list)
  19. }
  20. }
  21. })
  22. }
  23. }
  24. const getUserAllRoles = (item) => {
  25. console.log(item)
  26. for (let i = 0; i < item.length; i++) {
  27. rolesList.push(item[i].name)
  28. // console.log('用户权限',rolesList)
  29. if (item[i].children && item[i].children.length > 0) {
  30. getUserAllRoles(item[i].children)
  31. }
  32. }
  33. return rolesList;
  34. }
  35. const setAudit = (item) => {
  36. let _list = uni.getStorageSync("copyTaskInfo")
  37. let _isShowbtn = true
  38. if (_list.length == 0) {
  39. _isShowbtn = false
  40. }
  41. for (let i = 0; i < _list.length; i++) {
  42. if (_list[i].businessId == item.id) {
  43. _list.splice(i, 1)
  44. uni.setStorageSync("copyTaskInfo", _list)
  45. }
  46. }
  47. if (_list.length > 0) {
  48. uni.navigateTo({
  49. url: _list[0].itemUrl + '&isShowbtn=' + _isShowbtn,
  50. })
  51. }
  52. console.log(item)
  53. }
  54. export default {
  55. getListByUserId,
  56. setAudit
  57. }