"use strict";
const common_vendor = require("../../../common/vendor.js");
const ErpNavBar = () => "../../../components/erp-nav-bar.js";
const _sfc_main = {
  components: { ErpNavBar },
  data() {
    return {
      footerHeight: 80,
      // px
      headerHeight: 120,
      // px
      order: {
        orderNo: "-",
        status: 1,
        statusName: "加载中",
        statusType: "pending",
        models: [],
        erpNo: "",
        time: "-"
      }
    };
  },
  computed: {
    statusSubText() {
      const map = {
        pending: "您的订单已提交，正在排队等待审核...",
        process: "审核已完成，正在由相关主管签批...",
        making: "订单已入库排产，工厂正在全力生产中...",
        finish: "该订单生产已完成并正式入库。",
        expired: "该订单已由客户主动撤销。"
      };
      return map[this.order.statusType] || "订单状态更新中";
    },
    scrollHeight() {
      const info = common_vendor.index.getSystemInfoSync();
      const safeBottom = info.safeAreaInsets ? info.safeAreaInsets.bottom : 0;
      const statusBarHeight = common_vendor.index.getSystemInfoSync().statusBarHeight || 20;
      return `calc(100vh - ${statusBarHeight + 164}px - ${80 + safeBottom}px)`;
    }
  },
  onLoad(options) {
    if (options.data) {
      try {
        this.order = JSON.parse(decodeURIComponent(options.data));
      } catch (e) {
        common_vendor.index.__f__("error", "at pages/order/detail/index.vue:124", "Data Error");
      }
    }
  },
  methods: {
    goBack() {
      common_vendor.index.navigateBack();
    },
    doCancel() {
      common_vendor.index.showModal({
        title: "确认撤销",
        content: "订单撤销后将流转至已撤销状态，确定吗？",
        confirmColor: "#ff3b30",
        success: (res) => {
          if (res.confirm) {
            this.order.status = 0;
            this.order.statusName = "已撤销";
            this.order.statusType = "expired";
            common_vendor.index.showToast({ title: "撤销成功" });
          }
        }
      });
    },
    callSales() {
      common_vendor.index.makePhoneCall({ phoneNumber: "13888888888" });
    },
    goHome() {
      common_vendor.index.reLaunch({ url: "/pages/order/index" });
    }
  }
};
if (!Array) {
  const _component_erp_nav_bar = common_vendor.resolveComponent("erp-nav-bar");
  _component_erp_nav_bar();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.p({
      title: "订单详情"
    }),
    b: common_vendor.t($data.order.statusName),
    c: common_vendor.t($options.statusSubText),
    d: common_vendor.n($data.order.statusType),
    e: common_vendor.f($data.order.models || [$data.order], (model, mIdx, i0) => {
      return {
        a: common_vendor.t(mIdx + 1),
        b: common_vendor.t(model.type),
        c: common_vendor.t(model.typeName || "铝型材主料"),
        d: common_vendor.t(model.material || "6063-T5"),
        e: common_vendor.t(model.surface),
        f: common_vendor.t(model.package || "普通包装"),
        g: common_vendor.t(model.length),
        h: common_vendor.t(model.wallThickness || "1.2"),
        i: common_vendor.t(model.count),
        j: mIdx === 0 ? 1 : "",
        k: mIdx
      };
    }),
    f: common_vendor.t($data.order.orderNo),
    g: [2, 3, 4].includes($data.order.status)
  }, [2, 3, 4].includes($data.order.status) ? {
    h: common_vendor.t($data.order.erpNo || "ERP" + $data.order.orderNo.slice(-8))
  } : {}, {
    i: common_vendor.t($data.order.time),
    j: $options.scrollHeight,
    k: $data.order.status === 1
  }, $data.order.status === 1 ? {
    l: common_vendor.o((...args) => $options.doCancel && $options.doCancel(...args), "8d"),
    m: common_vendor.o((...args) => $options.callSales && $options.callSales(...args), "49")
  } : {
    n: common_vendor.o((...args) => $options.goHome && $options.goHome(...args), "a0")
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-a8bbe39b"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/order/detail/index.js.map
