"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const api_api = require("../../api/api.js");
const hooks_useNav = require("../../hooks/useNav.js");
if (!Array) {
  const _easycom_search2 = common_vendor.resolveComponent("search");
  const _easycom_up_swiper2 = common_vendor.resolveComponent("up-swiper");
  const _easycom_orderList2 = common_vendor.resolveComponent("orderList");
  const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
  const _easycom_tabbar2 = common_vendor.resolveComponent("tabbar");
  (_easycom_search2 + _easycom_up_swiper2 + _easycom_orderList2 + _easycom_z_paging2 + _easycom_tabbar2)();
}
const _easycom_search = () => "../../components/search/search.js";
const _easycom_up_swiper = () => "../../uni_modules/uview-plus/components/u-swiper/u-swiper.js";
const _easycom_orderList = () => "../../components/orderList/orderList.js";
const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
const _easycom_tabbar = () => "../../components/tabbar/tabbar.js";
if (!Math) {
  (_easycom_search + _easycom_up_swiper + _easycom_orderList + _easycom_z_paging + _easycom_tabbar)();
}
const _sfc_main = {
  __name: "home",
  setup(__props) {
    const { nav, navTo } = hooks_useNav.useNav();
    const dataList = common_vendor.ref([]);
    const paging = common_vendor.ref(null);
    const query = common_vendor.reactive({
      lon: "",
      lat: "",
      orderByType: 1,
      //1-最近;2-空闲较多
      keyWord: ""
    });
    const list1 = common_vendor.ref([]);
    common_vendor.onLoad(async () => {
      let _res = await api_api.bannerList();
      list1.value = _res;
    });
    common_vendor.onShow(() => {
      common_vendor.index.hideTabBar();
    });
    const queryList = async () => {
      common_vendor.index.showLoading({
        title: "加载中..."
      });
      try {
        if (!query.lon && !query.lat) {
          const { longitude: lon, latitude: lat } = await common_vendor.index.getLocation();
          query.lon = lon;
          query.lat = lat;
        }
      } catch (err) {
        console.log(err);
      }
      console.log(query);
      api_api.aroundAreaApi(query).then((res) => {
        console.log(res, "list");
        paging.value.complete(res);
        common_vendor.index.hideLoading();
      }).catch((res) => {
        paging.value.complete(false);
        common_vendor.index.hideLoading();
      });
    };
    let tabChange = (e) => {
      query.orderByType = e;
      paging.value.reload();
    };
    let isPagingRefNotFound = () => {
      return !paging.value;
    };
    common_vendor.onPullDownRefresh(() => {
      if (isPagingRefNotFound())
        return;
      paging.value.reload().catch(() => {
      });
    });
    common_vendor.onPageScroll((e) => {
      if (isPagingRefNotFound())
        return;
      paging.value.updatePageScrollTop(e.scrollTop);
      e.scrollTop < 10 && paging.value.doChatRecordLoadMore();
    });
    common_vendor.onReachBottom(() => {
      if (isPagingRefNotFound())
        return;
      paging.value.pageReachBottom();
    });
    const toOrder = () => {
      common_vendor.index.switchTab({
        url: "/pages/order/order"
      });
    };
    let searchChange = (e) => {
      query.keyWord = e;
      paging.value.reload();
    };
    let showMode = () => {
      common_vendor.index.showModal({
        title: "提示",
        content: "暂未开放",
        showCancel: false,
        confirmText: "确认",
        success: () => {
        }
      });
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(common_vendor.unref(searchChange)),
        b: common_vendor.p({
          list: list1.value,
          height: "150rpx",
          keyName: "imageUrl",
          indicator: true
        }),
        c: common_assets._imports_0,
        d: common_vendor.o(toOrder),
        e: common_assets._imports_1,
        f: common_vendor.o((...args) => common_vendor.unref(showMode) && common_vendor.unref(showMode)(...args)),
        g: common_assets._imports_2,
        h: common_vendor.o(($event) => common_vendor.unref(navTo)("/pageMake/invoice/invoice")),
        i: common_assets._imports_3,
        j: query.orderByType == 1
      }, query.orderByType == 1 ? {} : {}, {
        k: common_vendor.o(($event) => common_vendor.unref(tabChange)(1)),
        l: query.orderByType == 2
      }, query.orderByType == 2 ? {} : {}, {
        m: common_vendor.o(($event) => common_vendor.unref(tabChange)(2)),
        n: common_vendor.f(dataList.value, (item, index, i0) => {
          return {
            a: "07e72d3c-3-" + i0 + ",07e72d3c-2",
            b: common_vendor.p({
              toNav: true,
              info: item
            }),
            c: index
          };
        }),
        o: () => ({
          r: paging,
          k: "paging"
        }),
        p: common_vendor.o(queryList),
        q: common_vendor.o(($event) => dataList.value = $event),
        r: common_vendor.p({
          ["use-page-scroll"]: true,
          modelValue: dataList.value
        }),
        s: common_vendor.p({
          path: "/pages/home/home"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-07e72d3c"]]);
_sfc_main.__runtimeHooks = 1;
my.createPage(MiniProgramPage);
