main.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import Vue from 'vue';
  2. import App from './App';
  3. import uView from 'uview-ui';
  4. Vue.use(uView);
  5. import { myRequest } from './util/api.js';
  6. Vue.prototype.$myRequest = myRequest;
  7. Vue.config.productionTip = false;
  8. App.mpType = 'app';
  9. import config from './util/neutral.js';
  10. Vue.prototype.$isneutral = config.isneutral;
  11. Vue.prototype.$imageURL = config.imageURL;// 线上图片服务器路径常量
  12. import { QueryPermission } from './util/QueryPermission.js';
  13. Vue.prototype.$QueryPermission = QueryPermission;
  14. // 自定义卡片
  15. import customCard from './components/customCard/customCard.vue';
  16. Vue.component('customCard', customCard);
  17. Vue.filter('timeFormat', function (time,fmt = 'yyyy-MM-dd hh:mm:ss') {
  18. function fun(a) {
  19. return String(a).length == 1 ? '0' + a : a;
  20. }
  21. let $this = new Date(time*1000);
  22. let o = {
  23. 'M+': $this.getMonth() + 1,
  24. 'd+': $this.getDate(),
  25. 'h+': $this.getHours(),
  26. 'm+': $this.getMinutes(),
  27. 's+': $this.getSeconds(),
  28. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  29. S: $this.getMilliseconds(),
  30. };
  31. if (/(y+)/.test(fmt)) {
  32. fmt = fmt.replace(
  33. RegExp.$1,
  34. ($this.getFullYear() + '').substr(4 - RegExp.$1.length)
  35. );
  36. }
  37. for (var k in o) {
  38. if (new RegExp('(' + k + ')').test(fmt)) {
  39. fmt = fmt.replace(
  40. RegExp.$1,
  41. RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
  42. );
  43. }
  44. }
  45. return fmt;
  46. });
  47. Vue.prototype.formatTime = function (thistime, fmt = 'yyyy-MM-dd hh:mm:ss') {
  48. let $this = new Date(thistime);
  49. let o = {
  50. 'M+': $this.getMonth() + 1,
  51. 'd+': $this.getDate(),
  52. 'h+': $this.getHours(),
  53. 'm+': $this.getMinutes(),
  54. 's+': $this.getSeconds(),
  55. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  56. S: $this.getMilliseconds(),
  57. };
  58. if (/(y+)/.test(fmt)) {
  59. fmt = fmt.replace(
  60. RegExp.$1,
  61. ($this.getFullYear() + '').substr(4 - RegExp.$1.length)
  62. );
  63. }
  64. for (var k in o) {
  65. if (new RegExp('(' + k + ')').test(fmt)) {
  66. fmt = fmt.replace(
  67. RegExp.$1,
  68. RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
  69. );
  70. }
  71. }
  72. return fmt;
  73. };
  74. const app = new Vue({
  75. ...App,
  76. });
  77. app.$mount();