"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
  const _easycom_t_fab2 = common_vendor.resolveComponent("t-fab");
  _easycom_t_fab2();
}
const _easycom_t_fab = () => "../../uni_modules/tdesign-uniapp/components/fab/fab.js";
if (!Math) {
  _easycom_t_fab();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  setup(__props) {
    const user = common_vendor.ref(null);
    const banners = common_vendor.ref([
      { image: "https://picsum.photos/800/400?random=1", title: "专业美容服务" },
      { image: "https://picsum.photos/800/400?random=2", title: "预约更便捷" },
      { image: "https://picsum.photos/800/400?random=3", title: "优惠活动" }
    ]);
    const menuItems = common_vendor.ref([
      { icon: "📅", text: "我要预约", path: "/pages/booking/booking" },
      { icon: "📋", text: "我的预约", path: "/pages/appointments/appointments" }
    ]);
    common_vendor.onMounted(() => {
      const token = common_vendor.index.getStorageSync("token");
      if (!token) {
        common_vendor.index.redirectTo({ url: "/pages/login/login" });
      } else {
        user.value = common_vendor.index.getStorageSync("user");
      }
    });
    const navigateTo = (path) => {
      common_vendor.index.navigateTo({ url: path });
    };
    const logout = () => {
      common_vendor.index.showModal({
        title: "提示",
        content: "确定要退出登录吗？",
        success: (res) => {
          if (res.confirm) {
            common_vendor.index.removeStorageSync("token");
            common_vendor.index.removeStorageSync("user");
            common_vendor.index.redirectTo({ url: "/pages/login/login" });
          }
        }
      });
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(banners.value, (item, index, i0) => {
          return {
            a: item.image,
            b: index
          };
        }),
        b: common_vendor.f(menuItems.value, (item, index, i0) => {
          return {
            a: common_vendor.t(item.icon),
            b: common_vendor.t(item.text),
            c: item.path,
            d: common_vendor.o(($event) => navigateTo(item.path), item.path)
          };
        }),
        c: common_vendor.o(logout),
        d: common_vendor.p({
          icon: "caret-right",
          ["aria-label"]: "退出"
        })
      };
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map
