index.js 973 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import {
  2. AES,
  3. mode,
  4. pad,
  5. enc
  6. } from "crypto-js";
  7. //aes加密
  8. export function encryptByEnAES(data = '') {
  9. let Key = "dsadmin";
  10. let tmpAES = AES.encrypt(data, Key, {
  11. mode: mode.CBC,
  12. padding: pad.Pkcs7,
  13. });
  14. return tmpAES.toString();
  15. }
  16. //aes解密
  17. export function encryptByDeAES(data = '') {
  18. let Key = "dsadmin";
  19. let tmpDeAES = AES.decrypt(data, Key, {
  20. mode: mode.CBC,
  21. padding: pad.Pkcs7,
  22. });
  23. return tmpDeAES.toString(enc.Utf8);
  24. }
  25. // 简单的模拟枚举
  26. export function createEnum(arr = []) {
  27. let obj = {}
  28. arr.forEach(v => {
  29. obj[obj[v.name] = v.value] = v.name;
  30. })
  31. return Object.freeze(obj);
  32. };
  33. // 获取页面栈,默认0是当前页面栈
  34. export function getCurrentPagesSeimin(num = 0) {
  35. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  36. let curRoute = routes[routes.length - 1 - num].route // 获取当前页面路由,也就是最后一个打开的页面路由
  37. return curRoute;
  38. };