helper.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import * as config from '../config'
  2. const rolesList = []
  3. const ossUploadUrl = 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/';
  4. const chooseImage = {
  5. count: '1',
  6. sizeType: ['original', 'compressed'],
  7. sourceType: ['album'],
  8. }
  9. const imgType = '请选择图片来源'
  10. const imgTypeList = [{
  11. name: '相册',
  12. },
  13. {
  14. name: '拍照',
  15. }
  16. ]
  17. const getListByUserId = function() {
  18. let baseUrlNew = config.def().baseUrlNew
  19. var userInfo = uni.getStorageSync("userInfo")
  20. console.log("------", userInfo)
  21. if (userInfo) {
  22. uni.request({
  23. url: baseUrlNew + '/roleMenu/query/getListByUserId',
  24. data: {
  25. userId: userInfo.id ? userInfo.id : userInfo.data.id
  26. },
  27. method: 'GET',
  28. success: (res) => {
  29. if (res.statusCode === 200) {
  30. uni.setStorageSync("jurisdiction", res.data.data)
  31. let list = getUserAllRoles(res.data.data);
  32. uni.setStorageSync("rolesList", list)
  33. }
  34. }
  35. })
  36. }
  37. }
  38. const getUserAllRoles = (item) => {
  39. console.log(item)
  40. for (let i = 0; i < item.length; i++) {
  41. rolesList.push(item[i].name)
  42. // console.log('用户权限',rolesList)
  43. if (item[i].children && item[i].children.length > 0) {
  44. getUserAllRoles(item[i].children)
  45. }
  46. }
  47. return rolesList;
  48. }
  49. const setAudit = (item) => {
  50. let _list = uni.getStorageSync("copyTaskInfo")
  51. let _isShowbtn = true
  52. if (_list.length == 0) {
  53. _isShowbtn = false
  54. }
  55. for (let i = 0; i < _list.length; i++) {
  56. if (_list[i].businessId == item.id) {
  57. _list.splice(i, 1)
  58. uni.setStorageSync("copyTaskInfo", _list)
  59. }
  60. }
  61. if (_list.length > 0) {
  62. uni.navigateTo({
  63. url: _list[0].itemUrl + '&isShowbtn=' + _isShowbtn,
  64. })
  65. }
  66. console.log(item)
  67. }
  68. const contactCustomerService = (item) => {
  69. console.log(item)
  70. console.log("联系客服")
  71. uni.makePhoneCall({
  72. phoneNumber: '114' //仅为示例
  73. });
  74. }
  75. export default {
  76. getListByUserId,
  77. setAudit,
  78. ossUploadUrl,
  79. contactCustomerService,
  80. chooseImage,
  81. imgType,
  82. imgTypeList
  83. }