"use strict";
const common_vendor = require("../../../common/vendor.js");
const components_request = require("../../../components/request.js");
const components_formatDate = require("../../../components/formatDate.js");
const components_DifferenceArray = require("../../../components/DifferenceArray.js");
const Recompose = () => "./recompose/recompose2.js";
const _sfc_main = {
  data() {
    return {
      pkList: [],
      userinfo: {},
      page: 0,
      createModule: null,
      parentMessage: null,
      triggered: false,
      pickerArray: [],
      index: 0,
      topPinnedPersondata: {},
      Topdate: 0,
      popupOutdata: {},
      popupExpurgatedata: {}
    };
  },
  onLoad() {
    common_vendor.index.getStorage({
      key: "userinfo",
      success: (res) => {
        this.userinfo = res.data;
        this.getpkList();
      }
    });
  },
  mounted() {
    this.createModule = this.$refs.createModule;
  },
  methods: {
    // 刷新
    onRefresherRefresh() {
      this.page = 0;
      this.pkList = [];
      this.getpkList();
      this.triggered = true;
    },
    // 下拉加载
    onScrollToLower() {
      this.page++;
      this.getpkList();
    },
    // 返回
    onBack() {
      common_vendor.index.navigateBack({
        delta: 1
      });
    },
    //时间格式化
    formatDate: components_formatDate.formatDate,
    // 获取pk列表
    getpkList() {
      components_request.request({
        url: "user/queryMyAllPkData",
        method: "POST",
        data: {
          userId: this.userinfo.id,
          page: this.page,
          size: 10
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.pkList.push(...res.data);
          this.triggered = false;
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/minecomponents/pkInformation.vue:217", res.msg);
        }
      });
    },
    // 打开修改窗口
    onRecompose(item) {
      this.parentMessage = item;
      this.createModule.open();
    },
    // 置顶
    onTop(item) {
      this.pickerArray = components_DifferenceArray.DifferenceArray(item.pkTime);
      this.$refs.popup.open("center");
      this.topPinnedPersondata = item;
    },
    bindPickerChange(e) {
      this.index = e.detail.value;
    },
    closePopup() {
      this.$refs.popup.close();
      this.index = 0;
      this.pickerArray = [];
      this.topPinnedPersondata = {};
    },
    onTopConfirm() {
      this.Topdate = Math.ceil(Date.now() / 1e3 + Number(this.pickerArray[this.index]) * 3600);
      components_request.request({
        url: "user/pinToTop",
        method: "POST",
        data: {
          articleId: this.topPinnedPersondata.id,
          pinExpireTime: this.Topdate
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.onRefresherRefresh();
          common_vendor.index.showToast({
            title: res.data,
            icon: "none",
            duration: 3e3
          });
          this.closePopup();
        } else {
          common_vendor.index.showToast({
            title: res.msg,
            icon: "none",
            duration: 3e3
          });
        }
      });
    },
    //取消置顶
    onOutTop(item) {
      this.$refs.popupOut.open("center");
      this.popupOutdata = item;
    },
    // 确认取消置顶
    onOutTopConfirm() {
      components_request.request({
        url: "user/cancelPin",
        method: "POST",
        data: {
          articleId: this.popupOutdata.id
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.closePopupOut();
          this.onRefresherRefresh();
          common_vendor.index.showToast({
            title: res.data,
            icon: "none",
            duration: 3e3
          });
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/minecomponents/pkInformation.vue:293", res.msg);
        }
      });
    },
    // 取消取消置顶
    closePopupOut() {
      this.$refs.popupOut.close();
      this.popupOutdata = {};
    },
    // 删除pk
    onExpurgate(item) {
      this.$refs.popupExpurgate.open("center");
      this.popupExpurgatedata = item;
    },
    // 确认删除pk
    onExpurgateConfirm() {
      components_request.request({
        url: "pk/deletePkDataWithId",
        method: "POST",
        data: {
          id: this.popupExpurgatedata.id
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.onRefresherRefresh();
          this.closePopupExpurgate();
          common_vendor.index.showToast({
            title: res.msg,
            icon: "none",
            duration: 2e3
          });
        } else {
          common_vendor.index.showToast({
            title: res.msg,
            icon: "none",
            duration: 2e3
          });
        }
      });
    },
    // 关闭删除弹窗
    closePopupExpurgate() {
      this.$refs.popupExpurgate.close();
      this.popupExpurgatedata = {};
    }
    //
  },
  components: {
    Recompose
  }
};
if (!Array) {
  const _component_uni_card = common_vendor.resolveComponent("uni-card");
  const _component_Recompose = common_vendor.resolveComponent("Recompose");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_component_uni_card + _component_Recompose + _easycom_uni_popup2)();
}
const _easycom_uni_popup = () => "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  _easycom_uni_popup();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.o$1((...args) => $options.onBack && $options.onBack(...args)),
    b: $data.pkList.length !== 0
  }, $data.pkList.length !== 0 ? {
    c: common_vendor.f($data.pkList, (item, index, i0) => {
      return common_vendor.e({
        a: item.anchorIcon,
        b: common_vendor.t(item.anchorId),
        c: item.sex === "2"
      }, item.sex === "2" ? {} : {}, {
        d: common_vendor.t(item.sex === "1" ? "男" : "女"),
        e: item.sex === "1" ? 1 : "",
        f: item.sex === "2" ? 1 : "",
        g: common_vendor.t(item.country),
        h: common_vendor.t(item.coin),
        i: common_vendor.t($options.formatDate(item.pkTime)),
        j: item.inviteStatus === 0
      }, item.inviteStatus === 0 ? common_vendor.e({
        k: item.isPin === false
      }, item.isPin === false ? {
        l: common_vendor.o$1(($event) => $options.onTop(item), index)
      } : {}, {
        m: item.isPin === true
      }, item.isPin === true ? {
        n: common_vendor.o$1(($event) => $options.onOutTop(item), index)
      } : {}, {
        o: common_vendor.o$1(($event) => $options.onRecompose(item), index),
        p: common_vendor.o$1(($event) => $options.onExpurgate(item), index)
      }) : {}, {
        q: index,
        r: "36b7ee78-0-" + i0
      });
    }),
    d: common_vendor.o$1((...args) => $options.onRefresherRefresh && $options.onRefresherRefresh(...args)),
    e: common_vendor.o$1((...args) => $options.onScrollToLower && $options.onScrollToLower(...args)),
    f: $data.triggered
  } : {}, {
    g: $data.pkList.length === 0
  }, $data.pkList.length === 0 ? {} : {}, {
    h: common_vendor.sr("createModule", "36b7ee78-1"),
    i: common_vendor.o$1($options.onRefresherRefresh),
    j: common_vendor.p({
      message: $data.parentMessage
    }),
    k: common_vendor.t($data.pickerArray[$data.index]),
    l: $data.pickerArray,
    m: $data.index,
    n: common_vendor.o$1((...args) => $options.bindPickerChange && $options.bindPickerChange(...args)),
    o: common_vendor.o$1((...args) => $options.onTopConfirm && $options.onTopConfirm(...args)),
    p: common_vendor.o$1((...args) => $options.closePopup && $options.closePopup(...args)),
    q: common_vendor.sr("popup", "36b7ee78-2"),
    r: common_vendor.p({
      type: "center",
      ["border-radius"]: "10px 10px 0 0"
    }),
    s: common_vendor.o$1((...args) => $options.onOutTopConfirm && $options.onOutTopConfirm(...args)),
    t: common_vendor.o$1((...args) => $options.closePopupOut && $options.closePopupOut(...args)),
    v: common_vendor.sr("popupOut", "36b7ee78-3"),
    w: common_vendor.p({
      type: "center",
      ["border-radius"]: "10px 10px 0 0"
    }),
    x: common_vendor.o$1((...args) => $options.onExpurgateConfirm && $options.onExpurgateConfirm(...args)),
    y: common_vendor.o$1((...args) => $options.closePopupExpurgate && $options.closePopupExpurgate(...args)),
    z: common_vendor.sr("popupExpurgate", "36b7ee78-4"),
    A: common_vendor.p({
      type: "center",
      ["border-radius"]: "10px 10px 0 0"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-36b7ee78"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/Mine/minecomponents/pkInformation.js.map
