"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_wd_datetime_picker2 = common_vendor.resolveComponent("wd-datetime-picker");
  (_easycom_wd_icon2 + _easycom_wd_datetime_picker2)();
}
const _easycom_wd_icon = () => "../../uni_modules/wot-design-uni/components/wd-icon/wd-icon.js";
const _easycom_wd_datetime_picker = () => "../../uni_modules/wot-design-uni/components/wd-datetime-picker/wd-datetime-picker.js";
if (!Math) {
  (_easycom_wd_icon + _easycom_wd_datetime_picker)();
}
const _sfc_main = {
  __name: "useDetail",
  setup(__props) {
    const userInfo = common_vendor.index.getStorageSync("carUserInfo");
    const paddingTop = common_vendor.ref(0);
    const timeValue1 = common_vendor.ref(/* @__PURE__ */ new Date());
    const timeValue = common_vendor.ref(/* @__PURE__ */ new Date());
    const timeTime = common_vendor.ref("");
    const pageSize = common_vendor.ref(6);
    const currentPage = common_vendor.ref(1);
    const total = common_vendor.ref(0);
    const listData = common_vendor.ref([]);
    common_vendor.onMounted(() => {
      paddingTop.value = common_vendor.index.getMenuButtonBoundingClientRect().top;
    });
    function formattedDate(value) {
      const date = new Date(value);
      return date.toString();
    }
    function formattedDate2(value) {
      const date = new Date(value);
      const year = date.getFullYear();
      const month = String(date.getMonth() + 1).padStart(2, "0");
      return `${year}-${month}`;
    }
    function nextMonth(value1) {
      const [year, month] = value1.value.split("-").map(Number);
      let newYear = year;
      let newMonth = month + 1;
      if (newMonth > 12) {
        newYear += 1;
        newMonth = 1;
      }
      return `${newYear}-${String(newMonth).padStart(2, "0")}`;
    }
    const handleConfirm = (value) => {
      timeValue.value = formattedDate(value.value);
      getMyData();
    };
    async function getMyData() {
      const start = formattedDate2(timeValue.value);
      timeTime.value = formattedDate2(timeValue.value);
      const end = nextMonth(timeTime);
      const res = await utils_api.myRequest({
        url: "/cardlist.action",
        data: {
          mobile: userInfo.mobile,
          createStart: start,
          createEnd: end,
          rows: pageSize.value,
          page: currentPage.value
        }
      });
      console.log(res);
      listData.value = [...listData.value, ...res.rows];
      total.value = res.total;
    }
    common_vendor.onLoad(() => {
      getMyData();
      console.log(111, timeValue.value);
    });
    const scrolltolower = () => {
      if (listData.value.length < total.value) {
        currentPage.value++;
        getMyData();
      } else {
        common_vendor.index.showToast({
          title: "没有更多数据了",
          icon: "none"
        });
      }
    };
    const handleBack = () => {
      common_vendor.index.navigateBack();
    };
    return (_ctx, _cache) => {
      return {
        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: common_vendor.o(handleConfirm),
        f: common_vendor.o(($event) => timeValue1.value = $event),
        g: common_vendor.p({
          type: "year-month",
          format: "yyyy-MM",
          modelValue: timeValue1.value
        }),
        h: common_vendor.f(listData.value, (item, index, i0) => {
          return common_vendor.e({
            a: item.vertifyState == 1
          }, item.vertifyState == 1 ? {
            b: common_vendor.t(item.orderNum),
            c: common_vendor.t(item.account4),
            d: common_vendor.t(item.account4),
            e: common_vendor.t(item.account1),
            f: common_vendor.t(item.createTime)
          } : {}, {
            g: item.vertifyState == 0
          }, item.vertifyState == 0 ? {
            h: common_vendor.t(item.orderNum),
            i: common_vendor.t(item.account4),
            j: common_vendor.t(item.account1),
            k: common_vendor.t(item.createTime)
          } : {}, {
            l: index
          });
        }),
        i: common_vendor.o(scrolltolower)
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-551fb24c"], ["__file", "D:/创海项目/CH2025/约车小程序/yueche_app/pages/useDetail/useDetail.vue"]]);
wx.createPage(MiniProgramPage);
