main.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import App from './App'
  2. import Vue from 'vue'
  3. import store from './store'
  4. // 引入全局uView
  5. import uView from "@/node_modules/uview-ui";
  6. import {parseIDCardInfo,logout,clearVideoCacheOnLogout,parseText,getDictLabelName,parseIdCard,getAge,parsePhone,isEmpty,
  7. isLogin,navBack,navTo,getUserInfo,formatHour,dateFormatStr,registerIdCode,updateMsgDot,handleBindCompanyFsUser,
  8. setSource,companyUserIsLogin,checkWechatInstalled,isAndroid,isIos,loginNavTo,isAgreePrivacy,getCurrentPage} from './utils/common.js'
  9. import { showLoginPage,getRegistrationID } from './utils/login.js'
  10. import { formatSeconds,formatDate } from './utils/tools.js'
  11. import { qconfig } from './utils/config.js'
  12. // 时间格式化
  13. import timeFormat from './utils/timeFormat.js'
  14. // Vuex
  15. import Vuex from 'vuex'
  16. // #ifndef VUE3
  17. import './uni.promisify.adaptor'
  18. Vue.config.productionTip = false
  19. App.mpType = 'app'
  20. // Vuex 插件注册
  21. Vue.use(Vuex)
  22. Vue.use(uView);
  23. Vue.prototype.$isLogin = isLogin;
  24. Vue.prototype.$isEmpty = isEmpty;
  25. Vue.prototype.$parsePhone = parsePhone;
  26. Vue.prototype.$showLoginPage = showLoginPage;
  27. Vue.prototype.$getRegistrationID = getRegistrationID;
  28. Vue.prototype.$navBack = navBack;
  29. Vue.prototype.$navTo = navTo;
  30. Vue.prototype.$qconfig = qconfig;
  31. Vue.prototype.$getAge = getAge;
  32. Vue.prototype.$parseIdCard = parseIdCard;
  33. Vue.prototype.$getDictLabelName = getDictLabelName;
  34. Vue.prototype.$parseText = parseText;
  35. Vue.prototype.$logout = logout;
  36. Vue.prototype.$clearVideoCacheOnLogout=clearVideoCacheOnLogout;
  37. Vue.prototype.$getUserInfo = getUserInfo;
  38. Vue.prototype.$dateFormatStr = dateFormatStr;
  39. Vue.prototype.$registerIdCode = registerIdCode;
  40. Vue.prototype.$formatSeconds = formatSeconds;
  41. Vue.prototype.$formatDate = formatDate;
  42. Vue.prototype.$parseIDCardInfo = parseIDCardInfo;
  43. Vue.prototype.$timeFormat = timeFormat;
  44. Vue.prototype.$formatHour = formatHour;
  45. Vue.prototype.$updateMsgDot = updateMsgDot;
  46. Vue.prototype.$handleBindCompanyFsUser = handleBindCompanyFsUser;
  47. Vue.prototype.$setSource = setSource;
  48. Vue.prototype.$companyUserIsLogin = companyUserIsLogin;
  49. Vue.prototype.$checkWechatInstalled = checkWechatInstalled;
  50. Vue.prototype.$isAndroid = isAndroid;
  51. Vue.prototype.$isIos = isIos;
  52. Vue.prototype.$loginNavTo = loginNavTo;
  53. Vue.prototype.$isAgreePrivacy = isAgreePrivacy;
  54. Vue.prototype.$getCurrentPage = getCurrentPage;
  55. // 自动打印页面路径(仅开发环境)
  56. if (process.env.NODE_ENV === 'development') {
  57. Vue.mixin({
  58. onShow() {
  59. try {
  60. const pages = getCurrentPages();
  61. if (pages && pages.length > 0) {
  62. const current = pages[pages.length - 1];
  63. // 避免重复打印,或打印空路径
  64. if (current && current.route) {
  65. console.log(`>>> [当前页面] ${current.route}`);
  66. }
  67. }
  68. } catch (e) {
  69. // 忽略错误
  70. }
  71. }
  72. })
  73. }
  74. const app = new Vue({
  75. store,
  76. ...App
  77. });
  78. // 引入请求封装
  79. require("./pages_im/util/request/index")(app);
  80. app.$mount()
  81. // #endif
  82. // #ifdef VUE3
  83. import { createSSRApp } from 'vue'
  84. export function createApp() {
  85. const app = createSSRApp(App)
  86. app.use(uviewPlus)
  87. app.use(Vuex)
  88. app.use(store)
  89. app.config.globalProperties.$isLogin = isLogin
  90. app.config.globalProperties.$isEmpty = isEmpty
  91. app.config.globalProperties.$parsePhone = parsePhone
  92. app.config.globalProperties.$showLoginPage = showLoginPage
  93. app.config.globalProperties.$getRegistrationID = getRegistrationID
  94. app.config.globalProperties.$navBack = navBack
  95. app.config.globalProperties.$navTo = navTo
  96. app.config.globalProperties.$qconfig = qconfig
  97. app.config.globalProperties.$getAge = getAge
  98. app.config.globalProperties.$parseIdCard = parseIdCard
  99. app.config.globalProperties.$getDictLabelName = getDictLabelName
  100. app.config.globalProperties.$parseText = parseText
  101. app.config.globalProperties.$logout = logout,
  102. app.config.globalProperties.$getUserInfo = getUserInfo,
  103. app.config.globalProperties.$dateFormatStr = dateFormatStr,
  104. app.config.globalProperties.$registerIdCode = registerIdCode,
  105. app.config.globalProperties.$formatSeconds = formatSeconds,
  106. app.config.globalProperties.$formatDate = formatDate,
  107. app.config.globalProperties.$parseIDCardInfo = parseIDCardInfo
  108. app.config.globalProperties.$timeFormat = timeFormat;
  109. app.config.globalProperties.$formatHour = formatHour;
  110. app.config.globalProperties.$updateMsgDot = updateMsgDot;
  111. app.config.globalProperties.$handleBindCompanyFsUser = handleBindCompanyFsUser;
  112. app.config.globalProperties.$setSource = setSource;
  113. app.config.globalProperties.$loginNavTo = loginNavTo;
  114. return {
  115. app
  116. }
  117. }
  118. // #endif