"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
  data() {
    return {
      statusBarHeight: 20,
      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;
      return `calc(100vh - ${this.statusBarHeight + 164}px - ${80 + safeBottom}px)`;
    }
  },
  onLoad(options) {
    const info = common_vendor.index.getSystemInfoSync();
    this.statusBarHeight = info.statusBarHeight;
    if (options.data) {
      try {
        this.order = JSON.parse(decodeURIComponent(options.data));
      } catch (e) {
        common_vendor.index.__f__("error", "at pages/order/detail.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/order" });
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args), "ee"),
    b: $data.statusBarHeight + "px",
    c: common_vendor.t($data.order.statusName),
    d: common_vendor.t($options.statusSubText),
    e: common_vendor.n($data.order.statusType),
    f: 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
      };
    }),
    g: common_vendor.t($data.order.orderNo),
    h: [2, 3, 4].includes($data.order.status)
  }, [2, 3, 4].includes($data.order.status) ? {
    i: common_vendor.t($data.order.erpNo || "ERP" + $data.order.orderNo.slice(-8))
  } : {}, {
    j: common_vendor.t($data.order.time),
    k: $options.scrollHeight,
    l: $data.order.status === 1
  }, $data.order.status === 1 ? {
    m: common_vendor.o((...args) => $options.doCancel && $options.doCancel(...args), "e1"),
    n: common_vendor.o((...args) => $options.callSales && $options.callSales(...args), "e9")
  } : {
    o: common_vendor.o((...args) => $options.goHome && $options.goHome(...args), "c7")
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6b23c96c"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/order/detail.js.map
