"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const utils_api = require("../../utils/api.js");
if (!Array) {
  const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
  const _easycom_uv_qrcode2 = common_vendor.resolveComponent("uv-qrcode");
  const _easycom_wd_popup2 = common_vendor.resolveComponent("wd-popup");
  (_easycom_wd_icon2 + _easycom_uv_qrcode2 + _easycom_wd_popup2)();
}
const _easycom_wd_icon = () => "../../uni_modules/wot-design-uni/components/wd-icon/wd-icon.js";
const _easycom_uv_qrcode = () => "../../uni_modules/uv-qrcode/components/uv-qrcode/uv-qrcode.js";
const _easycom_wd_popup = () => "../../uni_modules/wot-design-uni/components/wd-popup/wd-popup.js";
if (!Math) {
  (_easycom_wd_icon + _easycom_uv_qrcode + _easycom_wd_popup)();
}
const _sfc_main = {
  __name: "orderDetail",
  setup(__props) {
    const info = common_vendor.ref();
    common_vendor.index.getStorageSync("carUserInfo");
    const popShow_pay = common_vendor.ref(false);
    const payList = common_vendor.ref([
      {
        text: "微信支付",
        icon: "/static/images/pay/wx.png",
        isCheck: false
      },
      {
        text: "电子交通卡支付",
        icon: "/static/images/pay/card.png",
        isCheck: false
      }
    ]);
    const selectedPay = common_vendor.ref(null);
    const orderNo = common_vendor.ref("");
    const getRouteParts = (str) => {
      if (typeof str === "string" && str.length > 0) {
        return str.split("→");
      }
      return [];
    };
    common_vendor.onLoad((options) => {
      if (options.info) {
        info.value = JSON.parse(decodeURIComponent(options.info));
        console.log(info.value, "单");
      }
    });
    const handlePay = (item) => {
      popShow_pay.value = true;
      orderNo.value = item;
    };
    const handleClose = () => {
      popShow_pay.value = false;
    };
    const togglePay = (item) => {
      payList.value.forEach((pay) => {
        pay.isCheck = false;
      });
      item.isCheck = true;
      selectedPay.value = item;
    };
    const payTime = () => {
      if (!selectedPay.value) {
        common_vendor.index.showModal({
          content: "请选择支付方式"
        });
        return;
      }
      if (selectedPay.value.text == "微信支付") {
        payWei();
      } else if (selectedPay.value.text == "电子交通卡支付")
        ;
    };
    const payWei = async () => {
      const res = await utils_api.myRequest({
        url: "/tAppcontinuePay.action",
        // method: 'POST', // 明确指定请求方法为POST
        data: {
          order_num: orderNo.value
        }
      });
      if (res.code == 200) {
        payParams.value = res.data;
        invokeWechatPay();
      } else {
        common_vendor.index.showToast({ title: res.message });
      }
    };
    const invokeWechatPay = () => {
      common_vendor.index.requestPayment({
        ...payParams.value,
        success: (res) => {
          common_vendor.index.showToast({ title: "支付成功" });
          setTimeout(function() {
            getMyData();
          }, 1e3);
        },
        fail: (err) => {
          common_vendor.index.showToast({ title: "支付失败", icon: "none" });
          console.error("支付失败", err);
        }
      });
    };
    const tuiPay = async (item) => {
      const res = await utils_api.myRequest({
        url: "/tApprefund.action",
        // method: 'POST', // 明确指定请求方法为POST
        data: {
          order_num: item.orderNo,
          id: item.id
        }
      });
      if (res.code == 200) {
        common_vendor.index.showToast({ title: "退款成功" });
        setTimeout(function() {
          common_vendor.index.switchTab({
            url: "/pages/order/order"
          });
        }, 1e3);
      } else {
        common_vendor.index.showToast({ title: res.message });
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_assets._imports_0$1,
        b: info.value.payState === 1 && info.value.byState === 3
      }, info.value.payState === 1 && info.value.byState === 3 ? {
        c: common_vendor.p({
          name: "clock",
          color: "#001713",
          size: "22"
        })
      } : {}, {
        d: info.value.payState === 1 && info.value.byState === 2
      }, info.value.payState === 1 && info.value.byState === 2 ? {
        e: common_vendor.p({
          name: "check-outline",
          color: "#001713",
          size: "22"
        })
      } : {}, {
        f: info.value.payState === 0
      }, info.value.payState === 0 ? {
        g: common_vendor.p({
          name: "money-circle",
          color: "#001713",
          size: "22"
        })
      } : {}, {
        h: info.value.payState === 3
      }, info.value.payState === 3 ? {
        i: common_vendor.p({
          name: "file-excel",
          color: "#001713",
          size: "22"
        })
      } : {}, {
        j: _ctx.statusValue === "预约失败"
      }, _ctx.statusValue === "预约失败" ? {
        k: common_vendor.p({
          name: "warning",
          color: "#001713",
          size: "22"
        })
      } : {}, {
        l: common_assets._imports_1$4,
        m: info.value.payState === 1 && info.value.byState === 3 || info.value.payState === 1 && info.value.byState === 1
      }, info.value.payState === 1 && info.value.byState === 3 || info.value.payState === 1 && info.value.byState === 1 ? {
        n: common_vendor.t(info.value.ciDate),
        o: common_vendor.t(info.value.route_end),
        p: common_vendor.t(getRouteParts(info.value.route_end).prefix)
      } : {}, {
        q: info.value.payState === 0
      }, info.value.payState === 0 ? {} : {}, {
        r: info.value.payState === 1 && info.value.byState === 2
      }, info.value.payState === 1 && info.value.byState === 2 ? {} : {}, {
        s: info.value.payState === 3
      }, info.value.payState === 3 ? {} : {}, {
        t: common_vendor.t(info.value.ciDate),
        v: common_vendor.t(info.value.car_number),
        w: common_vendor.n(info.value.payState === 0 || info.value.byState === 3 || info.value.byState === 1 ? "carMsg_number" : "carMsg_number1"),
        x: common_vendor.t(info.value.contain),
        y: common_vendor.n(info.value.payState === 0 || info.value.byState === 3 || info.value.byState === 1 ? "carMsg_volume" : "carMsg_volume1"),
        z: common_assets._imports_2$1,
        A: common_vendor.f(getRouteParts(info.value.route_end), (item2, index2, i0) => {
          return {
            a: common_vendor.t(item2),
            b: index2 > 0 ? 1 : "",
            c: index2
          };
        }),
        B: info.value.payState === 1 && info.value.byState === 3 || info.value.payState === 1 && info.value.byState === 1
      }, info.value.payState === 1 && info.value.byState === 3 || info.value.payState === 1 && info.value.byState === 1 ? {
        C: common_vendor.sr("qrcode", "1353b6cf-5"),
        D: common_vendor.p({
          size: "180",
          value: info.value.id
        })
      } : {}, {
        E: common_vendor.t(info.value.row_num),
        F: common_vendor.t(info.value.createTime),
        G: common_vendor.t(info.value.payAmount),
        H: common_vendor.n(info.value.payState === 0 || info.value.byState === 3 || info.value.byState === 1 ? "info_price" : "info_price1"),
        I: info.value.payState == 1 && info.value.state != 4
      }, info.value.payState == 1 && info.value.state != 4 ? common_vendor.e({
        J: info.value.byState == 3
      }, info.value.byState == 3 ? {} : {}) : {}, {
        K: info.value.payState === 0
      }, info.value.payState === 0 ? {
        L: common_vendor.t(info.value.payAmount),
        M: common_vendor.o(($event) => handlePay(info.value.orderNo))
      } : {}, {
        N: info.value.payState == 1 && info.value.state != 4
      }, info.value.payState == 1 && info.value.state != 4 ? common_vendor.e({
        O: info.value.byState == 3 || info.value.byState == 1
      }, info.value.byState == 3 || info.value.byState == 1 ? {
        P: common_vendor.t(info.value.payAmount),
        Q: common_vendor.o(($event) => tuiPay(info.value))
      } : {}) : {}, {
        R: common_vendor.p({
          name: "close-bold",
          color: "#ABA6A6",
          size: "22"
        }),
        S: common_vendor.o(handleClose),
        T: common_vendor.f(payList.value, (item, index, i0) => {
          return {
            a: item.icon,
            b: common_vendor.t(item.text),
            c: item.isCheck,
            d: common_vendor.o(($event) => togglePay(item), index),
            e: index
          };
        }),
        U: common_vendor.o(payTime),
        V: common_vendor.o(($event) => popShow_pay.value = $event),
        W: common_vendor.p({
          position: "bottom",
          ["safe-area-inset-bottom"]: true,
          ["close-on-click-modal"]: false,
          modelValue: popShow_pay.value
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1353b6cf"], ["__file", "D:/创海项目/CH2025/约车小程序/yueche_app/pages/orderDetail/orderDetail.vue"]]);
wx.createPage(MiniProgramPage);
