appointment_system/unpackage/dist/dev/mp-weixin/pages/me/me-page.js
2025-12-15 23:42:31 +08:00

232 lines
7.4 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_tabbarI18n = require("../../utils/tabbar-i18n.js");
const utils_auth = require("../../utils/auth.js");
const modules_api_AppServer = require("../../modules/api/AppServer.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
data() {
return {
showLanguagePicker: false,
languages: [
{ code: "zh", name: "中文" },
{ code: "en", name: "English" },
{ code: "pt", name: "Português" }
],
user: null,
isLogin: false
};
},
computed: {
currentLanguage() {
return this.$i18n.locale;
}
},
onLoad() {
this.checkLoginStatus();
},
onShow() {
utils_tabbarI18n.updateTabBarI18n(this);
this.checkLoginStatus();
if (this.isLogin) {
this.refreshUserInfo();
}
},
methods: {
/**
* 检查登录状态
*/
checkLoginStatus() {
this.isLogin = utils_auth.isLoggedIn();
if (this.isLogin) {
this.user = utils_auth.getCurrentUser();
}
},
/**
* 从服务器刷新用户信息
*/
async refreshUserInfo() {
try {
const appserver = new modules_api_AppServer.AppServer();
const response = await appserver.GetUserProfile();
if (response.code === 0 && response.data) {
this.user = response.data;
utils_auth.saveUserInfo(response.data);
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/me/me-page.vue:294", "刷新用户信息失败:", error);
}
},
getCurrentLanguageName() {
const current = this.languages.find((lang) => lang.code === this.currentLanguage);
return current ? current.name : "中文";
},
changeLanguage(langCode) {
if (langCode === this.$i18n.locale) {
this.showLanguagePicker = false;
return;
}
this.$i18n.locale = langCode;
common_vendor.index.setStorageSync("language", langCode);
this.showLanguagePicker = false;
common_vendor.index.showToast({
title: this.$t("common.success"),
icon: "success",
duration: 1e3
});
setTimeout(() => {
common_vendor.index.reLaunch({
url: "/pages/index/index"
});
}, 1e3);
},
/**
* 跳转到个人资料编辑页面(需要登录)
*/
goToProfileEdit() {
if (!utils_auth.requireAuth()) {
return;
}
common_vendor.index.navigateTo({
url: "/pages/me/profile-edit-page"
});
},
/**
* 跳转到通知页面(需要登录)
*/
goToNotification() {
if (!utils_auth.requireAuth()) {
return;
}
common_vendor.index.navigateTo({
url: "/pages/me/notification-page"
});
},
/**
* 跳转到联系我们(不需要登录)
*/
goToContactUs() {
common_vendor.index.navigateTo({
url: "/pages/me/contact-us-page"
});
},
/**
* 跳转到邀请奖励页面(需要登录)
*/
goToInviteReward() {
if (!utils_auth.requireAuth()) {
return;
}
common_vendor.index.navigateTo({
url: "/pages/me/invite-reward-page"
});
},
/**
* 退出登录
*/
handleLogout() {
if (!this.isLogin) {
common_vendor.index.navigateTo({
url: "/pages/login/login-page"
});
return;
}
common_vendor.index.showModal({
title: this.$t("common.confirm"),
content: "确定要退出登录吗?",
success: async (res) => {
if (res.confirm) {
await utils_auth.logout();
}
}
});
}
}
};
if (!Array) {
const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
_easycom_up_popup2();
}
const _easycom_up_popup = () => "../../node-modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
_easycom_up_popup();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.isLogin && $data.user
}, $data.isLogin && $data.user ? {
b: $data.user.avatar || "/static/default_avatar.png",
c: common_vendor.t($data.user.nickname || "用户"),
d: common_vendor.t($data.user.uid || ""),
e: common_assets._imports_0$1,
f: common_vendor.o((...args) => $options.goToProfileEdit && $options.goToProfileEdit(...args))
} : {
g: common_assets._imports_1$1,
h: common_assets._imports_0$1,
i: common_vendor.o((...args) => $options.handleLogout && $options.handleLogout(...args))
}, {
j: common_vendor.t($data.isLogin ? "0" : "-"),
k: common_vendor.t(_ctx.$t("me.appointment")),
l: common_vendor.t($data.isLogin ? "0" : "-"),
m: common_vendor.t(_ctx.$t("me.inProgress")),
n: common_vendor.t($data.isLogin ? "0" : "-"),
o: common_vendor.t(_ctx.$t("me.completed")),
p: common_assets._imports_2,
q: common_assets._imports_1,
r: common_vendor.t(_ctx.$t("me.notification")),
s: common_assets._imports_2$1,
t: common_vendor.o((...args) => $options.goToNotification && $options.goToNotification(...args)),
v: common_assets._imports_5,
w: common_vendor.t(_ctx.$t("me.customerService")),
x: common_assets._imports_2$1,
y: common_assets._imports_6,
z: common_vendor.t(_ctx.$t("me.contactUs")),
A: common_assets._imports_2$1,
B: common_vendor.o((...args) => $options.goToContactUs && $options.goToContactUs(...args)),
C: common_assets._imports_7,
D: common_vendor.t(_ctx.$t("me.inviteReward")),
E: common_assets._imports_2$1,
F: common_vendor.o((...args) => $options.goToInviteReward && $options.goToInviteReward(...args)),
G: common_assets._imports_8,
H: common_assets._imports_9,
I: common_vendor.t(_ctx.$t("me.language")),
J: common_vendor.t($options.getCurrentLanguageName()),
K: common_assets._imports_2$1,
L: common_vendor.o(($event) => $data.showLanguagePicker = true),
M: common_assets._imports_10,
N: common_vendor.t(_ctx.$t("me.about")),
O: common_assets._imports_2$1,
P: common_assets._imports_11,
Q: common_vendor.t(_ctx.$t("me.userAgreement")),
R: common_assets._imports_2$1,
S: common_assets._imports_12,
T: common_vendor.t(_ctx.$t("me.privacyPolicy")),
U: common_assets._imports_2$1,
V: common_assets._imports_13,
W: common_vendor.t($data.isLogin ? _ctx.$t("me.logout") : "登录"),
X: common_assets._imports_2$1,
Y: common_vendor.o((...args) => $options.handleLogout && $options.handleLogout(...args)),
Z: common_vendor.t(_ctx.$t("me.language")),
aa: common_vendor.o(($event) => $data.showLanguagePicker = false),
ab: common_vendor.f($data.languages, (lang, k0, i0) => {
return common_vendor.e({
a: common_vendor.t(lang.name),
b: $options.currentLanguage === lang.code
}, $options.currentLanguage === lang.code ? {} : {}, {
c: lang.code,
d: common_vendor.o(($event) => $options.changeLanguage(lang.code), lang.code),
e: $options.currentLanguage === lang.code ? 1 : ""
});
}),
ac: common_vendor.o(($event) => $data.showLanguagePicker = false),
ad: common_vendor.p({
show: $data.showLanguagePicker,
mode: "bottom",
["border-radius"]: "20"
})
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/me/me-page.js.map