index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // 存放页面公用数据、方法...
  2. export default {
  3. data() {
  4. return {
  5. }
  6. },
  7. mixins: [],
  8. onLoad() {
  9. },
  10. methods: {
  11. //检查文件类型
  12. $checkFileType(url) {
  13. if (!url) return '';
  14. if (url.indexOf('?') >= 0) {
  15. url = url.slice(0, url.indexOf('?'));
  16. }
  17. const fileSuffix = url.substring(url.lastIndexOf(".") + 1);
  18. const wordList = ['doc', 'docx', 'dot', 'wps', 'wpt'];
  19. const excelList = ['xls', 'xlsx', 'xlt', 'et', 'ett'];
  20. const pptList = ['ppt', 'pptx', 'dps', 'dpt', 'pot', 'pps'];
  21. const pdfList = ['pdf'];
  22. const imgList = ['jpg', 'jpeg', 'png'];
  23. const videoList = ['mp4'];
  24. if (wordList.indexOf(fileSuffix) >= 0) {
  25. return 'word';
  26. } else if (excelList.indexOf(fileSuffix) >= 0) {
  27. return 'excel';
  28. } else if (pptList.indexOf(fileSuffix) >= 0) {
  29. return 'ppt';
  30. } else if (pdfList.indexOf(fileSuffix) >= 0) {
  31. return 'pdf';
  32. } else if (imgList.indexOf(fileSuffix) >= 0) {
  33. return 'img';
  34. } else if (videoList.indexOf(fileSuffix) >= 0) {
  35. return 'video';
  36. } else {
  37. return '';
  38. }
  39. },
  40. //密码转化成密文
  41. $passwordFn(id, pas) {
  42. let k = 123456789
  43. for (let i = 0; i < id.length; i++) {
  44. let a = (id[i].charCodeAt() % 13) + 1
  45. k = ((k * a) % 9999999) + 1
  46. }
  47. k = (k % 98989898) + 99
  48. for (let i = 0; i < pas.length; i++) {
  49. let a = (pas[i].charCodeAt() % 17) + 1
  50. k = ((k % 9876543) + 1) * a
  51. }
  52. let res = k % 100000000
  53. // console.log(res, k, id, pas);
  54. return new Intl.NumberFormat(undefined, {
  55. minimumIntegerDigits: 8,
  56. useGrouping: false
  57. }).format(res)
  58. },
  59. test() {
  60. console.log('mixins');
  61. }
  62. }
  63. }