main.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. import ScsNoData from '@/components/public/scs-no-data.vue'
  13. // 时间格式化
  14. import timeFormat from './utils/timeFormat.js'
  15. // Vuex
  16. import Vuex from 'vuex'
  17. // #ifndef VUE3
  18. import './uni.promisify.adaptor'
  19. Vue.config.productionTip = false
  20. App.mpType = 'app'
  21. // Vuex 插件注册
  22. Vue.use(Vuex)
  23. Vue.use(uView);
  24. Vue.prototype.$isLogin = isLogin;
  25. Vue.prototype.$isEmpty = isEmpty;
  26. Vue.prototype.$parsePhone = parsePhone;
  27. Vue.prototype.$showLoginPage = showLoginPage;
  28. Vue.prototype.$getRegistrationID = getRegistrationID;
  29. Vue.prototype.$navBack = navBack;
  30. Vue.prototype.$navTo = navTo;
  31. Vue.prototype.$qconfig = qconfig;
  32. Vue.prototype.$getAge = getAge;
  33. Vue.prototype.$parseIdCard = parseIdCard;
  34. Vue.prototype.$getDictLabelName = getDictLabelName;
  35. Vue.prototype.$parseText = parseText;
  36. Vue.prototype.$logout = logout;
  37. Vue.prototype.$clearVideoCacheOnLogout=clearVideoCacheOnLogout;
  38. Vue.prototype.$getUserInfo = getUserInfo;
  39. Vue.prototype.$dateFormatStr = dateFormatStr;
  40. Vue.prototype.$registerIdCode = registerIdCode;
  41. Vue.prototype.$formatSeconds = formatSeconds;
  42. Vue.prototype.$formatDate = formatDate;
  43. Vue.prototype.$parseIDCardInfo = parseIDCardInfo;
  44. Vue.prototype.$timeFormat = timeFormat;
  45. Vue.prototype.$formatHour = formatHour;
  46. Vue.prototype.$updateMsgDot = updateMsgDot;
  47. Vue.prototype.$handleBindCompanyFsUser = handleBindCompanyFsUser;
  48. Vue.prototype.$setSource = setSource;
  49. Vue.prototype.$companyUserIsLogin = companyUserIsLogin;
  50. Vue.prototype.$checkWechatInstalled = checkWechatInstalled;
  51. Vue.prototype.$isAndroid = isAndroid;
  52. Vue.prototype.$isIos = isIos;
  53. Vue.prototype.$loginNavTo = loginNavTo;
  54. Vue.prototype.$isAgreePrivacy = isAgreePrivacy;
  55. Vue.prototype.$getCurrentPage = getCurrentPage;
  56. // 自动打印页面路径(仅开发环境)
  57. if (process.env.NODE_ENV === 'development') {
  58. Vue.mixin({
  59. onShow() {
  60. try {
  61. const pages = getCurrentPages();
  62. if (pages && pages.length > 0) {
  63. const current = pages[pages.length - 1];
  64. // 避免重复打印,或打印空路径
  65. if (current && current.route) {
  66. console.log(`>>> [当前页面] ${current.route}`);
  67. }
  68. }
  69. } catch (e) {
  70. // 忽略错误
  71. }
  72. }
  73. })
  74. }
  75. Vue.component('scs-no-data', ScsNoData)
  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. app.component('scs-no-data', ScsNoData)
  117. return {
  118. app
  119. }
  120. }
  121. // #endif