| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <script>
- import { GLOBALDATA, frontEndConfig, menu } from './config';
- import { common } from '@kasite/uni-app-base/utils';
- import {
- useFrontEndConfigVersion,
- useSetFrontEndConfig,
- useAppStatus,
- useGetUpdateManager,
- useSmallProgramLogin,
- useGetSysAppPageList,
- usePreserMember,
- useSetFrontEndForm,
- useSetMenuList,
- } from './hook';
- import { nextTick } from 'vue';
- let app = null;
- const beforeMain = async () => {
- common.showLoading();
- // 获取前端当前配置信息版本号 并控制是否 前端配置信息是否要重新获取
- await useFrontEndConfigVersion();
- // 获取前端配置信息
- let has = await useSetFrontEndConfig();
- // 判断获取配置信息是否成功 不成功不让往下
- if (has) return;
- // 判断应用状态,非运行中的应用跳转对应状态的缺省页
- await useAppStatus();
- common.hideLoading();
- if (!app.globalData.logSuccess) {
- main();
- } else {
- // 配置判断是否需要互联网医院Websocket
- if (app.globalData.hasWebsocket) {
- // 链接websocket
- connectWebsocket(true);
- }
- }
- };
- const main = async function () {
- let isUpdateManager = false;
- // #ifndef APP || H5 || WEB
- // 判断如果是在开发过程 不检查是否存在新版本
- isUpdateManager =
- app.globalData.accountInfo.miniProgram.envVersion == 'develop'
- ? false
- : await useGetUpdateManager();
- // #endif
- /**如果有新版本 return */
- if (isUpdateManager) {
- return;
- }
- common.showLoading();
- // 同步获取设备信息
- app.globalData.smallPro_systemInfo = JSON.stringify(uni.getSystemInfoSync());
- const resp = await useSmallProgramLogin(app);
- if (resp) {
- app.globalData.logSuccess = true;
- await useGetSysAppPageList();
- await usePreserMember();
- // 判断前端配置信息有修改获取form表单存储为空从新获取一遍form表单
- if (
- uni.getStorageSync('frontEndConfigRequest') ||
- common.isEmpty(uni.getStorageSync('formConfigList'))
- ) {
- await useSetFrontEndForm(frontEndConfig);
- }
- // 判断前端配置信息有修改获取菜单存储为空从新获取一遍菜单
- if (
- uni.getStorageSync('frontEndConfigRequest') ||
- common.isEmpty(uni.getStorageSync('menuList'))
- ) {
- await useSetMenuList(menu);
- }
- common.hideLoading();
- // 配置判断是否需要互联网医院Websocket
- if (app.globalData.hasWebsocket) {
- // 链接websocket
- // connectWebsocket(true);
- }
- /**判断是否登录成功回调 */
- if (app.loginReadyCallBack && typeof app.loginReadyCallBack == 'function') {
- app.loginReadyCallBack();
- }
- }
- };
- export default {
- globalData: GLOBALDATA,
- onLaunch: function (options) {
- console.log('App Launch');
- console.log('应用启动路径:', options.path);
- // #ifndef APP || WEB || H5 || MP-BAIDU || MP-TOUTIAO || MP-LARK
- // 保存 当前账号信息
- app = this.$scope;
- app.globalData.accountInfo = uni.getAccountInfoSync();
- // #endif
- // WEB只需要获取一次
- // #ifdef WEB
- app = getApp();
- beforeMain();
- // #endif
- },
- onShow: function (options) {
- console.log('App Show');
- console.log('应用启动路径:', options.path);
- // #ifndef WEB
- beforeMain();
- // #endif
- },
- onHide: function () {
- console.log('App Hide');
- },
- methods: {
- loginReadyCallBack: () => {},
- },
- };
- </script>
- <style lang="scss">
- @import '/theme/index';
- </style>
|