"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_button2 = common_vendor.resolveComponent("u-button");
  const _easycom_u_loadmore2 = common_vendor.resolveComponent("u-loadmore");
  const _easycom_u_empty2 = common_vendor.resolveComponent("u-empty");
  const _easycom_u__input2 = common_vendor.resolveComponent("u--input");
  const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
  (_easycom_u_navbar2 + _easycom_u_icon2 + _easycom_u_button2 + _easycom_u_loadmore2 + _easycom_u_empty2 + _easycom_u__input2 + _easycom_u_popup2)();
}
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_button = () => "../../../node-modules/uview-plus/components/u-button/u-button.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__input = () => "../../../node-modules/uview-plus/components/u--input/u--input.js";
const _easycom_u_popup = () => "../../../node-modules/uview-plus/components/u-popup/u-popup.js";
if (!Math) {
  (_easycom_u_navbar + _easycom_u_icon + _easycom_u_button + _easycom_u_loadmore + _easycom_u_empty + _easycom_u__input + _easycom_u_popup)();
}
const _sfc_main = {
  __name: "merc",
  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 searchMenu = common_vendor.reactive({
      showPopMenu: false,
      selStatus: 0,
      style: {
        marginTop: "174rpx"
      },
      searchMenu_body_style: {
        height: "600rpx"
      },
      params: {
        searchKey: void 0,
        contact: void 0,
        contactPhone: void 0,
        deviceId: void 0
      },
      reqUrls: {
        searchMerc: "/merc/be/merc/searchTreeList"
      },
      dataList: []
    });
    function openSearchMenu() {
      searchMenu.showPopMenu = true;
    }
    function resetSearchMenu() {
      searchMenu.params.searchKey = void 0;
      searchMenu.params.contact = void 0;
      searchMenu.params.contactPhone = void 0;
    }
    function doSearch(o) {
      if (o == 0)
        resetSearchMenu();
      setTimeout(function() {
        searchMenu.showPopMenu = false;
        data.curPage = 1;
        getList();
      }, 500);
    }
    const data = common_vendor.reactive({
      reqUrls: {
        list: "/merc/be/merc/page",
        token: "/merc/mini/adminToMerc",
        tree: "/sys/sys-code-configure/tree"
      },
      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
    });
    common_vendor.onMounted(() => {
      dicts.device_type = [{
        value: null,
        label: "全部"
      }].concat(device_type.value);
      dicts.online_status = [{
        value: null,
        label: "全部"
      }].concat(device_online_status.value);
      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(res2) {
            const model = res2.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(res2.windowHeight, r.top);
            let h = 0;
            if (safeDistance) {
              h = res2.windowHeight - r.top;
            } else {
              h = res2.windowHeight - r.top;
            }
            data.fullHeight += h + "px";
          }
        });
      }).exec();
    });
    function scrolltolower() {
      if (data.loadmoreStatus == "nomore")
        return;
      data.curPage++;
      getList();
    }
    function getList() {
      return new Promise((resolve2, reject2) => {
        data.params.page.current = data.curPage;
        data.params.searchKey = searchMenu.params.searchKey;
        data.params.contact = searchMenu.params.contact;
        data.params.contactPhone = searchMenu.params.contactPhone;
        if (data.curPage == 1) {
          data.dataList = [];
        }
        proxy.$request({
          url: data.reqUrls.list,
          data: data.params,
          method: "post"
        }).then((res2) => {
          console.log("***", res2);
          if (res2.records) {
            data.dataList = data.dataList.concat(res2.records);
          }
          data.total = res2.total;
          if (res2.records.length < 10) {
            data.loadmoreStatus = "nomore";
          } else {
            data.loadmoreStatus = "loadmore";
          }
          resolve2(res2);
        }).catch((err) => {
          reject2(err);
        });
      });
    }
    function doSearchMerc() {
      return new Promise((resolve2, reject2) => {
        proxy.$request({
          url: searchMenu.reqUrls.searchMerc,
          data: {
            searchKey: searchMenu.params.deviceId
          },
          method: "post"
        }).then((data2) => {
          searchMenu.dataList = data2;
          console.log("机器号查找商户", searchMenu.dataList);
          resolve2(res);
        }).catch((err) => {
          reject2(err);
        });
      });
    }
    function gotoMerc(merc) {
      proxy.$request({
        url: data.reqUrls.token,
        data: {
          mercId: merc.id
        },
        method: "post"
      }).then((data2) => {
        console.log("token", data2);
        common_vendor.wx$1.navigateToMiniProgram({
          appId: "wxde6edfb4b2c1e7db",
          path: "pages/login",
          extraData: {
            mercId: data2.mercId,
            mercName: data2.mercName,
            token: data2.mercSatoken,
            type: 1
          },
          envVersion: "trial",
          //跳转体验版
          success(res2) {
            console.log(res2);
          }
        });
        resolve(res);
      }).catch((err) => {
        reject(err);
      });
    }
    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.t(data.total),
        d: common_vendor.p({
          name: "arrow-right",
          size: "14"
        }),
        e: common_vendor.o(openSearchMenu),
        f: data.dataList.length > 0
      }, data.dataList.length > 0 ? common_vendor.e({
        g: common_vendor.f(data.dataList, (item1, index1, i0) => {
          return common_vendor.e({
            a: item1.name
          }, item1.name ? {
            b: common_vendor.t(item1.name),
            c: common_vendor.t(item1.mercCode)
          } : {
            d: common_vendor.t(item1.mercCode)
          }, {
            e: common_vendor.t(item1.parentName),
            f: common_vendor.t(item1.parentId),
            g: common_vendor.t(item1.loginName),
            h: common_vendor.t(item1.contact),
            i: common_vendor.t(item1.contactPhone),
            j: common_vendor.t(item1.mercType),
            k: common_vendor.t(item1.createTime),
            l: common_vendor.o(($event) => gotoMerc(item1), item1.deviceId),
            m: "c90a5174-2-" + i0,
            n: item1.deviceId
          });
        }),
        h: common_vendor.p({
          size: "mini",
          type: "primary",
          text: "管理"
        }),
        i: data.dataList.length > 0
      }, data.dataList.length > 0 ? {
        j: common_vendor.p({
          status: data.loadmoreStatus
        })
      } : {}) : {
        k: common_vendor.p({
          mode: "data",
          text: "数据为空"
        })
      }, {
        l: common_vendor.o(scrolltolower),
        m: data.fullHeight,
        n: common_vendor.o(($event) => searchMenu.params.searchKey = $event),
        o: common_vendor.p({
          placeholder: "商户名称/编号",
          border: "surround",
          modelValue: searchMenu.params.searchKey
        }),
        p: common_vendor.o(($event) => searchMenu.params.contact = $event),
        q: common_vendor.p({
          placeholder: "联系人",
          border: "surround",
          modelValue: searchMenu.params.contact
        }),
        r: common_vendor.o(($event) => searchMenu.params.contactPhone = $event),
        s: common_vendor.p({
          placeholder: "联系电话",
          border: "surround",
          modelValue: searchMenu.params.contactPhone
        }),
        t: common_vendor.o(($event) => searchMenu.params.deviceId = $event),
        v: common_vendor.p({
          placeholder: "机器ID号",
          border: "surround",
          modelValue: searchMenu.params.deviceId
        }),
        w: common_vendor.o(($event) => doSearchMerc()),
        x: common_vendor.p({
          size: "normal",
          plain: true,
          text: "查找"
        }),
        y: common_vendor.f(searchMenu.dataList, (item2, index1, i0) => {
          return {
            a: common_vendor.t(item2.name),
            b: common_vendor.t(item2.mercCode),
            c: common_vendor.o(($event) => searchMenu.params.searchKey = item2.name, item2.id),
            d: item2.id
          };
        }),
        z: common_vendor.o(($event) => doSearch(0)),
        A: common_vendor.p({
          size: "normal",
          plain: true,
          text: "关闭"
        }),
        B: common_vendor.o(resetSearchMenu),
        C: common_vendor.p({
          size: "normal",
          type: "primary",
          plain: true,
          text: "重置"
        }),
        D: common_vendor.o(($event) => doSearch(1)),
        E: common_vendor.p({
          size: "normal",
          type: "primary",
          text: "查找"
        }),
        F: common_vendor.s(searchMenu.searchMenu_body_style),
        G: 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-c90a5174"], ["__file", "F:/兴元/开门柜项目/平台端管理系统小程序/src/pages/xy_merc_be/mercManager/merc.vue"]]);
wx.createPage(MiniProgramPage);
