helper.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 fUN_AmapLocation = uni.requireNativePlugin('FUN-AmapLocation');
  42. const getListByUserId = function() {
  43. let baseUrlNew = config.def().baseUrlNew
  44. var userInfo = uni.getStorageSync("userInfo")
  45. console.log("------", userInfo)
  46. if (userInfo) {
  47. uni.request({
  48. url: baseUrlNew + '/roleMenu/query/getListByUserId',
  49. data: {
  50. userId: userInfo.id ? userInfo.id : userInfo.data.id
  51. },
  52. method: 'GET',
  53. success: (res) => {
  54. if (res.statusCode === 200) {
  55. uni.setStorageSync("jurisdiction", res.data.data)
  56. let list = getUserAllRoles(res.data.data);
  57. uni.setStorageSync("rolesList", list)
  58. }
  59. }
  60. })
  61. }
  62. }
  63. const getUserAllRoles = (item) => {
  64. console.log(item)
  65. for (let i = 0; i < item.length; i++) {
  66. rolesList.push(item[i].name)
  67. // console.log('用户权限',rolesList)
  68. if (item[i].children && item[i].children.length > 0) {
  69. getUserAllRoles(item[i].children)
  70. }
  71. }
  72. return rolesList;
  73. }
  74. const setAudit = (item) => {
  75. let _list = uni.getStorageSync("copyTaskInfo")
  76. let _isShowbtn = true
  77. if (_list.length == 0) {
  78. _isShowbtn = false
  79. }
  80. for (let i = 0; i < _list.length; i++) {
  81. if (_list[i].businessId == item.id) {
  82. _list.splice(i, 1)
  83. uni.setStorageSync("copyTaskInfo", _list)
  84. }
  85. }
  86. if (_list.length > 0) {
  87. uni.navigateTo({
  88. url: _list[0].itemUrl + '&isShowbtn=' + _isShowbtn,
  89. })
  90. }
  91. console.log(item)
  92. }
  93. const contactCustomerService = (item) => {
  94. console.log(item)
  95. if(!item){
  96. item='110'
  97. }
  98. console.log("联系客服")
  99. uni.makePhoneCall({
  100. phoneNumber: item
  101. });
  102. }
  103. // 获取市、区简称
  104. const filterUrban = (s) => {
  105. return s.substring(0,s.length-1)
  106. }
  107. const filterArea = (q) => {
  108. return q.substring(0,q.length-1)
  109. }
  110. //获取省份简称
  111. const getProvinceAbbreviation = (province) => {
  112. if(province == "北京市"||province == "北京")
  113. return "京";
  114. else if(province == "天津市"||province == "天津")
  115. return "津";
  116. else if(province == "重庆市"||province == "重庆")
  117. return "渝";
  118. else if(province == "上海市"||province == "上海")
  119. return "沪";
  120. else if(province == "河北省"||province == "河北")
  121. return "冀";
  122. else if(province == "山西省"||province == "山西")
  123. return "晋";
  124. else if(province == "辽宁省"||province == "辽宁")
  125. return "辽";
  126. else if(province == "吉林省"||province == "吉林")
  127. return "吉";
  128. else if(province == "黑龙江省"||province == "黑龙江")
  129. return "黑";
  130. else if(province == "江苏省"||province == "江苏")
  131. return "苏";
  132. else if(province == "浙江省"||province == "浙江")
  133. return "浙";
  134. else if(province == "安徽省"||province == "安徽")
  135. return "皖";
  136. else if(province == "福建省"||province == "福建")
  137. return "闽";
  138. else if(province == "江西省"||province == "江西")
  139. return "赣";
  140. else if(province == "山东省"||province == "山东")
  141. return "鲁";
  142. else if(province == "河南省"||province == "河南")
  143. return "豫";
  144. else if(province == "湖北省"||province == "湖北")
  145. return "鄂";
  146. else if(province == "湖南省"||province == "湖南")
  147. return "湘";
  148. else if(province == "广东省"||province == "广东")
  149. return "粤";
  150. else if(province == "海南省"||province == "海南")
  151. return "琼";
  152. else if(province == "四川省"||province == "四川")
  153. return "川";
  154. else if(province == "贵州省"||province == "贵州")
  155. return "贵";
  156. else if(province == "云南省"||province == "云南")
  157. return "云";
  158. else if(province == "陕西省"||province == "陕西")
  159. return "陕";
  160. else if(province == "甘肃省"||province == "甘肃")
  161. return "甘";
  162. else if(province == "青海省"||province == "青海")
  163. return "青";
  164. else if(province == "台湾省"||province == "台湾")
  165. return "台";
  166. else if(province == "内蒙古自治区"||province == "内蒙古")
  167. return "蒙";
  168. else if(province == "广西壮族自治区"||province == "广西")
  169. return "桂";
  170. else if(province == "宁夏回族自治区"||province == "宁夏")
  171. return "宁";
  172. else if(province == "新疆维吾尔自治区"||province == "新疆")
  173. return "新";
  174. else if(province == "西藏自治区"||province == "西藏")
  175. return "藏";
  176. else if(province == "香港特别行政区"||province == "香港")
  177. return "港";
  178. else if(province == "澳门特别行政区"||province == "澳门")
  179. return "澳";
  180. }
  181. export default {
  182. getListByUserId,
  183. setAudit,
  184. ossUploadUrl,
  185. contactCustomerService,
  186. chooseImage,
  187. imgType,
  188. imgTypeList,
  189. makeValidityPeriod,
  190. getProvinceAbbreviation,
  191. filterUrban,
  192. filterArea,
  193. fUN_AmapLocation
  194. }