main.js 4.5 KB

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