"use strict";
const common_vendor = require("../../../common/vendor.js");
if (!Array) {
  const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
  const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  const _easycom_u_loadmore2 = common_vendor.resolveComponent("u-loadmore");
  const _easycom_u_empty2 = common_vendor.resolveComponent("u-empty");
  const _easycom_u_subsection2 = common_vendor.resolveComponent("u-subsection");
  const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
  const _easycom_u__input2 = common_vendor.resolveComponent("u--input");
  const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
  (_easycom_u_navbar2 + _easycom_u_icon2 + _easycom_u_loadmore2 + _easycom_u_empty2 + _easycom_u_subsection2 + _easycom_u_popup2 + _easycom_u__input2 + _easycom_u_button2)();
}
const _easycom_u_navbar = () => "../../../node-modules/uview-plus/components/u-navbar/u-navbar.js";
const _easycom_u_icon = () => "../../../node-modules/uview-plus/components/u-icon/u-icon.js";
const _easycom_u_loadmore = () => "../../../node-modules/uview-plus/components/u-loadmore/u-loadmore.js";
const _easycom_u_empty = () => "../../../node-modules/uview-plus/components/u-empty/u-empty.js";
const _easycom_u_subsection = () => "../../../node-modules/uview-plus/components/u-subsection/u-subsection.js";
const _easycom_u_popup = () => "../../../node-modules/uview-plus/components/u-popup/u-popup.js";
const _easycom_u__input = () => "../../../node-modules/uview-plus/components/u--input/u--input.js";
const _easycom_u_button = () => "../../../node-modules/uview-plus/components/u-button/u-button.js";
if (!Math) {
  (_easycom_u_navbar + _easycom_u_icon + _easycom_u_loadmore + _easycom_u_empty + _easycom_u_subsection + _easycom_u_popup + _easycom_u__input + _easycom_u_button)();
}
const _sfc_main = {
  __name: "deviceList",
  setup(__props) {
    const { proxy } = common_vendor.getCurrentInstance();
    const instance = common_vendor.getCurrentInstance();
    const {
      device_type,
      device_online_status,
      device_busy_status,
      device_active_status
    } = proxy.$useDict("device_type", "device_online_status", "device_busy_status", "device_active_status");
    const dicts = common_vendor.reactive({
      device_type: [],
      online_status: [],
      busy_status: [],
      active_status: []
    });
    const netStatus = common_vendor.reactive({
      showPopMenu: false,
      selIdx: 0,
      selStatus: {},
      style: {
        marginTop: "240rpx"
      }
    });
    function openNetStatusMenu() {
      console.log("-------", "openNetStatusMenu");
      activeStatus.showPopMenu = false;
      searchMenu.showPopMenu = false;
      netStatus.showPopMenu = true;
    }
    function netStatusChange(index) {
      netStatus.selStatus = dicts.online_status[index];
      netStatus.selIdx = index;
      setTimeout(function() {
        netStatus.showPopMenu = false;
        data.curPage = 1;
        getList();
      }, 500);
    }
    const activeStatus = common_vendor.reactive({
      showPopMenu: false,
      selIdx: 0,
      selStatus: {},
      style: {
        marginTop: "240rpx"
      }
    });
    function openActiveStatusMenu() {
      console.log("-------", "openActiveStatusMenu");
      netStatus.showPopMenu = false;
      searchMenu.showPopMenu = false;
      activeStatus.showPopMenu = true;
    }
    function activeStatusChange(index) {
      activeStatus.selStatus = dicts.active_status[index];
      activeStatus.selIdx = index;
      setTimeout(function() {
        activeStatus.showPopMenu = false;
        data.curPage = 1;
        getList();
      }, 500);
    }
    const searchMenu = common_vendor.reactive({
      showPopMenu: false,
      selStatus: 0,
      style: {
        marginTop: "174rpx"
      },
      searchMenu_body_style: {
        height: "600rpx"
      },
      params: {
        mercName: void 0,
        deviceIdName: void 0,
        deviceType: void 0,
        busyState: void 0,
        activeState: void 0,
        no: void 0
      }
    });
    function openSearchMenu() {
      activeStatus.showPopMenu = false;
      netStatus.showPopMenu = false;
      searchMenu.showPopMenu = true;
    }
    function resetSearchMenu() {
      searchMenu.params.deviceIdName = void 0;
      searchMenu.params.deviceType = void 0;
      searchMenu.params.mercName = void 0;
      searchMenu.params.no = void 0;
    }
    function doSearch(o) {
      if (o == 0)
        resetSearchMenu();
      setTimeout(function() {
        searchMenu.showPopMenu = false;
        data.curPage = 1;
        getList();
      }, 500);
    }
    common_vendor.ref("");
    const data = common_vendor.reactive({
      reqUrls: {
        list: "/device/device-info/page"
      },
      curPage: 1,
      loadmoreStatus: "nomore",
      params: {
        page: {
          current: 1,
          size: 10,
          orders: [
            {
              asc: false,
              column: "create_time"
            }
          ]
        }
      },
      fullHeight: 0,
      screenHeight: 1920,
      // screenWidht:1080,
      dataList: [],
      total: 0,
      isRemember: []
    });
    common_vendor.onMounted(() => {
      dicts.device_type = [{ value: null, label: "全部" }].concat(device_type.value);
      dicts.online_status = [{ value: null, label: "全部" }].concat(device_online_status.value);
      dicts.active_status = [{ value: null, label: "全部" }].concat(device_active_status.value);
      dicts.busy_status = [{ value: null, label: "全部" }].concat(device_busy_status.value);
      netStatus.selStatus = dicts.online_status[0];
      activeStatus.selStatus = dicts.active_status[0];
      data.screenHeight = common_vendor.index.getSystemInfoSync().windowHeight;
      searchMenu.searchMenu_body_style.height = data.screenHeight - 90 + "px";
      getList();
      const query = common_vendor.index.createSelectorQuery().in(instance);
      query.select(".scrollview").boundingClientRect((r) => {
        common_vendor.index.getSystemInfo({
          success(res) {
            const model = res.model;
            const modelInclude = [
              "iPhone X",
              "iPhone XR",
              "iPhone XS",
              "iPhone XS MAX",
              "iPhone 12/13 mini",
              "iPhone 12/13 (Pro)",
              "iPhone 12/13 Pro Max",
              "iPhone 14 Pro Max"
            ];
            let safeDistance = modelInclude.includes(model);
            console.log(res.windowHeight, r.top);
            let h = 0;
            if (safeDistance) {
              h = res.windowHeight - r.top;
            } else {
              h = res.windowHeight - r.top;
            }
            data.fullHeight += h + "px";
          }
        });
      }).exec();
    });
    function scrolltolower() {
      if (data.loadmoreStatus == "nomore")
        return;
      data.curPage++;
      getList();
    }
    function getList() {
      return new Promise((resolve, reject) => {
        data.params.page.current = data.curPage;
        data.params.netState = netStatus.selStatus.value;
        data.params.activeState = activeStatus.selStatus.value;
        data.params.deviceIdName = searchMenu.params.deviceIdName;
        data.params.deviceType = searchMenu.params.deviceType;
        data.params.merc = searchMenu.params.mercName;
        data.params.no = searchMenu.params.no;
        if (data.curPage == 1) {
          data.dataList = [];
        }
        proxy.$request({
          url: data.reqUrls.list,
          data: data.params,
          method: "post"
        }).then((res) => {
          console.log("***", res);
          if (res.records) {
            data.dataList = data.dataList.concat(res.records);
          }
          data.total = res.total;
          if (res.records.length < 10) {
            data.loadmoreStatus = "nomore";
          } else {
            data.loadmoreStatus = "loadmore";
          }
          resolve(res);
        }).catch((err) => {
          reject(err);
        });
      });
    }
    function gotoDeviceDetail(o) {
      proxy.$tab.navigateTo(`/pages/xy_system/devices/deviceDetail?id=${o}`);
    }
    function rightClick() {
      console.log("点击了右侧");
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(rightClick),
        b: common_vendor.p({
          title: "设备列表",
          titleStyle: "color:#fff;fontSize:36rpx;",
          bgColor: "#2C6FF3",
          autoBack: true,
          leftIconColor: "#fff",
          placeholder: true
        }),
        c: common_vendor.p({
          name: "arrow-right",
          size: "14"
        }),
        d: common_vendor.t(netStatus.selStatus.label),
        e: common_vendor.o(openNetStatusMenu),
        f: common_vendor.p({
          name: "arrow-right",
          size: "14"
        }),
        g: common_vendor.t(activeStatus.selStatus.label),
        h: common_vendor.o(openActiveStatusMenu),
        i: common_vendor.p({
          name: "arrow-right",
          size: "14"
        }),
        j: common_vendor.o(openSearchMenu),
        k: common_vendor.t(data.total),
        l: data.dataList.length > 0
      }, data.dataList.length > 0 ? common_vendor.e({
        m: common_vendor.f(data.dataList, (item1, index1, i0) => {
          return common_vendor.e({
            a: item1.deviceName
          }, item1.deviceName ? {
            b: common_vendor.t(item1.deviceName),
            c: common_vendor.t(item1.deviceId)
          } : {
            d: common_vendor.t(item1.deviceId)
          }, {
            e: common_vendor.t(item1.deviceStatus.netState == "1" ? "在线" : "离线"),
            f: common_vendor.n(item1.deviceStatus.netState == 1 ? "online" : ""),
            g: common_vendor.t(item1.deviceStatus.lockStateL == "1" ? "未锁机" : "已锁机"),
            h: common_vendor.n(item1.deviceStatus.lockStateL == 1 ? "online" : ""),
            i: common_vendor.t(item1.mercName),
            j: common_vendor.t(item1.mercId),
            k: common_vendor.t(common_vendor.unref(proxy).$getDictByValue(dicts.device_type, item1.deviceType).label),
            l: common_vendor.t(item1.activeState == 1 ? "已激活" : "未激活"),
            m: common_vendor.t(item1.deviceSysinfo.appUpmVersion),
            n: common_vendor.t(item1.deviceStatus.updateTime),
            o: common_vendor.o(($event) => gotoDeviceDetail(item1.deviceId), item1.deviceId),
            p: item1.deviceId
          });
        }),
        n: data.dataList.length > 0
      }, data.dataList.length > 0 ? {
        o: common_vendor.p({
          status: data.loadmoreStatus
        })
      } : {}) : {
        p: common_vendor.p({
          mode: "data",
          text: "数据为空"
        })
      }, {
        q: common_vendor.o(scrolltolower),
        r: data.fullHeight,
        s: common_vendor.o(netStatusChange),
        t: common_vendor.p({
          list: dicts.online_status,
          keyName: "label",
          current: netStatus.selIdx
        }),
        v: common_vendor.p({
          show: netStatus.showPopMenu,
          duration: "0",
          customStyle: netStatus.style,
          round: 10,
          mode: "top",
          overlay: false
        }),
        w: common_vendor.o(activeStatusChange),
        x: common_vendor.p({
          list: dicts.active_status,
          keyName: "label",
          current: activeStatus.selIdx
        }),
        y: common_vendor.p({
          show: activeStatus.showPopMenu,
          duration: "0",
          customStyle: activeStatus.style,
          round: 10,
          mode: "top",
          overlay: false
        }),
        z: common_vendor.o(($event) => searchMenu.params.mercName = $event),
        A: common_vendor.p({
          size: "mini",
          placeholder: "请输入商户名称",
          border: "surround",
          modelValue: searchMenu.params.mercName
        }),
        B: common_vendor.o(($event) => searchMenu.params.deviceIdName = $event),
        C: common_vendor.p({
          placeholder: "请输入机器名称,编号",
          border: "surround",
          modelValue: searchMenu.params.deviceIdName
        }),
        D: common_vendor.o(($event) => searchMenu.params.no = $event),
        E: common_vendor.p({
          placeholder: "SN/资产编号/流量卡号",
          border: "surround",
          modelValue: searchMenu.params.no
        }),
        F: common_vendor.f(dicts.device_type, (item, index, i0) => {
          return {
            a: common_vendor.t(item.label),
            b: common_vendor.n(searchMenu.params.deviceType == item.value ? "tab-item tab-show" : "tab-item"),
            c: common_vendor.o(($event) => searchMenu.params.deviceType = item.value, item.value),
            d: item.value
          };
        }),
        G: common_vendor.f(dicts.busy_status, (item, index, i0) => {
          return {
            a: common_vendor.t(item.label),
            b: common_vendor.n(searchMenu.params.busyState == item.value ? "tab-item tab-show" : "tab-item"),
            c: common_vendor.o(($event) => searchMenu.params.busyState = item.value, item.value),
            d: item.value
          };
        }),
        H: common_vendor.f(dicts.active_status, (item, index, i0) => {
          return {
            a: common_vendor.t(item.label),
            b: common_vendor.n(searchMenu.params.activeState == item.value ? "tab-item tab-show" : "tab-item"),
            c: common_vendor.o(($event) => searchMenu.params.activeState = item.value, item.value),
            d: item.value
          };
        }),
        I: common_vendor.o(($event) => doSearch(0)),
        J: common_vendor.p({
          size: "normal",
          plain: true,
          text: "关闭"
        }),
        K: common_vendor.o(resetSearchMenu),
        L: common_vendor.p({
          size: "normal",
          type: "primary",
          plain: true,
          text: "重置"
        }),
        M: common_vendor.o(($event) => doSearch(1)),
        N: common_vendor.p({
          size: "normal",
          type: "primary",
          text: "查找"
        }),
        O: common_vendor.s(searchMenu.searchMenu_body_style),
        P: common_vendor.p({
          show: searchMenu.showPopMenu,
          duration: "0",
          customStyle: searchMenu.style,
          round: 10,
          mode: "right",
          duration: 300,
          overlay: false
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-89b27d87"], ["__file", "F:/兴元/开门柜项目/平台端管理系统小程序/src/pages/xy_system/devices/deviceList.vue"]]);
wx.createPage(MiniProgramPage);
