main.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import Vue from 'vue'
  2. import store from './store'
  3. import App from './App'
  4. import goPage from '@/mixin/goPage.js'
  5. import * as utils from "@/access/utils.js"
  6. import * as common from "@/access/common.js"
  7. import Tabbar from '@/components/Tabbar/index';
  8. import empty from '@/components/empty/index.vue'
  9. Vue.component('Tabbar', Tabbar)
  10. Vue.component('Aempty', empty)
  11. // 数字精度计算
  12. import NP from "number-precision";
  13. Vue.prototype.$NP = NP; // 高精度数学计算
  14. import uView from "uview-ui";
  15. Vue.use(uView);
  16. const msg = (title, duration = 1500, mask = false, icon = 'none') => {
  17. //统一提示方便全局修改
  18. if (Boolean(title) === false) {
  19. return;
  20. }
  21. uni.showToast({
  22. title,
  23. duration,
  24. mask,
  25. icon
  26. });
  27. }
  28. const prePage = () => {
  29. let pages = getCurrentPages();
  30. let prePage = pages[pages.length - 2];
  31. // #ifdef H5
  32. return prePage;
  33. // #endif
  34. return prePage.$vm;
  35. }
  36. Vue.prototype.$api = {
  37. msg,
  38. prePage
  39. };
  40. Vue.mixin(goPage)
  41. Vue.config.productionTip = false
  42. Vue.prototype.$fire = new Vue();
  43. Vue.prototype.$store = store;
  44. Vue.prototype.$api = {
  45. msg,
  46. prePage
  47. };
  48. Vue.prototype.$_utils = utils
  49. Vue.prototype.$common = common
  50. App.mpType = 'app'
  51. const app = new Vue({
  52. ...App
  53. })
  54. // http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
  55. import httpInterceptor from '@/common/http.interceptor.js'
  56. Vue.use(httpInterceptor, app)
  57. // http接口API抽离,免于写url或者一些固定的参数
  58. import httpApi from '@/common/http.api.js'
  59. Vue.use(httpApi, app)
  60. app.$mount()