main.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.$imageURL_58003 = config.imageURL_58003;// 线上图片服务器路径常量 58003
  11. Vue.prototype.$imageURL = config.imageURL;//8006
  12. import { QueryPermission } from './util/QueryPermission.js';
  13. // Vue.use(QueryPermission)
  14. Vue.prototype.$QueryPermission = QueryPermission;
  15. import customCard from './components/customCard/customCard.vue';
  16. Vue.component('customCard', customCard);
  17. Vue.filter('timeFormat', function (time) {
  18. function fun(a) {
  19. return String(a).length == 1 ? '0' + a : a;
  20. }
  21. let date = new Date(time * 1000);
  22. let y = date.getFullYear();
  23. let m = date.getMonth() + 1;
  24. let d = date.getDate();
  25. let h = date.getHours();
  26. let min = date.getMinutes();
  27. let sec = date.getSeconds();
  28. return `${y}-${fun(m)}-${fun(d)} ${fun(h)}:${fun(min)}:${fun(sec)}`;
  29. });
  30. Vue.prototype.formatTime = function (thistime, fmt = 'yyyy-MM-dd hh:mm:ss') {
  31. let $this = new Date(thistime);
  32. let o = {
  33. 'M+': $this.getMonth() + 1,
  34. 'd+': $this.getDate(),
  35. 'h+': $this.getHours(),
  36. 'm+': $this.getMinutes(),
  37. 's+': $this.getSeconds(),
  38. 'q+': Math.floor(($this.getMonth() + 3) / 3),
  39. S: $this.getMilliseconds(),
  40. };
  41. if (/(y+)/.test(fmt)) {
  42. fmt = fmt.replace(
  43. RegExp.$1,
  44. ($this.getFullYear() + '').substr(4 - RegExp.$1.length)
  45. );
  46. }
  47. for (var k in o) {
  48. if (new RegExp('(' + k + ')').test(fmt)) {
  49. fmt = fmt.replace(
  50. RegExp.$1,
  51. RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
  52. );
  53. }
  54. }
  55. return fmt;
  56. };
  57. const app = new Vue({
  58. ...App,
  59. });
  60. app.$mount();