"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
  const _easycom_u_search2 = common_vendor.resolveComponent("u-search");
  _easycom_u_search2();
}
const _easycom_u_search = () => "../../node-modules/uview-plus/components/u-search/u-search.js";
if (!Math) {
  _easycom_u_search();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  setup(__props) {
    var _a, _b;
    const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
    (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config;
    common_vendor.computed(() => {
      return common_vendor.index.getStorageSync("openid");
    });
    const searchInfo = common_vendor.ref({});
    const config = common_vendor.ref({ logoUrl: [] });
    const list = common_vendor.ref([]);
    const total = common_vendor.ref(0);
    const skip = common_vendor.ref(0);
    const limit = common_vendor.ref(6);
    const page = common_vendor.ref(0);
    const is_bottom = common_vendor.ref(false);
    common_vendor.ref(0);
    const statusList = common_vendor.ref([]);
    common_vendor.onLoad(async () => {
      await searchOther();
      await searchConfig();
      await search();
    });
    const searchOther = async () => {
      let res;
      res = await $api(`dictData`, "GET", { code: "valuation", is_use: "0" });
      if (res.errcode === 0)
        statusList.value = res.data;
    };
    const searchConfig = async () => {
      config.value = common_vendor.index.getStorageSync("config");
    };
    const search = async () => {
      const info = {
        skip: skip.value,
        limit: limit.value
        // openid: openid.value
      };
      const res = await $api("estimate", "GET", {
        ...info,
        ...searchInfo.value
      });
      if (res.errcode === 0) {
        list.value = list.value.concat(res.data);
        total.value = res.total;
      } else {
        common_vendor.index.showToast({
          title: res.errmsg || "",
          icon: "error"
        });
      }
    };
    const getDict = (data, model) => {
      let list2;
      switch (model) {
        case "status":
          list2 = statusList.value;
          break;
      }
      if (!list2)
        return;
      const res = list2.find((f) => f.value == data);
      return (res == null ? void 0 : res.label) || "暂无";
    };
    const toChange = () => {
      common_vendor.index.navigateTo({
        url: `/pagesHome/type/index`
      });
    };
    const toPage = () => {
      if (total.value > list.value.length) {
        common_vendor.index.showLoading({
          title: "加载中",
          mask: true
        });
        page.value = page.value + 1;
        skip.value = page.value * limit.value;
        search();
        common_vendor.index.hideLoading();
      } else
        is_bottom.value = true;
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(toChange),
        b: common_vendor.p({
          shape: "square",
          ["show-action"]: false,
          placeholder: "品牌/车系"
        }),
        c: common_vendor.f(list.value, (item, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(item.brand || "暂无"),
            b: common_vendor.t(item.bank || "暂无"),
            c: common_vendor.t(item.type || "暂无"),
            d: item.start
          }, item.start ? {
            e: common_vendor.t(item.start || "暂无")
          } : {}, {
            f: item.course
          }, item.course ? {
            g: common_vendor.t(item.course || "暂无")
          } : {}, {
            h: item.city
          }, item.city ? {
            i: common_vendor.t(item.city || "暂无")
          } : {}, {
            j: item.place
          }, item.place ? {
            k: common_vendor.t(item.place || "暂无")
          } : {}, {
            l: item.estimate
          }, item.estimate ? {
            m: common_vendor.t(item.estimate || "暂无")
          } : {}, {
            n: item.status
          }, item.status ? {
            o: common_vendor.t(getDict(item.status, "status"))
          } : {}, {
            p: index
          });
        }),
        d: is_bottom.value
      }, is_bottom.value ? {
        e: common_vendor.t(config.value.bottom_title || "没有更多了！")
      } : {}, {
        f: common_vendor.o(toPage)
      });
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8e01b58b"], ["__file", "D:/project/赋强公证/notarization_applet/pagesMy/car/index.vue"]]);
wx.createPage(MiniProgramPage);
