"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const api_api = require("../../api/api.js");
const utils_fun = require("../../utils/fun.js");
const hooks_useNav = require("../../hooks/useNav.js");
if (!Array) {
  const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  const _easycom_up_swiper2 = common_vendor.resolveComponent("up-swiper");
  const _easycom_orderList2 = common_vendor.resolveComponent("orderList");
  const _easycom_up_tag2 = common_vendor.resolveComponent("up-tag");
  const _easycom_up_button2 = common_vendor.resolveComponent("up-button");
  const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
  const _easycom_up_popup2 = common_vendor.resolveComponent("up-popup");
  (_easycom_up_icon2 + _easycom_up_swiper2 + _easycom_orderList2 + _easycom_up_tag2 + _easycom_up_button2 + _easycom_z_paging2 + _easycom_up_popup2)();
}
const _easycom_up_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_up_swiper = () => "../../uni_modules/uview-plus/components/u-swiper/u-swiper.js";
const _easycom_orderList = () => "../../components/orderList/orderList.js";
const _easycom_up_tag = () => "../../uni_modules/uview-plus/components/u-tag/u-tag.js";
const _easycom_up_button = () => "../../uni_modules/uview-plus/components/u-button/u-button.js";
const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
const _easycom_up_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
  (_easycom_up_icon + _easycom_up_swiper + _easycom_orderList + _easycom_up_tag + _easycom_up_button + _easycom_z_paging + _easycom_up_popup)();
}
const _sfc_main = {
  __name: "detail",
  setup(__props) {
    const { nav, navTo } = hooks_useNav.useNav();
    const headerBg = common_vendor.ref(false);
    const statusBarHeight = common_vendor.index.getSystemInfoSync().statusBarHeight + "px";
    let info = common_vendor.reactive({});
    let show = common_vendor.ref(false);
    const dataList = common_vendor.ref([]);
    const paging = common_vendor.ref(null);
    let showJf = common_vendor.ref(false);
    const fullCost = common_vendor.computed(() => {
      var _a;
      let data = (_a = info == null ? void 0 : info.priceList) == null ? void 0 : _a.find((val) => val.isCurrent == 1);
      return data || {};
    });
    common_vendor.onLoad((options) => {
      getInfo(options.id, options.distance);
    });
    common_vendor.onPageScroll((e) => {
      if (e.scrollTop > common_vendor.index.getSystemInfoSync().statusBarHeight + 44) {
        headerBg.value = true;
      } else {
        headerBg.value = false;
      }
    });
    const getInfo = async (e, distance) => {
      let _res = await api_api.infoAroundApi({ id: e });
      _res.distance = distance;
      Object.assign(info, _res);
    };
    common_vendor.ref(["https://cdn.uviewui.com/uview/swiper/swiper3.png", "https://cdn.uviewui.com/uview/swiper/swiper2.png", "https://cdn.uviewui.com/uview/swiper/swiper1.png"]);
    let toRecharge = () => {
      common_vendor.index.scanCode({
        success: function(res) {
          let query = utils_fun.urlQuery(res.result);
          if (!query.num) {
            common_vendor.index.showToast({
              title: "请扫描正确的设备码",
              icon: "none"
            });
          } else {
            navTo(`/pages/home/star?id=${query.num}`);
          }
        }
      });
    };
    const back = () => {
      common_vendor.index.navigateBack();
    };
    const queryList = async () => {
      api_api.listByStationId({ stationId: info.id }).then((res) => {
        paging.value.complete(res);
      }).catch((res) => {
        paging.value.complete(false);
      });
    };
    const showZd = () => {
      show.value = true;
      paging.value.reload();
    };
    const startCd = async (e) => {
      common_vendor.index.navigateTo({
        url: "./star?id=" + e.deviceGunNo
      });
    };
    return (_ctx, _cache) => {
      return {
        a: statusBarHeight,
        b: common_vendor.o(back),
        c: common_vendor.p({
          name: "arrow-left",
          bold: true,
          color: "#000"
        }),
        d: common_vendor.o(back),
        e: headerBg.value ? 1 : 0,
        f: common_vendor.o(() => {
        }),
        g: headerBg.value ? "#FFF" : "",
        h: common_vendor.p({
          list: common_vendor.unref(info).pictures,
          height: "530rpx"
        }),
        i: common_vendor.p({
          info: {
            ...common_vendor.unref(info),
            priceAmount: fullCost.value.totalAmount
          },
          type: "info"
        }),
        j: common_vendor.p({
          color: "#333",
          size: "28rpx",
          name: "arrow-right"
        }),
        k: common_vendor.o(($event) => common_vendor.isRef(showJf) ? showJf.value = true : showJf = true),
        l: common_vendor.p({
          size: "mini",
          text: `当前计费时间段:${fullCost.value.startTime}-${fullCost.value.endTime}`,
          plain: true,
          plainFill: true
        }),
        m: common_vendor.t(fullCost.value.totalAmount),
        n: common_assets._imports_0$4,
        o: common_vendor.t(common_vendor.unref(info).gunCount - common_vendor.unref(info).gunUseCount),
        p: common_vendor.t(common_vendor.unref(info).gunCount),
        q: common_vendor.p({
          color: "#fff",
          size: "28rpx",
          name: "arrow-right"
        }),
        r: common_vendor.o(showZd),
        s: common_vendor.t(common_vendor.unref(info).merchantName),
        t: common_assets._imports_1$3,
        v: common_vendor.o(($event) => common_vendor.unref(utils_fun.lookImg)([common_vendor.unref(info).licenseImage])),
        w: common_vendor.t(common_vendor.unref(info).busineHours),
        x: common_vendor.o(($event) => common_vendor.unref(utils_fun.lookImg)([common_vendor.unref(info).licenseImage])),
        y: common_vendor.t(common_vendor.unref(info).invoice),
        z: common_vendor.t(common_vendor.unref(info).remarks || ""),
        A: common_vendor.t(common_vendor.unref(info).stationTel),
        B: common_vendor.o(($event) => common_vendor.unref(utils_fun.call)(common_vendor.unref(info).stationTel)),
        C: common_vendor.t(fullCost.value.totalAmount),
        D: common_vendor.o((...args) => common_vendor.unref(toRecharge) && common_vendor.unref(toRecharge)(...args)),
        E: common_assets._imports_0$4,
        F: common_vendor.t(common_vendor.unref(info).gunCount - common_vendor.unref(info).gunUseCount),
        G: common_vendor.t(common_vendor.unref(info).gunCount),
        H: common_vendor.o(($event) => common_vendor.isRef(show) ? show.value = true : show = true),
        I: common_vendor.f(dataList.value, (item, index, i0) => {
          return common_vendor.e({
            a: item.realtimeStatus == 1
          }, item.realtimeStatus == 1 ? {
            b: "431a10b7-8-" + i0 + ",431a10b7-7",
            c: common_vendor.p({
              size: "mini",
              type: "error",
              text: "故障",
              plain: true,
              plainFill: true
            })
          } : item.realtimeStatus == 2 ? {
            e: "431a10b7-9-" + i0 + ",431a10b7-7",
            f: common_vendor.p({
              size: "mini",
              type: "success",
              text: "空闲",
              plain: true,
              plainFill: true
            })
          } : item.realtimeStatus == 3 ? {
            h: "431a10b7-10-" + i0 + ",431a10b7-7",
            i: common_vendor.p({
              size: "mini",
              type: "warning",
              text: "充电中",
              plain: true,
              plainFill: true
            })
          } : {
            j: "431a10b7-11-" + i0 + ",431a10b7-7",
            k: common_vendor.p({
              size: "mini",
              type: "error",
              text: "离线",
              plain: true,
              plainFill: true
            })
          }, {
            d: item.realtimeStatus == 2,
            g: item.realtimeStatus == 3,
            l: item.insertStatus == 1
          }, item.insertStatus == 1 ? {
            m: "431a10b7-12-" + i0 + ",431a10b7-7",
            n: common_vendor.p({
              size: "mini",
              text: "已插枪",
              plain: true,
              plainFill: true
            })
          } : {}, {
            o: common_vendor.t(item.gunName),
            p: common_vendor.t(item.deviceNo),
            q: common_vendor.t(item.maxPower),
            r: common_vendor.t(item.maxVoltage),
            s: item.realtimeStatus == 2
          }, item.realtimeStatus == 2 ? {
            t: common_vendor.o(($event) => startCd(item), index),
            v: "431a10b7-13-" + i0 + ",431a10b7-7",
            w: common_vendor.p({
              shape: "circle",
              type: "success",
              plain: true,
              text: "启动充电"
            })
          } : {}, {
            x: item.realtimeStatus == 1 || item.realtimeStatus == 0
          }, item.realtimeStatus == 1 || item.realtimeStatus == 0 ? {
            y: "431a10b7-14-" + i0 + ",431a10b7-7",
            z: common_vendor.p({
              shape: "circle",
              type: "error",
              plain: true,
              text: "报故障",
              openType: "contact"
            })
          } : {}, {
            A: index
          });
        }),
        J: common_vendor.sr(paging, "431a10b7-7,431a10b7-6", {
          "k": "paging"
        }),
        K: common_vendor.o(queryList),
        L: common_vendor.o(($event) => dataList.value = $event),
        M: common_vendor.p({
          fixed: false,
          ["loading-more-enabled"]: false,
          height: "600rpx;",
          auto: false,
          ["show-refresher-when-reload"]: true,
          modelValue: dataList.value
        }),
        N: common_vendor.o(($event) => common_vendor.isRef(show) ? show.value = false : show = false),
        O: common_vendor.p({
          show: common_vendor.unref(show),
          closeable: true,
          round: "10"
        }),
        P: common_vendor.f(common_vendor.unref(info).priceList, (item, index, i0) => {
          return common_vendor.e({
            a: item.isCurrent == 1
          }, item.isCurrent == 1 ? {} : {}, {
            b: common_vendor.t(item.startTime),
            c: common_vendor.t(item.endTime),
            d: common_vendor.t(item.electricityRate),
            e: common_vendor.t(item.serviceFeeRate),
            f: common_vendor.t(item.totalAmount),
            g: index
          });
        }),
        Q: common_vendor.o(($event) => common_vendor.isRef(showJf) ? showJf.value = false : showJf = false),
        R: common_vendor.p({
          show: common_vendor.unref(showJf),
          closeable: true,
          round: "10"
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-431a10b7"]]);
_sfc_main.__runtimeHooks = 1;
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/home/detail.js.map
