"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_assets = require("../../utils/assets.js");
const ErpTabBar = () => "../../components/erp-tab-bar.js";
const ErpNavBar = () => "../../components/erp-nav-bar.js";
const _sfc_main = {
  components: { ErpTabBar, ErpNavBar },
  data() {
    return {
      assets: utils_assets.assets,
      isLogin: false,
      // 控制登录状态
      orderStates: [
        { label: "待审核", icon: utils_assets.assets.minePendingReview },
        { label: "待签批", icon: utils_assets.assets.minePendingSign },
        { label: "生产中", icon: utils_assets.assets.mineProducing },
        { label: "已完成", icon: utils_assets.assets.mineCompleted }
      ],
      menuList: [
        { label: "用户协议", icon: utils_assets.assets.mineProtocol, id: "agreement" },
        { label: "隐私政策", icon: utils_assets.assets.minePrivacy, id: "privacy" },
        { label: "投诉与建议", icon: utils_assets.assets.mineComplaint, id: "complaint" },
        { label: "联系客服", icon: utils_assets.assets.mineService, id: "service" }
      ]
    };
  },
  onShow() {
    this.isLogin = !!common_vendor.index.getStorageSync("isLogin");
  },
  methods: {
    goToLogin() {
      common_vendor.index.reLaunch({ url: "/pages/login/index" });
    },
    // 跳转至设置页面
    goToSettings() {
      if (this.isLogin) {
        common_vendor.index.navigateTo({
          url: "/pages/mine/settings/index"
        });
      }
    },
    // 新增：跳转至订单列表
    goToOrderList(status) {
      if (!this.isLogin) {
        return this.goToLogin();
      }
      common_vendor.index.navigateTo({
        url: `/pages/order/list/index?tab=${status}`
      });
    },
    handleLogout() {
      common_vendor.index.showModal({
        title: "退出提示",
        content: "确认退出当前账号吗？",
        confirmColor: "#C1001C",
        success: (res) => {
          if (res.confirm) {
            common_vendor.index.removeStorageSync("isLogin");
            this.isLogin = false;
          }
        }
      });
    },
    // 新增：菜单点击处理
    handleMenuClick(menu) {
      if (menu.id === "agreement") {
        common_vendor.index.navigateTo({ url: "/pages/mine/agreement/index" });
      } else if (menu.id === "privacy") {
        common_vendor.index.navigateTo({ url: "/pages/mine/privacy/index" });
      } else if (menu.id === "complaint") {
        common_vendor.index.navigateTo({ url: "/pages/mine/complaint/index" });
      } else if (menu.id === "service") {
        common_vendor.index.showModal({
          title: "联系客服",
          content: "客服电话：138-8888-8888",
          confirmText: "立即拨打",
          confirmColor: "#C1001C",
          cancelColor: "#999999",
          success: (res) => {
            if (res.confirm) {
              common_vendor.index.makePhoneCall({
                phoneNumber: "13888888888"
              });
            }
          }
        });
      }
    }
  }
};
if (!Array) {
  const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar");
  const _component_erp_tab_bar = common_vendor.resolveComponent("erp-tab-bar");
  (_component_erp_nav_bar + _component_erp_tab_bar)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.p({
      title: "个人中心",
      ["show-back"]: false,
      ["bg-color"]: "#C1001C",
      ["title-color"]: "#ffffff"
    }),
    b: $data.isLogin
  }, $data.isLogin ? {
    c: $data.assets.mineSettings,
    d: common_vendor.o((...args) => $options.goToSettings && $options.goToSettings(...args), "ee")
  } : {
    e: $data.assets.mineArrow,
    f: common_vendor.o((...args) => $options.goToLogin && $options.goToLogin(...args), "17")
  }, {
    g: $data.assets.mineArrow,
    h: common_vendor.o(($event) => $options.goToOrderList(0), "7c"),
    i: common_vendor.f($data.orderStates, (item, index, i0) => {
      return {
        a: item.icon,
        b: common_vendor.t(item.label),
        c: index,
        d: common_vendor.o(($event) => $options.goToOrderList(index + 1), index)
      };
    }),
    j: common_vendor.f($data.menuList, (menu, index, i0) => {
      return {
        a: menu.icon,
        b: common_vendor.t(menu.label),
        c: index,
        d: common_vendor.o(($event) => $options.handleMenuClick(menu), index)
      };
    }),
    k: $data.assets.mineArrow,
    l: $data.isLogin
  }, $data.isLogin ? {
    m: common_vendor.o((...args) => $options.handleLogout && $options.handleLogout(...args), "33")
  } : {}, {
    n: common_vendor.p({
      active: "mine"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-569e925a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/index.js.map
