317 lines
10 KiB
JavaScript
317 lines
10 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
const common_vendor = require("./common/vendor.js");
|
|
const common_appInit = require("./common/appInit.js");
|
|
require("./common/openApp.js");
|
|
const common_uniIdPagesInit = require("./common/uni-id-pages-init.js");
|
|
const common_store = require("./common/store.js");
|
|
const lang_i18n = require("./lang/i18n.js");
|
|
if (!Math) {
|
|
"./pages/furniture_reception/furniture_reception.js";
|
|
"./pages/ucenter/ucenter.js";
|
|
"./pages/team/team.js";
|
|
"./pages/furniture_reception/common_begin_reception.js";
|
|
"./pages/furniture_customer/furniture_customer.js";
|
|
"./pages/furniture_top_sales/furniture_top_sales.js";
|
|
"./uni_modules/uni-feedback/pages/opendb-feedback/opendb-feedback.js";
|
|
"./uni_modules/uni-id-pages/pages/userinfo/userinfo.js";
|
|
"./uni_modules/uni-id-pages/pages/userinfo/realname-verify/realname-verify.js";
|
|
"./uni_modules/uni-id-pages/pages/login/login-withoutpwd.js";
|
|
"./uni_modules/uni-id-pages/pages/login/login-withpwd.js";
|
|
"./uni_modules/uni-id-pages/pages/userinfo/deactivate/deactivate.js";
|
|
"./uni_modules/uni-id-pages/pages/userinfo/bind-mobile/bind-mobile.js";
|
|
"./uni_modules/uni-id-pages/pages/login/login-smscode.js";
|
|
"./uni_modules/uni-id-pages/pages/register/register.js";
|
|
"./uni_modules/uni-id-pages/pages/retrieve/retrieve.js";
|
|
"./uni_modules/uni-id-pages/pages/common/webview/webview.js";
|
|
"./uni_modules/uni-id-pages/pages/userinfo/change_pwd/change_pwd.js";
|
|
"./uni_modules/uni-id-pages/pages/register/register-by-email.js";
|
|
"./uni_modules/uni-id-pages/pages/retrieve/retrieve-by-email.js";
|
|
"./uni_modules/uni-id-pages/pages/userinfo/set-pwd/set-pwd.js";
|
|
"./pages-subpackage/champion/champion.js";
|
|
"./pages-subpackage/list/list.js";
|
|
"./pages-subpackage/grid/grid.js";
|
|
"./pages-subpackage/list/search/search.js";
|
|
"./pages-subpackage/list/detail.js";
|
|
"./pages-subpackage/meeting_summary/meeting_summary.js";
|
|
"./pages-subpackage/workspace/workspace.js";
|
|
"./pages-subpackage/workspace/scene-detail.js";
|
|
"./pages-subpackage/bluetooth-recorder/bluetooth-recorder.js";
|
|
"./pages-subpackage/reception/reception.js";
|
|
"./pages-subpackage/customer/customer.js";
|
|
"./pages-subpackage/uni-agree/uni-agree.js";
|
|
"./pages-subpackage/ucenter/settings/settings.js";
|
|
"./pages-subpackage/ucenter/read-news-log/read-news-log.js";
|
|
}
|
|
const _sfc_main = {
|
|
globalData: {
|
|
searchText: "",
|
|
appVersion: {},
|
|
config: {},
|
|
$i18n: {},
|
|
$t: {}
|
|
},
|
|
data() {
|
|
return {
|
|
showLoading: true
|
|
// 初始显示加载状态
|
|
};
|
|
},
|
|
onLaunch: async function() {
|
|
common_vendor.index.__f__("log", "at App.vue:45", "App Launch");
|
|
this.setGlobalRoleInfo();
|
|
this.updateCurrentPath();
|
|
try {
|
|
if (this.$i18n) {
|
|
this.globalData.$i18n = this.$i18n;
|
|
} else {
|
|
setTimeout(() => {
|
|
try {
|
|
if (this.$i18n) {
|
|
this.globalData.$i18n = this.$i18n;
|
|
}
|
|
} catch (e) {
|
|
common_vendor.index.__f__("warn", "at App.vue:66", "[App] i18n 初始化延迟设置失败:", e);
|
|
}
|
|
}, 100);
|
|
}
|
|
} catch (e) {
|
|
common_vendor.index.__f__("warn", "at App.vue:71", "[App] i18n 初始化失败:", e);
|
|
}
|
|
this.globalData.$t = (str) => {
|
|
try {
|
|
return this.$t ? this.$t(str) : str;
|
|
} catch (e) {
|
|
return str;
|
|
}
|
|
};
|
|
common_appInit.initApp();
|
|
await common_uniIdPagesInit.uniIdPageInit();
|
|
this.setupRouteInterceptor();
|
|
setTimeout(() => {
|
|
const checkPageLoaded = () => {
|
|
const pages = getCurrentPages();
|
|
if (pages.length > 0 && pages[pages.length - 1].route) {
|
|
if (!this.isLoggedIn()) {
|
|
this.showLoading = false;
|
|
this.redirectToLogin();
|
|
} else {
|
|
this.checkCurrentPageLogin();
|
|
setTimeout(() => {
|
|
this.showLoading = false;
|
|
}, 200);
|
|
}
|
|
} else {
|
|
setTimeout(checkPageLoaded, 100);
|
|
}
|
|
};
|
|
checkPageLoaded();
|
|
}, 500);
|
|
},
|
|
onShow: function() {
|
|
common_vendor.index.__f__("log", "at App.vue:152", "App Show");
|
|
try {
|
|
common_store.mutations.syncUserInfoFromStorage();
|
|
} catch (e) {
|
|
}
|
|
this.checkCurrentPageLogin();
|
|
},
|
|
onHide: function() {
|
|
common_vendor.index.__f__("log", "at App.vue:165", "App Hide");
|
|
this.stopTabBarMonitor();
|
|
},
|
|
onError: function(msg) {
|
|
common_vendor.index.__f__("error", "at App.vue:171", "[App Global Error]:", msg);
|
|
},
|
|
methods: {
|
|
/**
|
|
* 设置全局路由拦截
|
|
*/
|
|
setupRouteInterceptor() {
|
|
const app = this;
|
|
common_vendor.index.addInterceptor("navigateTo", {
|
|
invoke: (options) => {
|
|
if (app.shouldRedirectToLogin(options.url)) {
|
|
app.redirectToLogin();
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
common_vendor.index.addInterceptor("redirectTo", {
|
|
invoke: (options) => {
|
|
if (app.shouldRedirectToLogin(options.url)) {
|
|
app.redirectToLogin();
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
common_vendor.index.addInterceptor("switchTab", {
|
|
invoke: (options) => {
|
|
if (app.shouldRedirectToLogin(options.url)) {
|
|
app.redirectToLogin();
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
common_vendor.index.addInterceptor("reLaunch", {
|
|
invoke: (options) => {
|
|
if (app.shouldRedirectToLogin(options.url)) {
|
|
app.redirectToLogin();
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 判断是否需要跳转到登录页
|
|
*/
|
|
shouldRedirectToLogin(url) {
|
|
if (!url)
|
|
return false;
|
|
const excludePaths = [
|
|
"/uni_modules/uni-id-pages/pages/login",
|
|
"/uni_modules/uni-id-pages/pages/register",
|
|
"/uni_modules/uni-id-pages/pages/retrieve"
|
|
];
|
|
for (let excludePath of excludePaths) {
|
|
if (url.includes(excludePath)) {
|
|
return false;
|
|
}
|
|
}
|
|
return !this.isLoggedIn();
|
|
},
|
|
/**
|
|
* 检查是否已登录
|
|
*/
|
|
isLoggedIn() {
|
|
const backendToken = common_vendor.index.getStorageSync("backend-token");
|
|
if (backendToken) {
|
|
return true;
|
|
}
|
|
return common_store.store.hasLogin;
|
|
},
|
|
/**
|
|
* 跳转到登录页
|
|
*/
|
|
redirectToLogin() {
|
|
const loginPage = "/uni_modules/uni-id-pages/pages/login/login-withpwd";
|
|
const pages = getCurrentPages();
|
|
if (pages.length > 0) {
|
|
const currentPage = pages[pages.length - 1];
|
|
if (currentPage.route && currentPage.route.includes("login")) {
|
|
return;
|
|
}
|
|
}
|
|
common_vendor.index.reLaunch({
|
|
url: loginPage,
|
|
success: () => {
|
|
common_vendor.index.__f__("log", "at App.vue:279", "跳转登录页成功");
|
|
},
|
|
fail: (err) => {
|
|
common_vendor.index.__f__("error", "at App.vue:282", "跳转登录页失败:", err);
|
|
const loginPageWithoutSlash = loginPage.startsWith("/") ? loginPage.substring(1) : loginPage;
|
|
common_vendor.index.reLaunch({
|
|
url: loginPageWithoutSlash,
|
|
fail: (err2) => {
|
|
common_vendor.index.__f__("error", "at App.vue:288", "跳转登录页失败(重试):", err2);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
},
|
|
/**
|
|
* 更新当前页面路径(用于更新 tabBar 等)
|
|
*/
|
|
updateCurrentPath() {
|
|
try {
|
|
const pages = getCurrentPages();
|
|
if (pages.length > 0) {
|
|
const currentPage = pages[pages.length - 1];
|
|
if (currentPage && currentPage.route) {
|
|
const currentPath = `/${currentPage.route}`;
|
|
try {
|
|
const app = getApp({ allowDefault: true });
|
|
if (app && app.globalData) {
|
|
const tabBar = app.globalData.tabBarInstance;
|
|
if (tabBar && typeof tabBar.updateCurrentPath === "function") {
|
|
tabBar.updateCurrentPath(currentPath);
|
|
}
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
}
|
|
},
|
|
/**
|
|
* 检查当前页面是否需要登录
|
|
*/
|
|
setGlobalRoleInfo() {
|
|
try {
|
|
const tokenData = common_vendor.index.getStorageSync("uni_id_token");
|
|
if (tokenData && tokenData.roles) {
|
|
common_vendor.index.__f__("log", "at App.vue:343", "[App] Setting global role info:", tokenData.roles);
|
|
this.globalData.roles = tokenData.roles;
|
|
this.globalData.roleName = tokenData.roleName || "";
|
|
try {
|
|
const app = getApp({ allowDefault: true });
|
|
if (app && app.globalData) {
|
|
const tabBar = app.globalData.tabBarInstance;
|
|
if (tabBar) {
|
|
tabBar.refreshRole();
|
|
}
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
} catch (e) {
|
|
common_vendor.index.__f__("warn", "at App.vue:361", "[App] Failed to set global role info:", e);
|
|
}
|
|
},
|
|
checkCurrentPageLogin() {
|
|
const pages = getCurrentPages();
|
|
if (pages.length === 0) {
|
|
setTimeout(() => {
|
|
this.checkCurrentPageLogin();
|
|
}, 200);
|
|
return;
|
|
}
|
|
const currentPage = pages[pages.length - 1];
|
|
if (!currentPage || !currentPage.route) {
|
|
setTimeout(() => {
|
|
this.checkCurrentPageLogin();
|
|
}, 200);
|
|
return;
|
|
}
|
|
const currentRoute = "/" + currentPage.route;
|
|
if (currentRoute.includes("/uni_modules/uni-id-pages/pages/login") || currentRoute.includes("/uni_modules/uni-id-pages/pages/register") || currentRoute.includes("/uni_modules/uni-id-pages/pages/retrieve")) {
|
|
return;
|
|
}
|
|
if (!this.isLoggedIn()) {
|
|
setTimeout(() => {
|
|
this.redirectToLogin();
|
|
}, 100);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _component_router_view = common_vendor.resolveComponent("router-view");
|
|
_component_router_view();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return common_vendor.e({
|
|
a: $data.showLoading
|
|
}, $data.showLoading ? {} : {});
|
|
}
|
|
const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
function createApp() {
|
|
const app = common_vendor.createSSRApp(App);
|
|
app.use(lang_i18n.i18n);
|
|
return { app };
|
|
}
|
|
createApp().app.mount("#app");
|
|
exports.createApp = createApp;
|
|
//# sourceMappingURL=../.sourcemap/mp-weixin/app.js.map
|