Files
smartDriveEEUniApp/unpackage/dist/dev/mp-weixin/app.js
2026-01-20 08:46:36 +08:00

237 lines
8.0 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 uni_modules_uniIdPages_init = require("./uni_modules/uni-id-pages/init.js");
const uni_modules_uniIdPages_common_store = require("./uni_modules/uni-id-pages/common/store.js");
const lang_i18n = require("./lang/i18n.js");
if (!Math) {
"./pages/reception/reception.js";
"./pages/customer/customer.js";
"./pages/team/team.js";
"./pages/champion/champion.js";
"./pages/speaking_training_voice/speaking_training_voice.js";
"./pages/speaking_training_expression/speaking_training_expression.js";
"./pages/speaking_training_record/speaking_training_record.js";
"./pages/speaking_training_homework/speaking_training_homework.js";
"./pages/speaking_training_edu/speaking_training_edu.js";
"./pages/list/list.js";
"./pages/grid/grid.js";
"./pages/list/search/search.js";
"./pages/list/detail.js";
"./pages/workspace/workspace.js";
"./pages/workspace/scene-detail.js";
"./pages/bluetooth-recorder/bluetooth-recorder.js";
"./pages/ucenter/ucenter.js";
"./pages/furniture_reception/furniture_reception.js";
"./pages/furniture_reception/common_begin_reception.js";
"./pages/furniture_customer/furniture_customer.js";
"./pages/furniture_top_sales/furniture_top_sales.js";
"./pages/meeting_prepare/meeting_prepare.js";
"./pages/meeting_meeting/meeting_meeting.js";
"./pages/meeting_summary/meeting_summary.js";
"./pages/meeting_me/meeting_me.js";
"./pages/uni-agree/uni-agree.js";
"./pages/ucenter/settings/settings.js";
"./pages/ucenter/read-news-log/read-news-log.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";
}
const _sfc_main = {
globalData: {
searchText: "",
appVersion: {},
config: {},
$i18n: {},
$t: {}
},
onLaunch: async function() {
common_vendor.index.__f__("log", "at App.vue:20", "App Launch");
this.globalData.$i18n = this.$i18n;
this.globalData.$t = (str) => this.$t(str);
common_appInit.initApp();
await uni_modules_uniIdPages_init.uniIdPageInit();
this.setupRouteInterceptor();
setTimeout(() => {
if (!this.isLoggedIn()) {
this.redirectToLogin();
} else {
this.checkCurrentPageLogin();
}
}, 300);
},
onShow: function() {
common_vendor.index.__f__("log", "at App.vue:75", "App Show");
this.checkCurrentPageLogin();
},
onHide: function() {
common_vendor.index.__f__("log", "at App.vue:85", "App Hide");
},
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 uni_modules_uniIdPages_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:307", "跳转登录页成功");
},
fail: (err) => {
common_vendor.index.__f__("error", "at App.vue:310", "跳转登录页失败:", 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:316", "跳转登录页失败(重试):", err2);
}
});
}
});
},
/**
* 判断是否为tabBar页面
*/
isTabBarPage(route) {
if (!route)
return false;
const tabBarPages = [
"pages/reception/reception",
"pages/customer/customer",
"pages/team/team",
"pages/meeting_summary/meeting_summary",
"pages/furniture_reception/furniture_reception",
"pages/furniture_reception/common_begin_reception",
"pages/furniture_customer/furniture_customer",
"pages/furniture_top_sales/furniture_top_sales",
"pages/ucenter/ucenter"
];
return tabBarPages.includes(route);
},
/**
* 检查当前页面是否需要登录
*/
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);
}
}
}
};
function createApp() {
const app = common_vendor.createSSRApp(_sfc_main);
app.use(lang_i18n.i18n);
return { app };
}
createApp().app.mount("#app");
exports.createApp = createApp;
//# sourceMappingURL=../.sourcemap/mp-weixin/app.js.map