"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const utils_api = require("../../utils/api.js");
const utils_tabParams = require("../../utils/tabParams.js");
if (!Array) {
  const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
  const _easycom_wd_popup2 = common_vendor.resolveComponent("wd-popup");
  (_easycom_wd_icon2 + _easycom_wd_popup2)();
}
const _easycom_wd_icon = () => "../../uni_modules/wot-design-uni/components/wd-icon/wd-icon.js";
const _easycom_wd_popup = () => "../../uni_modules/wot-design-uni/components/wd-popup/wd-popup.js";
if (!Math) {
  (_easycom_wd_icon + _easycom_wd_popup)();
}
const _sfc_main = {
  __name: "transportation",
  setup(__props) {
    utils_tabParams.useTabParamStore();
    const paddingTop = common_vendor.ref(0);
    const userInfo = common_vendor.index.getStorageSync("carUserInfo");
    const cardType = common_vendor.ref("优行卡");
    const cardTypeNum = common_vendor.ref(0);
    const freePay = common_vendor.ref(0);
    const chongPay = common_vendor.ref(0);
    const buPay = common_vendor.ref(0);
    const popShow = common_vendor.ref(false);
    const rulesImg = common_vendor.ref("");
    const rulesImg1 = common_vendor.ref("");
    const rulesImg2 = common_vendor.ref("");
    const rulesImg3 = common_vendor.ref("");
    const clickImg = () => {
      common_vendor.wx$1.previewImage({
        urls: [rulesImg.value],
        //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
        current: "",
        // 当前显示图片的http链接，默认是第一个
        success: function(res) {
        },
        fail: function(res) {
        },
        complete: function(res) {
        }
      });
    };
    async function getMyVetry() {
      const res = await utils_api.myRequest({
        url: "/vertifyqueryOwn.action",
        data: {
          mobile: userInfo.mobile
        }
      });
      console.log(res.value, res.code == 205);
      if (res.code == 200) {
        if (res.data[0].type == 1) {
          cardType.value = "教师卡";
          cardTypeNum.value = 1;
        } else if (res.data[0].type == 2) {
          cardType.value = "暖心卡";
          cardTypeNum.value = 2;
        }
        getYougui();
        console.log("卡", cardTypeNum.value);
        common_vendor.index.setStorageSync("cardTypeNum", cardTypeNum.value);
      } else if (res.code == 205) {
        cardType.value = "优行卡";
        cardTypeNum.value = 0;
        getYougui();
        console.log("卡", cardTypeNum.value);
        common_vendor.index.setStorageSync("cardTypeNum", cardTypeNum.value);
      }
    }
    async function getYougui() {
      const res = await utils_api.myRequest({
        url: "/fileslist.action",
        data: {}
      });
      if (res.code == 200) {
        for (var i = 0; i < res.data.length; i++) {
          if (res.data[i].name == "优行卡规则内容") {
            rulesImg1.value = res.data[i].url;
          } else if (res.data[i].name == "教师卡规则内容") {
            rulesImg2.value = res.data[i].url;
          } else if (res.data[i].name == "暖心卡规则内容") {
            rulesImg3.value = res.data[i].url;
          }
        }
        if (cardTypeNum.value == 1) {
          rulesImg.value = rulesImg2.value;
        } else if (cardTypeNum.value == 1) {
          rulesImg.value = rulesImg3.value;
        } else if (cardTypeNum.value == 0) {
          rulesImg.value = rulesImg1.value;
        }
      }
    }
    async function getKaYue() {
      const res = await utils_api.myRequest({
        url: "/tAppsummary.action",
        data: {
          mobile: userInfo.mobile
          // nickname:userInfo.username,
          // type:cardTypeNum,
        }
      });
      if (res.code == 200) {
        freePay.value = res.data.freeBalance.money;
        chongPay.value = res.data.mainBalance.money;
        buPay.value = res.data.allowanceBalance.money;
      }
    }
    common_vendor.onMounted(() => {
      paddingTop.value = common_vendor.index.getMenuButtonBoundingClientRect().top;
      getMyVetry();
      getKaYue();
      getYougui();
    });
    const handleDetail = () => {
      common_vendor.index.navigateTo({
        url: "/pages/useDetail/useDetail"
      });
    };
    const handlePull = () => {
      common_vendor.index.navigateTo({
        url: "/pages/pay/pay"
      });
    };
    const goPage = (url) => {
      common_vendor.index.navigateTo({
        url: "/pages/identity/identity"
      });
    };
    const handleRefund = () => {
      popShow.value = true;
    };
    const closePop = () => {
      popShow.value = false;
    };
    const tuikuan = async () => {
      const res = await utils_api.myRequest({
        url: "/cardrefund.action",
        // method: 'POST', // 明确指定请求方法为POST
        data: {
          id: userInfo.id,
          refundAccount: freePay.value
        }
      });
      if (res.code == 200) {
        common_vendor.index.showToast({
          title: res.message,
          icon: "none"
        });
      } else {
        common_vendor.index.showToast({
          title: res.message,
          icon: "none"
        });
      }
      popShow.value = false;
    };
    const handleBack = () => {
      common_vendor.index.navigateBack();
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_assets._imports_0$1,
        b: common_vendor.p({
          name: "thin-arrow-left",
          color: "#001713",
          size: "18"
        }),
        c: common_vendor.o(handleBack),
        d: `${paddingTop.value * 2}rpx`,
        e: cardType.value == "优行卡"
      }, cardType.value == "优行卡" ? {} : {}, {
        f: cardType.value == "教师卡"
      }, cardType.value == "教师卡" ? {} : {}, {
        g: cardType.value == "暖心卡"
      }, cardType.value == "暖心卡" ? {} : {}, {
        h: common_vendor.t(cardType.value),
        i: common_vendor.p({
          name: "arrow-right",
          color: "#376477",
          size: "8"
        }),
        j: common_vendor.o(($event) => goPage()),
        k: common_vendor.t(freePay.value),
        l: common_vendor.n({
          btn_excellent: cardType.value == "优行卡"
        }),
        m: common_vendor.n({
          btn_teacher: cardType.value == "教师卡"
        }),
        n: common_vendor.n({
          btn_warm: cardType.value == "暖心卡"
        }),
        o: common_vendor.o(handleDetail),
        p: common_vendor.n({
          line_excellent: cardType.value == "优行卡"
        }),
        q: common_vendor.n({
          line_teacher: cardType.value == "教师卡"
        }),
        r: common_vendor.n({
          line_warm: cardType.value == "暖心卡"
        }),
        s: common_vendor.n({
          excellent: cardType.value == "优行卡"
        }),
        t: common_vendor.n({
          teacher: cardType.value == "教师卡"
        }),
        v: common_vendor.n({
          warm: cardType.value == "暖心卡"
        }),
        w: common_vendor.o(handlePull),
        x: common_vendor.o(handleRefund),
        y: rulesImg.value,
        z: common_vendor.o(clickImg),
        A: common_vendor.p({
          name: "close",
          size: "16"
        }),
        B: common_vendor.o(closePop),
        C: freePay.value == 0
      }, freePay.value == 0 ? {} : {}, {
        D: freePay.value > 0
      }, freePay.value > 0 ? {
        E: common_vendor.t(freePay.value)
      } : {}, {
        F: freePay.value > 0
      }, freePay.value > 0 ? {} : {}, {
        G: freePay.value > 0
      }, freePay.value > 0 ? {
        H: common_vendor.o(tuikuan)
      } : {}, {
        I: common_vendor.o(($event) => popShow.value = $event),
        J: common_vendor.p({
          position: "bottom",
          ["safe-area-inset-bottom"]: true,
          ["close-on-click-modal"]: false,
          modelValue: popShow.value
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-12c962df"], ["__file", "D:/创海项目/CH2025/约车小程序/yueche_app/pages/transportation/transportation.vue"]]);
wx.createPage(MiniProgramPage);
