methods-util.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { Util } from 'naf-core';
  2. const { isNullOrUndefined } = Util;
  3. export default {
  4. //判断信息是否过期
  5. isDateOff(dataDate) {
  6. const now = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
  7. dataDate = new Date(dataDate);
  8. return now.getTime() <= dataDate.getTime();
  9. },
  10. //判断企业是否可以执行此动作/显示
  11. checkCorp(data) {
  12. const { role, unit, selfUnit, status, displayType, userid } = data;
  13. if (!isNullOrUndefined(selfUnit) && !isNullOrUndefined(status)) {
  14. return role === 'corp' && selfUnit === unit && status === '0';
  15. } else if (!isNullOrUndefined(displayType)) {
  16. if (role === 'corp') {
  17. return role === displayType;
  18. } else {
  19. return role === displayType && !isNullOrUndefined(userid);
  20. }
  21. }
  22. },
  23. //获取url的参数params
  24. getParams() {
  25. let str = location.href;
  26. let num = str.indexOf('?');
  27. const param = {};
  28. str = str.substr(num + 1);
  29. let num2 = str.indexOf('#');
  30. let str2 = '';
  31. if (num2 > 0) {
  32. str2 = str.substr(0, num2);
  33. } else {
  34. num2 = str.indexOf('/');
  35. str2 = str.substr(0, num2);
  36. }
  37. const arr = str2.split('&');
  38. for (let i = 0; i < arr.length; i++) {
  39. num = arr[i].indexOf('=');
  40. if (num > 0) {
  41. const name = arr[i].substring(0, num);
  42. const value = arr[i].substr(num + 1);
  43. param[name] = decodeURI(value);
  44. }
  45. }
  46. return param;
  47. },
  48. };