helper.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 makeValidityPeriod = function(type) {
  18. //获取当前年
  19. let nowDate = new Date();
  20. let year = nowDate.getFullYear()
  21. let _list = []
  22. let _list1 = []
  23. // let _list2 = ["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]
  24. let _list2 = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
  25. let _list3 = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14",
  26. "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30",
  27. "31"
  28. ]
  29. let _ValidityPeriod = []
  30. for (let i = 0; i < 30; i++) {
  31. _list1.push(year + i)
  32. }
  33. if (type == 0) {
  34. _list1.unshift('长期')
  35. _list2.unshift('')
  36. _list3.unshift('')
  37. }
  38. _list.push(_list1, _list2, _list3)
  39. return _list
  40. }
  41. const getListByUserId = function() {
  42. let baseUrlNew = config.def().baseUrlNew
  43. var userInfo = uni.getStorageSync("userInfo")
  44. console.log("------", userInfo)
  45. if (userInfo) {
  46. uni.request({
  47. url: baseUrlNew + '/roleMenu/query/getListByUserId',
  48. data: {
  49. userId: userInfo.id ? userInfo.id : userInfo.data.id
  50. },
  51. method: 'GET',
  52. success: (res) => {
  53. if (res.statusCode === 200) {
  54. uni.setStorageSync("jurisdiction", res.data.data)
  55. let list = getUserAllRoles(res.data.data);
  56. uni.setStorageSync("rolesList", list)
  57. }
  58. }
  59. })
  60. }
  61. }
  62. const getUserAllRoles = (item) => {
  63. console.log(item)
  64. for (let i = 0; i < item.length; i++) {
  65. rolesList.push(item[i].name)
  66. // console.log('用户权限',rolesList)
  67. if (item[i].children && item[i].children.length > 0) {
  68. getUserAllRoles(item[i].children)
  69. }
  70. }
  71. return rolesList;
  72. }
  73. const setAudit = (item) => {
  74. let _list = uni.getStorageSync("copyTaskInfo")
  75. let _isShowbtn = true
  76. if (_list.length == 0) {
  77. _isShowbtn = false
  78. }
  79. for (let i = 0; i < _list.length; i++) {
  80. if (_list[i].businessId == item.id) {
  81. _list.splice(i, 1)
  82. uni.setStorageSync("copyTaskInfo", _list)
  83. }
  84. }
  85. if (_list.length > 0) {
  86. uni.navigateTo({
  87. url: _list[0].itemUrl + '&isShowbtn=' + _isShowbtn,
  88. })
  89. }
  90. console.log(item)
  91. }
  92. const contactCustomerService = (item) => {
  93. console.log(item)
  94. console.log("联系客服")
  95. uni.makePhoneCall({
  96. phoneNumber: '114' //仅为示例
  97. });
  98. }
  99. export default {
  100. getListByUserId,
  101. setAudit,
  102. ossUploadUrl,
  103. contactCustomerService,
  104. chooseImage,
  105. imgType,
  106. imgTypeList,
  107. makeValidityPeriod
  108. }