App.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <script>
  2. import { GLOBALDATA, frontEndConfig, menu } from './config';
  3. import { common } from '@kasite/uni-app-base';
  4. import {
  5. useFrontEndConfigVersion,
  6. useSetFrontEndConfig,
  7. useAppStatus,
  8. useGetUpdateManager,
  9. useSmallProgramLogin,
  10. useGetSysAppPageList,
  11. usePreserMember,
  12. useSetFrontEndForm,
  13. useSetMenuList,
  14. } from './hook';
  15. import { nextTick } from 'vue';
  16. let app = null;
  17. const beforeMain = async () => {
  18. common.showLoading();
  19. // 获取前端当前配置信息版本号 并控制是否 前端配置信息是否要重新获取
  20. await useFrontEndConfigVersion();
  21. // 获取前端配置信息
  22. let has = await useSetFrontEndConfig();
  23. // 判断获取配置信息是否成功 不成功不让往下
  24. if (has) return;
  25. // 判断应用状态,非运行中的应用跳转对应状态的缺省页
  26. // await useAppStatus();
  27. common.hideLoading();
  28. if (!app.globalData.logSuccess) {
  29. main();
  30. } else {
  31. // 配置判断是否需要互联网医院Websocket
  32. if (app.globalData.hasWebsocket) {
  33. // 链接websocket
  34. connectWebsocket(true);
  35. }
  36. }
  37. };
  38. const main = async function () {
  39. let isUpdateManager = false;
  40. // #ifndef APP || H5 || WEB
  41. // 判断如果是在开发过程 不检查是否存在新版本
  42. isUpdateManager =
  43. app.globalData.accountInfo.miniProgram.envVersion == 'develop'
  44. ? false
  45. : await useGetUpdateManager();
  46. // #endif
  47. /**如果有新版本 return */
  48. if (isUpdateManager) {
  49. return;
  50. }
  51. common.showLoading();
  52. // 同步获取设备信息
  53. app.globalData.smallPro_systemInfo = JSON.stringify(uni.getSystemInfoSync());
  54. const resp = await useSmallProgramLogin(app);
  55. if (resp) {
  56. app.globalData.logSuccess = true;
  57. // await useGetSysAppPageList();
  58. // await usePreserMember();
  59. // 判断前端配置信息有修改获取form表单存储为空从新获取一遍form表单
  60. // if (
  61. // uni.getStorageSync('frontEndConfigRequest') ||
  62. // common.isEmpty(uni.getStorageSync('formConfigList'))
  63. // ) {
  64. // await useSetFrontEndForm(frontEndConfig);
  65. // }
  66. // 判断前端配置信息有修改获取菜单存储为空从新获取一遍菜单
  67. // if (
  68. // uni.getStorageSync('frontEndConfigRequest') ||
  69. // common.isEmpty(uni.getStorageSync('menuList'))
  70. // ) {
  71. // await useSetMenuList(menu);
  72. // }
  73. common.hideLoading();
  74. // 配置判断是否需要互联网医院Websocket
  75. if (app.globalData.hasWebsocket) {
  76. // 链接websocket
  77. // connectWebsocket(true);
  78. }
  79. /**判断是否登录成功回调 */
  80. if (app.loginReadyCallBack && typeof app.loginReadyCallBack == 'function') {
  81. app.loginReadyCallBack();
  82. }
  83. }
  84. };
  85. export default {
  86. globalData: GLOBALDATA,
  87. onLaunch: function (options) {
  88. console.log('App Launch');
  89. console.log('应用启动路径:', options.path);
  90. // #ifndef APP || WEB || H5 || MP-BAIDU || MP-TOUTIAO || MP-LARK
  91. // 保存 当前账号信息
  92. app = this.$scope;
  93. app.globalData.accountInfo = uni.getAccountInfoSync();
  94. // #endif
  95. // WEB只需要获取一次
  96. // #ifdef WEB
  97. app = getApp();
  98. beforeMain();
  99. // #endif
  100. },
  101. onShow: function (options) {
  102. console.log('App Show');
  103. console.log('应用启动路径:', options.path);
  104. // #ifndef WEB
  105. beforeMain();
  106. // #endif
  107. },
  108. onHide: function () {
  109. console.log('App Hide');
  110. },
  111. methods: {
  112. loginReadyCallBack: () => {},
  113. },
  114. };
  115. </script>
  116. <style lang="scss">
  117. @import '/theme/index';
  118. /* 隐藏所有页面的 navigationBar */
  119. uni-page-head {
  120. display: none;
  121. }
  122. </style>