main.js 2.0 KB

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