main.js 2.1 KB

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