main.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import App from "./App";
  2. // #ifndef VUE3
  3. import Vue from "vue";
  4. Vue.config.productionTip = false;
  5. App.mpType = "app";
  6. Vue.prototype.$getOpenId = new Promise(resolve => {
  7. Vue.prototype.$isResolve = resolve;
  8. })
  9. const app = new Vue({
  10. ...App,
  11. });
  12. app.$mount();
  13. // #endif
  14. // #ifdef VUE3
  15. import {createSSRApp} from "vue";
  16. export function createApp() {
  17. const app = createSSRApp(App);
  18. return {
  19. app,
  20. };
  21. }
  22. // #endif
  23. Vue.filter("globalTime", function (value) {
  24. if (value) {
  25. const time = new Date(value * 1000);
  26. const y = time.getFullYear();
  27. const m =
  28. time.getMonth() + 1 < 10
  29. ? "0" + (time.getMonth() + 1)
  30. : time.getMonth() + 1;
  31. const d = time.getDate() < 10 ? "0" + time.getDate() : time.getDate();
  32. // const h = time.getHours()
  33. // const mm = time.getMinutes();
  34. // const s = time.getSeconds();
  35. return y + "-" + m + "-" + d;
  36. } else {
  37. return "";
  38. }
  39. });
  40. Vue.filter("globalTimeSecond", function (value) {
  41. if (value) {
  42. const time = new Date(value * 1000);
  43. // const y = time.getFullYear();
  44. // const m = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
  45. // const d = time.getDate() < 10 ? '0' + time.getDate(): time.getDate();
  46. const h = time.getHours() < 10 ? '0' + time.getHours() : time.getHours();
  47. const mm = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes();
  48. const s = time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds();
  49. return h + ":" + mm + ":" + s;
  50. // return h + ":" + mm;
  51. } else {
  52. return "";
  53. }
  54. });
  55. Vue.filter("nameFilter", function (value) {
  56. if (value) {
  57. let start = new Array(value.length).join('*');
  58. let end = value.slice(0,1);
  59. return `${end}${start}`
  60. } else {
  61. return "";
  62. }
  63. });
  64. Vue.filter("phoneFilter", function (value) {
  65. if (value) {
  66. let reg = /^(.{3}).*(.{4})$/
  67. return value.replace(reg,'$1****$2')
  68. } else {
  69. return "";
  70. }
  71. });