"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const api_index = require("../../api/index.js");
const utils_fun = require("../../utils/fun.js");
const store_index = require("../../store/index.js");
if (!Array) {
  const _easycom_wd_datetime_picker2 = common_vendor.resolveComponent("wd-datetime-picker");
  const _easycom_uni_dateformat2 = common_vendor.resolveComponent("uni-dateformat");
  const _easycom_z_paging2 = common_vendor.resolveComponent("z-paging");
  (_easycom_wd_datetime_picker2 + _easycom_uni_dateformat2 + _easycom_z_paging2)();
}
const _easycom_wd_datetime_picker = () => "../../uni_modules/wot-design-uni/components/wd-datetime-picker/wd-datetime-picker.js";
const _easycom_uni_dateformat = () => "../../uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.js";
const _easycom_z_paging = () => "../../uni_modules/z-paging/components/z-paging/z-paging.js";
if (!Math) {
  (_easycom_wd_datetime_picker + _easycom_uni_dateformat + _easycom_z_paging)();
}
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "team",
  setup(__props) {
    const paging = common_vendor.ref(null);
    const dataList = common_vendor.ref([]);
    const count = common_vendor.ref({});
    const showLoading = common_vendor.ref(true);
    const timeTrue = common_vendor.ref(false);
    const store = store_index.Store();
    const userInfo = common_vendor.computed(
      () => store.userInfo || {
        inviteCode: "",
        nickname: "",
        mobile: "",
        avatar: "",
        paywallet: {
          balance: 0
        }
      }
    );
    common_vendor.onShow(() => {
    });
    common_vendor.onLoad(() => {
      timeTrue.value = isTimestampInCurrentMonth((/* @__PURE__ */ new Date()).getTime());
      timeCount();
    });
    function timeCount() {
      if (userInfo.value.userRights && userInfo.value.userRights.rightsLevel == 3) {
        api_index.api.getTeamMonthlyPerformanceAward({ month: utils_fun.timeFormat(value.value, "yyyy-MM-ddThh:mm:ss") }).then((res) => {
          count.value = res;
        });
      }
    }
    const value = common_vendor.ref((/* @__PURE__ */ new Date()).getTime());
    common_vendor.ref({});
    const queryList = (pageNo, pageSize) => {
      api_index.api.usersGetInfoTeam({ pageNo, pageSize }).then((res) => {
        paging.value.complete(res.list);
        timeCount();
      }).catch((res) => {
        paging.value.complete(false);
      });
    };
    const confirm = (e) => {
      timeTrue.value = isTimestampInCurrentMonth(e.value);
      paging.value.reload();
    };
    function isTimestampInCurrentMonth(timestamp) {
      const ts = timestamp < 1e12 ? timestamp * 1e3 : timestamp;
      const date = new Date(ts);
      const now = /* @__PURE__ */ new Date();
      const currentYear = now.getFullYear();
      const currentMonth = now.getMonth();
      const targetYear = date.getFullYear();
      const targetMonth = date.getMonth();
      return currentYear === targetYear && currentMonth === targetMonth;
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: userInfo.value.userRights && userInfo.value.userRights.rightsLevel == 3
      }, userInfo.value.userRights && userInfo.value.userRights.rightsLevel == 3 ? {
        b: common_assets._imports_0$5,
        c: common_assets._imports_1$3,
        d: common_vendor.o(confirm),
        e: common_vendor.o(($event) => showLoading.value = true),
        f: common_vendor.o(($event) => showLoading.value = false),
        g: common_vendor.o(($event) => value.value = $event),
        h: common_vendor.p({
          type: "year-month",
          modelValue: value.value
        }),
        i: common_vendor.t(count.value.investmentAmount),
        j: common_vendor.t(timeTrue.value ? "可" : "已"),
        k: common_vendor.t(count.value.expectedReturn),
        l: common_vendor.t(count.value.totalExpectedReturn)
      } : {}, {
        m: userInfo.value.puser
      }, userInfo.value.puser ? {
        n: common_vendor.t(userInfo.value.puser ? `${userInfo.value.puser.nickname} ${userInfo.value.puser.mobile}` : "无")
      } : {}, {
        o: common_vendor.f(dataList.value, (item, index, i0) => {
          return common_vendor.e({
            a: item.avatar,
            b: common_vendor.t(item.nickname || "微信用户"),
            c: common_vendor.t(item.mobile),
            d: "dc51e287-2-" + i0 + ",dc51e287-0",
            e: common_vendor.p({
              format: "yyyy-MM-dd hh:mm:ss",
              date: item.createTime
            }),
            f: item.userRights
          }, item.userRights ? {
            g: common_vendor.t(item.userRights.rights.rightsName)
          } : {}, {
            h: index
          });
        }),
        p: common_vendor.sr(paging, "dc51e287-0", {
          "k": "paging"
        }),
        q: common_vendor.o(queryList),
        r: common_vendor.o(($event) => dataList.value = $event),
        s: common_vendor.p({
          ["refresher-enabled"]: showLoading.value,
          modelValue: dataList.value
        })
      });
    };
  }
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-dc51e287"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/team/team.js.map
