"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_api = require("../../utils/api.js");
if (!Array) {
  const _easycom_wd_icon2 = common_vendor.resolveComponent("wd-icon");
  const _easycom_wd_status_tip2 = common_vendor.resolveComponent("wd-status-tip");
  (_easycom_wd_icon2 + _easycom_wd_status_tip2)();
}
const _easycom_wd_icon = () => "../../uni_modules/wot-design-uni/components/wd-icon/wd-icon.js";
const _easycom_wd_status_tip = () => "../../uni_modules/wot-design-uni/components/wd-status-tip/wd-status-tip.js";
if (!Math) {
  (_easycom_wd_icon + _easycom_wd_status_tip)();
}
const _sfc_main = {
  __name: "commonPeople",
  setup(__props) {
    const userInfo = common_vendor.ref();
    const pageSize = common_vendor.ref(8);
    const currentPage = common_vendor.ref(1);
    const total = common_vendor.ref(0);
    const dataList = common_vendor.ref([]);
    common_vendor.onLoad(() => {
      userInfo.value = common_vendor.index.getStorageSync("carUserInfo");
      console.log(userInfo.value);
      getCommonData();
    });
    common_vendor.onReachBottom(() => {
      if (dataList.value.length < total.value) {
        currentPage.value++;
        getCommonData();
      } else {
        common_vendor.index.showToast({
          title: "没有更多数据了",
          icon: "none"
        });
      }
    });
    const getCommonData = async () => {
      let data = {
        page: currentPage.value,
        rows: pageSize.value,
        // mobile: uni.getStorageSync('carUserInfo').mobile
        uid: common_vendor.index.getStorageSync("carUserInfo").id
      };
      const res = await utils_api.myRequest({
        url: "/ctUserlist.action",
        data
      });
      console.log(res);
      dataList.value = [...dataList.value, ...res.rows];
      total.value = res.total;
    };
    const handleAdd = () => {
      common_vendor.index.navigateTo({
        url: "/pages/handlePeople/handlePeople"
      });
    };
    const handleEdit = (item) => {
      let info = encodeURIComponent(JSON.stringify(item));
      common_vendor.index.navigateTo({
        url: `/pages/handlePeople/handlePeople?info=${info}`
      });
    };
    const handleDelete = (item) => {
      common_vendor.index.showModal({
        title: "提示",
        content: `确定删除${item.username}吗？`,
        success: (res) => {
          if (res.confirm) {
            deleteReq(item.id);
          }
        }
      });
    };
    const deleteReq = async (id) => {
      let data = {
        id
      };
      const res = await utils_api.myRequest({
        url: "/ctUserdel.action",
        data
      });
      if (res.code == 200) {
        common_vendor.index.showToast({
          title: res.message,
          icon: "success"
        });
        setTimeout(() => {
          currentPage.value = 1;
          dataList.value = [];
          total.value = 0;
          getCommonData();
        }, 1500);
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(handleAdd),
        b: common_vendor.f(dataList.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.username),
            b: common_vendor.t(item.sfzh),
            c: common_vendor.t(item.mobile),
            d: common_vendor.t(item.cardNumber),
            e: common_vendor.o(($event) => handleDelete(item), item.id),
            f: "357c93f1-0-" + i0,
            g: common_vendor.o(($event) => handleEdit(item), item.id),
            h: "357c93f1-1-" + i0,
            i: item.id
          };
        }),
        c: common_vendor.p({
          name: "delete",
          color: "#DC2626",
          size: "20"
        }),
        d: common_vendor.p({
          name: "edit-1",
          color: "#ABA6A6",
          size: "20"
        }),
        e: !dataList.value.length
      }, !dataList.value.length ? {
        f: common_vendor.p({
          image: "content",
          tip: "暂无数据"
        })
      } : {});
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-357c93f1"], ["__file", "D:/创海项目/CH2025/约车小程序/yueche_app/pages/commonPeople/commonPeople.vue"]]);
wx.createPage(MiniProgramPage);
