JewelryMall/miniprogram/unpackage/dist/dev/mp-weixin/pages/mine/index.js
2026-02-25 01:21:16 +08:00

93 lines
3.7 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const store_user = require("../../store/user.js");
const api_order = require("../../api/order.js");
if (!Math) {
CustomerServiceBtn();
}
const CustomerServiceBtn = () => "../../components/CustomerServiceBtn.js";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "index",
setup(__props) {
const userStore = store_user.useUserStore();
const showQrCode = common_vendor.ref(false);
const showAbout = common_vendor.ref(false);
const orderCount = common_vendor.ref(0);
const isLoggedIn = common_vendor.ref(false);
function refreshData() {
const token = common_vendor.index.getStorageSync("token");
isLoggedIn.value = !!token;
if (token) {
userStore.fetchProfile();
api_order.getOrderList().then((data) => {
orderCount.value = Array.isArray(data) ? data.length : (data == null ? void 0 : data.total) || 0;
}).catch(() => {
});
}
}
common_vendor.onShow(() => {
refreshData();
});
function handleUserCardClick() {
if (!isLoggedIn.value) {
common_vendor.index.navigateTo({ url: "/pages/login/index" });
}
}
function navigateTo(url) {
const token = common_vendor.index.getStorageSync("token");
if (!token) {
common_vendor.index.navigateTo({ url: "/pages/login/index" });
return;
}
common_vendor.index.navigateTo({ url });
}
function showAgreement(type) {
const title = type === "user" ? "用户协议" : "隐私协议";
common_vendor.index.showModal({
title,
content: type === "user" ? "欢迎使用珠宝商城小程序。使用本小程序即表示您同意遵守相关服务条款。" : "我们重视您的隐私保护。我们仅收集必要的信息以提供服务,不会向第三方泄露您的个人信息。",
showCancel: false,
confirmText: "我知道了"
});
}
return (_ctx, _cache) => {
var _a, _b;
return common_vendor.e({
a: ((_a = common_vendor.unref(userStore).user) == null ? void 0 : _a.avatar) || "/static/logo.png",
b: common_vendor.t(isLoggedIn.value ? ((_b = common_vendor.unref(userStore).user) == null ? void 0 : _b.nickname) || "微信用户" : "点击注册/登录"),
c: common_vendor.o(handleUserCardClick),
d: common_assets._imports_0$2,
e: common_vendor.t(orderCount.value),
f: common_vendor.o(($event) => navigateTo("/pages/order/list")),
g: common_assets._imports_1,
h: common_vendor.o(($event) => navigateTo("/pages/address/index")),
i: common_assets._imports_2,
j: common_vendor.o(($event) => showQrCode.value = true),
k: common_assets._imports_3,
l: common_vendor.o(($event) => showAbout.value = true),
m: common_assets._imports_4,
n: common_vendor.o(($event) => showAgreement("user")),
o: common_assets._imports_5,
p: common_vendor.o(($event) => showAgreement("privacy")),
q: showQrCode.value
}, showQrCode.value ? {
r: common_vendor.o(($event) => showQrCode.value = false),
s: common_vendor.p({
mode: "qrcode"
})
} : {}, {
t: showAbout.value
}, showAbout.value ? {
v: common_vendor.o(($event) => showAbout.value = false),
w: common_vendor.o(() => {
}),
x: common_vendor.o(($event) => showAbout.value = false)
} : {});
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-569e925a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/index.js.map