index.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import {
  2. isWeixin
  3. } from '@/common/utils/common';
  4. // #ifdef H5
  5. import wx from 'weixin-js-sdk'
  6. // #endif
  7. // 存放页面公用数据、方法...
  8. export default {
  9. data() {
  10. return {
  11. }
  12. },
  13. mixins: [],
  14. onLoad() {
  15. },
  16. mounted() {
  17. if (isWeixin()) {
  18. // 去除顶部
  19. var uni_page_head = document.querySelector("uni-page-head[uni-page-head-type='default']")
  20. if (uni_page_head) {
  21. uni_page_head.remove()
  22. }
  23. // 去除底部
  24. var uni_tabbar_bottom = document.getElementsByClassName("uni-tabbar-bottom")
  25. if (uni_tabbar_bottom.length) {
  26. uni_tabbar_bottom[0].remove()
  27. var uni_page_wrapper = document.getElementsByTagName("uni-page-wrapper")
  28. if (uni_page_wrapper.length) {
  29. uni_page_wrapper[0].setAttribute('style', 'height: calc(100% - env(safe-area-inset-bottom)) !important')
  30. }
  31. }
  32. }
  33. },
  34. methods: {
  35. //检查文件类型
  36. $checkFileType(url) {
  37. if (!url) return '';
  38. if (url.indexOf('?') >= 0) {
  39. url = url.slice(0, url.indexOf('?'));
  40. }
  41. const fileSuffix = url.substring(url.lastIndexOf(".") + 1);
  42. const wordList = ['doc', 'docx', 'dot', 'wps', 'wpt'];
  43. const excelList = ['xls', 'xlsx', 'xlt', 'et', 'ett'];
  44. const pptList = ['ppt', 'pptx', 'dps', 'dpt', 'pot', 'pps'];
  45. const pdfList = ['pdf'];
  46. const imgList = ['jpg', 'jpeg', 'png'];
  47. const videoList = ['mp4'];
  48. if (wordList.indexOf(fileSuffix) >= 0) {
  49. return 'word';
  50. } else if (excelList.indexOf(fileSuffix) >= 0) {
  51. return 'excel';
  52. } else if (pptList.indexOf(fileSuffix) >= 0) {
  53. return 'ppt';
  54. } else if (pdfList.indexOf(fileSuffix) >= 0) {
  55. return 'pdf';
  56. } else if (imgList.indexOf(fileSuffix) >= 0) {
  57. return 'img';
  58. } else if (videoList.indexOf(fileSuffix) >= 0) {
  59. return 'video';
  60. } else {
  61. return '';
  62. }
  63. },
  64. //密码转化成密文
  65. $passwordFn(id, pas) {
  66. let k = 123456789
  67. for (let i = 0; i < id.length; i++) {
  68. let a = (id[i].charCodeAt() % 13) + 1
  69. k = ((k * a) % 9999999) + 1
  70. }
  71. k = (k % 98989898) + 99
  72. for (let i = 0; i < pas.length; i++) {
  73. let a = (pas[i].charCodeAt() % 17) + 1
  74. k = ((k % 9876543) + 1) * a
  75. }
  76. let res = k % 100000000
  77. // console.log(res, k, id, pas);
  78. return new Intl.NumberFormat(undefined, {
  79. minimumIntegerDigits: 8,
  80. useGrouping: false
  81. }).format(res)
  82. },
  83. test() {
  84. console.log('mixins');
  85. }
  86. }
  87. }