main.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import Vue from 'vue'
  2. import App from './App'
  3. import store from "store";
  4. import uView from "uview-ui";
  5. Vue.use(uView);
  6. Vue.config.productionTip = false
  7. import {
  8. Base64
  9. } from 'js-base64'
  10. Vue.prototype.$Base64 = Base64
  11. import {
  12. toast,
  13. successToast,
  14. showLoading,
  15. tipLoading,
  16. hideLoading,
  17. modal,
  18. navPage,
  19. redPage,
  20. backPage,
  21. callPhone,
  22. copy,
  23. getLocation,
  24. getAddress,
  25. } from "common/utils/common"
  26. import {
  27. navToPage
  28. } from "common/utils/navPag"
  29. Vue.prototype.$navToPage = navToPage;
  30. Vue.prototype.$H5Href = process.env.VUE_APP_HREF;
  31. Vue.prototype.$toast = toast;
  32. Vue.prototype.$successToast = successToast;
  33. Vue.prototype.$showLoading = showLoading;
  34. Vue.prototype.$tipLoading = tipLoading;
  35. Vue.prototype.$hideLoading = hideLoading;
  36. Vue.prototype.$modal = modal;
  37. Vue.prototype.$navPage = navPage;
  38. Vue.prototype.$redPage = redPage;
  39. Vue.prototype.$backPage = backPage;
  40. Vue.prototype.$callPhone = callPhone;
  41. Vue.prototype.$copy = copy;
  42. Vue.prototype.$getLocation = getLocation;
  43. Vue.prototype.$getAddress = getAddress;
  44. // 注入全局
  45. import pages from 'mixins';
  46. Vue.mixin(pages);
  47. App.mpType = 'app'
  48. import api from '@/common/http/'
  49. Vue.prototype.$api = api
  50. import * as filters from './filters/index.js' // global filters
  51. // register global utility filters
  52. Object.keys(filters).forEach(key => {
  53. Vue.filter(key, filters[key])
  54. })
  55. import custom from '@/components/custom.vue';
  56. import Loading from '@/components/Loading.vue';
  57. import zjPageLayout from "@/components/zj-container/zj-page-layout.vue"
  58. Vue.component('custom', custom);
  59. Vue.component('Loading', Loading);
  60. Vue.component('zjPageLayout', zjPageLayout);
  61. import {
  62. getUserInfo
  63. } from "@/common/utils/util.js";
  64. Vue.prototype.$getUserInfo = getUserInfo;
  65. // #ifdef H5
  66. import {
  67. router,
  68. RouterMount
  69. } from 'router'
  70. Vue.use(router)
  71. import Mylink from 'uni-simple-router/dist/link.vue'
  72. // 组件式导航
  73. Vue.component('my-link', Mylink)
  74. // #endif
  75. // 渲染图片文件
  76. Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + '/img/get?key=';
  77. const app = new Vue({
  78. ...App,
  79. store
  80. })
  81. //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
  82. // #ifdef H5
  83. RouterMount(app, router, '#app')
  84. // #endif
  85. // #ifndef H5
  86. app.$mount(); //为了兼容小程序及app端必须这样写才有效果
  87. // #endif