main.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import App from './App'
  2. // vuex
  3. import store from '@/store/index.js'
  4. // uviewPlus导入
  5. import uviewPlus from '@/uni_modules/uview-plus'
  6. import bootstrap from './core/bootstrap'
  7. import {isLogin,isEmpty,navTo,getRegistrationID,parsePhone} from '@/utils/util.js'
  8. // 全局 mixin
  9. import share from './core/mixins/share.js'
  10. import mixin from './core/mixins/app'
  11. // #ifndef VUE3
  12. import Vue from 'vue'
  13. import './uni.promisify.adaptor'
  14. Vue.config.productionTip = false
  15. Vue.prototype.$img = {
  16. img: '/static/images/img.png', // 默认图片
  17. logo: '/static/images/logo.png', // 其他公共图片
  18. }
  19. Vue.prototype.$isLogin = isLogin;
  20. Vue.prototype.$isEmpty = isEmpty;
  21. Vue.prototype.$navTo = navTo;
  22. Vue.prototype.$getRegistrationID = getRegistrationID;
  23. Vue.prototype.$parsePhone = parsePhone;
  24. App.mpType = 'app'
  25. const app = new Vue({
  26. ...App
  27. })
  28. app.$mount()
  29. // #endif
  30. // #ifdef VUE3
  31. import { createSSRApp } from 'vue'
  32. export function createApp() {
  33. const app = createSSRApp(App)
  34. // 注册组件库和vuex
  35. app.use(uviewPlus).use(store)
  36. app.config.productionTip = false
  37. // 定义全局变量 $img(Vue3 方式)
  38. app.config.globalProperties.$img = {
  39. img: '/static/images/img.png', // 默认图片
  40. logo: '/static/images/logo.png', // 其他公共图片
  41. }
  42. app.config.globalProperties.$isLogin = isLogin
  43. app.config.globalProperties.$isEmpty = isEmpty
  44. app.config.globalProperties.$navTo = navTo
  45. app.config.globalProperties.$getRegistrationID = getRegistrationID
  46. app.config.globalProperties.$parsePhone = parsePhone
  47. // 全局 mixin
  48. app.mixin(share).mixin(mixin)
  49. return {
  50. app,
  51. created: bootstrap
  52. }
  53. }
  54. // #endif