"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const api_api = require("../../api/api.js");
if (!Array) {
  const _easycom_uni_transition2 = common_vendor.resolveComponent("uni-transition");
  const _easycom_orderList2 = common_vendor.resolveComponent("orderList");
  const _easycom_cc_myTabbar2 = common_vendor.resolveComponent("cc-myTabbar");
  (_easycom_uni_transition2 + _easycom_orderList2 + _easycom_cc_myTabbar2)();
}
const _easycom_uni_transition = () => "../../uni_modules/uni-transition/components/uni-transition/uni-transition.js";
const _easycom_orderList = () => "../../components/orderList/orderList.js";
const _easycom_cc_myTabbar = () => "../../uni_modules/cc-myTabbar/components/cc-myTabbar/cc-myTabbar.js";
if (!Math) {
  (_easycom_uni_transition + _easycom_orderList + _easycom_cc_myTabbar)();
}
const _sfc_main = {
  __name: "index",
  setup(__props) {
    let longitude = common_vendor.ref(113.675688);
    let latitude = common_vendor.ref(34.75527700365562);
    let mapContext = common_vendor.ref(null);
    let mapBox = common_vendor.ref(false);
    let mapLocationRef = common_vendor.ref();
    let infoDz = common_vendor.ref([]);
    let markList = common_vendor.ref([]);
    common_vendor.onLoad(async () => {
      mapContext.value = common_vendor.index.createMapContext("map");
      const { longitude: lon, latitude: lat } = await common_vendor.index.getLocation({
        type: "gcj02"
        // 根据实际需要选择坐标系
      });
      latitude.value = lat;
      longitude.value = lon;
      getInfo();
      setTimeout(() => {
        mapLocation();
      }, 300);
    });
    let getInfo = async () => {
      let _res = await api_api.aroundAreaMap({
        orderByType: 1,
        lat: latitude.value,
        lon: longitude.value
      });
      let list = _res.map((item, index) => {
        return {
          id: item.id,
          longitude: item.location.lng,
          latitude: item.location.lat,
          iconPath: "/static/icon/marker-pointer.png",
          width: 20,
          height: 23,
          content: "2",
          gunUseCount: item.gunUseCount,
          gunCount: item.gunCount,
          distance: item.distance,
          customCallout: {
            display: "ALWAYS",
            // 显示方式
            anchorX: 0,
            // 锚点X轴
            anchorY: -10
            // 锚点Y轴
          }
        };
      });
      list.unshift({
        longitude: longitude.value,
        latitude: latitude.value,
        iconPath: "/static/icon/my-location-default.png",
        width: 45,
        height: 45,
        id: -1
      });
      markList.value = list;
    };
    const mapLocation = () => {
      const log = longitude.value;
      const lat = latitude.value;
      mapContext.value.moveToLocation({
        longitude: log,
        latitude: lat
      });
    };
    const regionchange = (e) => {
      if (e.type == "end") {
        common_vendor.index.__f__("log", "at pages/index/index.vue:125", e);
        common_vendor.index.__f__("log", "at pages/index/index.vue:126", e.detail.scale);
        mapBox.value = false;
        mapLocationRefStep(false);
      }
    };
    const markerClick = async (e) => {
      var _a;
      common_vendor.index.__f__("log", "at pages/index/index.vue:134", e, "eeeeeee");
      if (e.markerId == -1) {
        return;
      }
      common_vendor.index.showLoading();
      let _res = await api_api.infoAroundApi({
        id: e.markerId
      });
      let markerInfo = markList.value.find((val) => val.id == e.markerId);
      let data = (_a = _res == null ? void 0 : _res.priceList) == null ? void 0 : _a.find((val) => val.isCurrent == 1);
      infoDz.value = {
        ..._res,
        distance: markerInfo.distance,
        priceAmount: data.totalAmount
      };
      common_vendor.index.__f__("log", "at pages/index/index.vue:153", infoDz, "infoDzinfoDz");
      common_vendor.index.hideLoading();
      mapBox.value = true;
      mapLocationRefStep(true);
    };
    const mapLocationRefStep = (type) => {
      if (type) {
        mapLocationRef.value.step(
          {
            translateY: "-200rpx"
          },
          {
            timingFunction: "ease-in",
            duration: 100
          }
        );
      } else {
        mapLocationRef.value.step(
          {
            translateY: "0rpx"
          },
          {
            timingFunction: "ease",
            duration: 500
          }
        );
      }
      mapLocationRef.value.run();
    };
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(common_vendor.unref(markList), (item, index, i0) => {
          return {
            a: common_vendor.t(item.gunUseCount || 0),
            b: common_vendor.t(item.gunCount || 0),
            c: item.id
          };
        }),
        b: common_assets._imports_0$1,
        c: common_vendor.unref(longitude),
        d: common_vendor.o(markerClick),
        e: common_vendor.o(markerClick),
        f: common_vendor.o(regionchange),
        g: common_vendor.unref(markList),
        h: common_vendor.unref(latitude),
        i: common_assets._imports_1$1,
        j: common_vendor.o(mapLocation),
        k: common_vendor.sr(mapLocationRef, "1a922a9b-0", {
          "k": "mapLocationRef"
        }),
        l: common_vendor.p({
          show: true
        }),
        m: common_vendor.p({
          toNav: true,
          Image: true,
          info: common_vendor.unref(infoDz),
          list: common_vendor.unref(infoDz).pictures
        }),
        n: common_vendor.p({
          modeClass: "fade",
          show: common_vendor.unref(mapBox)
        }),
        o: common_vendor.p({
          tabBarShow: 1
        })
      };
    };
  }
};
wx.createPage(_sfc_main);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/index.js.map
