"use strict";
const common_vendor = require("../../common/vendor.js");
const sheep_index = require("../../sheep/index.js");
const sheep_api_trade_brokerage = require("../../sheep/api/trade/brokerage.js");
require("../../sheep/api/index.js");
require("../../sheep/api/distri/score.js");
require("../../sheep/request/index.js");
require("../../sheep/config/index.js");
require("../../sheep/store/index.js");
require("../../sheep/store/app.js");
require("../../sheep/api/promotion/diy.js");
require("../../sheep/platform/index.js");
require("../../sheep/platform/provider/wechat/index.js");
require("../../sheep/platform/provider/wechat/miniProgram.js");
require("../../sheep/api/member/auth.js");
require("../../sheep/api/member/social.js");
require("../../sheep/api/member/user.js");
require("../../sheep/platform/provider/apple/index.js");
require("../../sheep/platform/share.js");
require("../../sheep/router/index.js");
require("../../sheep/hooks/useModal.js");
require("../../sheep/helper/index.js");
require("../../sheep/helper/test.js");
require("../../sheep/helper/digit.js");
require("../../sheep/api/member/signin.js");
require("../../sheep/helper/throttle.js");
require("../../sheep/url/index.js");
require("../../sheep/platform/pay.js");
require("../../sheep/api/pay/order.js");
require("../../sheep/store/user.js");
require("../../sheep/store/cart.js");
require("../../sheep/api/trade/cart.js");
require("../../sheep/api/pay/wallet.js");
require("../../sheep/api/trade/order.js");
require("../../sheep/api/promotion/coupon.js");
require("../../sheep/store/sys.js");
require("../../sheep/store/modal.js");
require("../../sheep/api/distri/share.js");
require("../../sheep/api/distri/team.js");
require("../../sheep/api/infra/file.js");
require("../../sheep/api/member/address.js");
require("../../sheep/api/member/point.js");
require("../../sheep/api/migration/app.js");
require("../../sheep/api/migration/chat.js");
require("../../sheep/api/migration/index.js");
require("../../sheep/api/migration/third.js");
require("../../sheep/api/pay/channel.js");
require("../../sheep/api/product/category.js");
require("../../sheep/api/product/comment.js");
require("../../sheep/api/product/favorite.js");
require("../../sheep/api/product/history.js");
require("../../sheep/api/product/spu.js");
require("../../sheep/api/promotion/activity.js");
require("../../sheep/api/promotion/article.js");
require("../../sheep/api/promotion/bargain.js");
require("../../sheep/api/promotion/combination.js");
require("../../sheep/api/promotion/rewardActivity.js");
require("../../sheep/api/promotion/seckill.js");
require("../../sheep/api/system/area.js");
require("../../sheep/api/system/voice.js");
require("../../sheep/api/trade/afterSale.js");
require("../../sheep/api/trade/config.js");
require("../../sheep/api/trade/delivery.js");
require("../../sheep/config/zIndex.js");
if (!Array) {
  const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  _easycom_s_layout2();
}
const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
if (!Math) {
  _easycom_s_layout();
}
const _sfc_main = {
  __name: "team",
  setup(__props) {
    common_vendor.useCssVars((_ctx) => ({
      "768616fe": common_vendor.unref(headerBg)
    }));
    sheep_index.sheep.$platform.device.statusBarHeight * 2;
    common_vendor.computed(() => sheep_index.sheep.$store("user").userInfo);
    const headerBg = sheep_index.sheep.$url.css("/static/img/shop/user/withdraw_bg.png");
    common_vendor.onPageScroll((e) => {
      state.scrollTop = e.scrollTop <= 100;
    });
    let sort = common_vendor.ref();
    const state = common_vendor.reactive({
      summary: {},
      pagination: {
        pageNo: 1,
        pageSize: 8,
        list: [],
        total: 0
      },
      loadStatus: "",
      // ↓ 新 ui 逻辑
      level: 1,
      nickname: common_vendor.ref(""),
      sortKey: "",
      isAsc: ""
    });
    function submitForm() {
      state.pagination.list = [];
      getTeamList();
    }
    async function getTeamList() {
      state.loadStatus = "loading";
      let { code, data } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserChildSummaryPage({
        pageNo: state.pagination.pageNo,
        pageSize: state.pagination.pageSize,
        level: state.level,
        "sortingField.order": state.isAsc,
        "sortingField.field": state.sortKey,
        nickname: state.nickname
      });
      if (code !== 0) {
        return;
      }
      state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
      state.pagination.total = data.total;
      state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
    }
    function setType(e) {
      state.pagination.list = [];
      state.level = e + "";
      getTeamList();
    }
    function setSort(sortKey, isAsc) {
      state.pagination.list = [];
      sort = sortKey + isAsc.toUpperCase();
      state.isAsc = isAsc;
      state.sortKey = sortKey;
      getTeamList();
    }
    common_vendor.onLoad(async () => {
      await getTeamList();
      let { data } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserSummary();
      state.summary = data;
    });
    function loadMore() {
      if (state.loadStatus === "noMore") {
        return;
      }
      state.pagination.pageNo++;
      getTeamList();
    }
    common_vendor.onReachBottom(() => {
      loadMore();
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.t(state.summary.firstBrokerageUserCount + state.summary.secondBrokerageUserCount || 0),
        b: common_vendor.t(state.summary.firstBrokerageUserCount || 0),
        c: common_vendor.n(state.level == 1 ? "item on" : "item"),
        d: common_vendor.o(($event) => setType(1)),
        e: common_vendor.t(state.summary.secondBrokerageUserCount || 0),
        f: common_vendor.n(state.level == 2 ? "item on" : "item"),
        g: common_vendor.o(($event) => setType(2)),
        h: common_vendor.o(submitForm),
        i: state.nickname,
        j: common_vendor.o(($event) => state.nickname = $event.detail.value),
        k: common_vendor.o(submitForm),
        l: common_vendor.unref(sort) === "userCountDESC"
      }, common_vendor.unref(sort) === "userCountDESC" ? {
        m: common_vendor.o(($event) => setSort("userCount", "asc"))
      } : common_vendor.unref(sort) === "userCountASC" ? {
        o: common_vendor.o(($event) => setSort("userCount", "desc"))
      } : {
        p: common_vendor.o(($event) => setSort("userCount", "desc"))
      }, {
        n: common_vendor.unref(sort) === "userCountASC",
        q: common_vendor.unref(sort) === "priceDESC"
      }, common_vendor.unref(sort) === "priceDESC" ? {
        r: common_vendor.o(($event) => setSort("price", "asc"))
      } : common_vendor.unref(sort) === "priceASC" ? {
        t: common_vendor.o(($event) => setSort("price", "desc"))
      } : {
        v: common_vendor.o(($event) => setSort("price", "desc"))
      }, {
        s: common_vendor.unref(sort) === "priceASC",
        w: common_vendor.unref(sort) === "orderCountDESC"
      }, common_vendor.unref(sort) === "orderCountDESC" ? {
        x: common_vendor.o(($event) => setSort("orderCount", "asc"))
      } : common_vendor.unref(sort) === "orderCountASC" ? {
        z: common_vendor.o(($event) => setSort("orderCount", "desc"))
      } : {
        A: common_vendor.o(($event) => setSort("orderCount", "desc"))
      }, {
        y: common_vendor.unref(sort) === "orderCountASC",
        B: common_vendor.f(state.pagination.list, (item, index, i0) => {
          return {
            a: item.avatar,
            b: common_vendor.t(item.nickname),
            c: common_vendor.t(common_vendor.unref(sheep_index.sheep).$helper.timeFormat(item.brokerageTime, "yyyy-mm-dd hh:MM:ss")),
            d: common_vendor.t(item.brokerageUserCount || 0),
            e: common_vendor.t(item.orderCount || 0),
            f: common_vendor.t(item.brokeragePrice || 0),
            g: index
          };
        }),
        C: state.pagination.list.length === 0
      }, state.pagination.list.length === 0 ? {} : {}, {
        D: common_vendor.n(state.scrollTop ? "team-wrap" : ""),
        E: common_vendor.s(_ctx.__cssVars()),
        F: common_vendor.p({
          title: "我的团队",
          navbar: "inner"
        })
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-42603af6"], ["__file", "D:/zx/mall-front-app/pages/commission/team.vue"]]);
_sfc_main.__runtimeHooks = 1;
wx.createPage(MiniProgramPage);
