115 lines
4.3 KiB
JavaScript
115 lines
4.3 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const utils_session = require("../../utils/session.js");
|
|
const composables_useNavigator = require("../../composables/useNavigator.js");
|
|
if (!Math) {
|
|
(AppIcon + TabBar)();
|
|
}
|
|
const TabBar = () => "../../components/TabBar.js";
|
|
const AppIcon = () => "../../components/AppIcon.js";
|
|
const _sfc_main = {
|
|
__name: "Mine",
|
|
emits: ["change-page"],
|
|
setup(__props, { emit: __emit }) {
|
|
const userInfo = utils_session.getUserSession();
|
|
const { goPage, navigateTo } = composables_useNavigator.useNavigator();
|
|
const userCardSafeStyle = (() => {
|
|
var _a, _b, _c, _d;
|
|
const statusBarHeight = ((_b = (_a = common_vendor.index).getSystemInfoSync) == null ? void 0 : _b.call(_a).statusBarHeight) || 20;
|
|
let safeTop = statusBarHeight + 12;
|
|
const menuRect = (_d = (_c = common_vendor.index).getMenuButtonBoundingClientRect) == null ? void 0 : _d.call(_c);
|
|
if (menuRect && menuRect.top && menuRect.height) {
|
|
safeTop = menuRect.top + menuRect.height + 8;
|
|
}
|
|
return `padding-top:${safeTop}px;`;
|
|
})();
|
|
const initials = common_vendor.computed(() => {
|
|
if (!userInfo.name) return "?";
|
|
return userInfo.name.slice(0, 1).toUpperCase();
|
|
});
|
|
const avatarStyle = common_vendor.computed(() => {
|
|
var _a;
|
|
if (userInfo.avatar) return {};
|
|
const colors = ["#ff7c43", "#07c160", "#8b6914", "#e06040", "#5090d0"];
|
|
const idx = (((_a = userInfo.name) == null ? void 0 : _a.charCodeAt(0)) || 0) % colors.length;
|
|
return { background: colors[idx] };
|
|
});
|
|
const logout = () => {
|
|
common_vendor.index.showModal({
|
|
title: "提示",
|
|
content: "确定退出登录?",
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
utils_session.clearSession();
|
|
navigateTo("login");
|
|
}
|
|
}
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return common_vendor.e({
|
|
a: common_vendor.unref(userInfo).avatar
|
|
}, common_vendor.unref(userInfo).avatar ? {
|
|
b: common_vendor.unref(userInfo).avatar
|
|
} : {
|
|
c: common_vendor.t(initials.value)
|
|
}, {
|
|
d: common_vendor.s(avatarStyle.value),
|
|
e: common_vendor.t(common_vendor.unref(userInfo).name),
|
|
f: common_vendor.t(common_vendor.unref(userInfo).phone),
|
|
g: common_vendor.t(common_vendor.unref(userInfo).role === "boss" ? "店长" : common_vendor.unref(userInfo).role === "customer" ? "客户" : "员工"),
|
|
h: common_vendor.s(common_vendor.unref(userCardSafeStyle)),
|
|
i: common_vendor.o(($event) => common_vendor.unref(navigateTo)("profile")),
|
|
j: common_vendor.unref(userInfo).role === "boss"
|
|
}, common_vendor.unref(userInfo).role === "boss" ? {
|
|
k: common_vendor.p({
|
|
name: "staff",
|
|
size: 15
|
|
}),
|
|
l: common_vendor.o(($event) => common_vendor.unref(navigateTo)("staff")),
|
|
m: common_vendor.p({
|
|
name: "service",
|
|
size: 15
|
|
}),
|
|
n: common_vendor.o(($event) => common_vendor.unref(navigateTo)("serviceType")),
|
|
o: common_vendor.p({
|
|
name: "store",
|
|
size: 15
|
|
}),
|
|
p: common_vendor.o(($event) => common_vendor.unref(navigateTo)("store"))
|
|
} : {}, {
|
|
q: common_vendor.p({
|
|
name: "profile",
|
|
size: 15
|
|
}),
|
|
r: common_vendor.o(($event) => common_vendor.unref(navigateTo)("profile")),
|
|
s: common_vendor.unref(userInfo).role !== "customer"
|
|
}, common_vendor.unref(userInfo).role !== "customer" ? {
|
|
t: common_vendor.p({
|
|
name: "report",
|
|
size: 15
|
|
}),
|
|
v: common_vendor.o(($event) => common_vendor.unref(navigateTo)("myReports"))
|
|
} : {}, {
|
|
w: common_vendor.p({
|
|
name: "orders",
|
|
size: 15
|
|
}),
|
|
x: common_vendor.o(($event) => common_vendor.unref(navigateTo)("myOrders")),
|
|
y: common_vendor.p({
|
|
name: "logout",
|
|
size: 15,
|
|
color: "#dc2626"
|
|
}),
|
|
z: common_vendor.o(logout),
|
|
A: common_vendor.o(common_vendor.unref(goPage)),
|
|
B: common_vendor.p({
|
|
["current-page"]: "mine"
|
|
})
|
|
});
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-02264ef7"]]);
|
|
wx.createPage(MiniProgramPage);
|