main.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import Vue from 'vue'
  2. import App from './App'
  3. // 引入全局存储
  4. import store from './store'
  5. // 引入全局配置
  6. import $mAssetsPath from '@/config/assets.config.js';
  7. import $mConfig from '@/config/global.config.js';
  8. // 引入全局方法
  9. import { http } from '@/common/request';
  10. import $mUtil from '@/common/util.js';
  11. // 全局组件
  12. import navbar from '@/components/hx-navbar/hx-navbar.nvue';
  13. import ldLoading from '@/components/ld-loading/index.vue';
  14. import nodata from '@/components/noData/nodata.vue';
  15. import loadMore from '@/components/uni-load-more/uni-load-more.vue';
  16. import Directives from './directives/index.js';
  17. // 网络状态监听
  18. // uni.getNetworkType({
  19. // success: res => {
  20. // console.log(res)
  21. // store.dispatch('networkStateChange', res.networkType);
  22. // }
  23. // });
  24. // uni.onNetworkStatusChange(function (res) {
  25. // console.log(res+'onNetworkStatusChange')
  26. // store.dispatch('networkStateChange', res.networkType);
  27. // });
  28. if (process.env.NODE_ENV === 'production') {
  29. Vue.config.productionTip = false;
  30. }
  31. // 挂载全局自定义方法
  32. Vue.prototype.$store = store
  33. Vue.prototype.$adpid = ""
  34. Vue.prototype.$http = http;
  35. Vue.prototype.$mConfig = $mConfig;
  36. Vue.prototype.$mAssetsPath = $mAssetsPath;
  37. Vue.prototype.$mUtil = $mUtil;
  38. Vue.component('navbar',navbar);
  39. Vue.component('ldLoading', ldLoading);
  40. Vue.component('nodata',nodata);
  41. Vue.component('loadMore',loadMore);
  42. App.mpType = 'app'
  43. Vue.use(Directives);
  44. // 保留小数点后两位
  45. Vue.filter('keepTwo', value => {
  46. return (Math.floor((value || 0) * 100) / 100).toFixed(2);
  47. });
  48. // import Vue from 'vue'
  49. /**
  50. * 注册指令
  51. */
  52. const app = new Vue({
  53. store,
  54. ...App
  55. })
  56. app.$mount()