"use strict";
const common_vendor = require("../../common/vendor.js");
const components_request = require("../../components/request.js");
const components_formatDate = require("../../components/formatDate.js");
const _sfc_main = {
  data() {
    return {
      customData: {},
      SenderData: {},
      ReceiverData: {},
      PkIDInfodata: {},
      id: ""
    };
  },
  onLoad(options) {
    common_vendor.index.getStorage({
      key: "userinfo",
      success: (res) => {
        this.id = res.data.id;
      }
    });
    this.customData = JSON.parse(options.customData);
    setTimeout(() => {
      this.getPkIDInfo();
      this.getPkyourInfo();
      this.getPkmineInfo();
    }, 1e3);
  },
  onShareAppMessage(res) {
    if (res.from === "menu") {
      return {
        title: "分享",
        path: `${getCurrentPages()[getCurrentPages().length - 1].route}?customData=${JSON.stringify(this.customData)}`
      };
    }
  },
  methods: {
    //根据当前消息ID查询pk信息
    async getPkIDInfo() {
      await components_request.request({
        url: "pk/singleRecord",
        method: "POST",
        data: {
          id: this.customData.id
        },
        userInfo: true
      }).then((res) => {
        common_vendor.index.__f__("log", "at pages/PKMessageprocessing/PKMessageprocessing.vue:227", res.data);
        this.PkIDInfodata = res.data;
      });
    },
    //发布者
    async getPkyourInfo() {
      await components_request.request({
        url: "pk/pkInfoDetail",
        method: "POST",
        data: {
          id: this.customData.pkIdA,
          userId: this.id,
          from: 2
        },
        userInfo: false
      }).then((res) => {
        common_vendor.index.__f__("log", "at pages/PKMessageprocessing/PKMessageprocessing.vue:243", res);
        if (res.code === 200) {
          common_vendor.index.__f__("log", "at pages/PKMessageprocessing/PKMessageprocessing.vue:245", res.data);
          this.SenderData = res.data;
        } else {
          common_vendor.wx$1.showToast({
            title: "获取发布者信息失败",
            icon: "none",
            duration: 2e3
          });
        }
      });
    },
    //被邀请者
    async getPkmineInfo() {
      await components_request.request({
        url: "pk/pkInfoDetail",
        method: "POST",
        data: {
          id: this.customData.pkIdB,
          userId: this.id,
          from: 2
        },
        userInfo: false
      }).then((res) => {
        if (res.code === 200) {
          common_vendor.index.__f__("log", "at pages/PKMessageprocessing/PKMessageprocessing.vue:269", res.data);
          this.ReceiverData = res.data;
        } else {
          common_vendor.wx$1.showToast({
            title: "获取被邀请者信息失败",
            icon: "none",
            duration: 2e3
          });
        }
      });
    },
    //返回上一页
    goBack() {
      common_vendor.wx$1.navigateBack({
        delta: 1
      });
    },
    formatDate: components_formatDate.formatDate,
    //接受邀请提示
    AcceptHint() {
      this.$refs.popups.open("center");
    },
    closeHint() {
      this.$refs.popups.close();
    },
    //拒绝邀请提示
    RefuseHint() {
      this.$refs.Refusepopup.open("center");
    },
    RefuseHintcloseHint() {
      this.$refs.Refusepopup.close();
    },
    //操作
    async operation(status) {
      await components_request.request({
        url: "pk/updatePkStatus",
        method: "POST",
        data: {
          id: this.customData.id,
          pkStatus: status
        },
        userInfo: true
      }).then((res) => {
        const Hinttext = status === 1 ? "接受邀请成功" : "拒绝邀请成功";
        if (res.code === 200) {
          this.getPkIDInfo();
          this.$refs.popups.close();
          this.$refs.Refusepopup.close();
          common_vendor.wx$1.showToast({
            title: Hinttext,
            icon: "success",
            duration: 2e3
          });
          common_vendor.wx$1.navigateBack({
            delta: 1
          });
        } else {
          common_vendor.wx$1.showToast({
            title: "操作失败",
            icon: "none",
            duration: 2e3
          });
        }
      });
    }
  }
};
if (!Array) {
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  _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((...args) => $options.goBack && $options.goBack(...args)),
    b: $data.SenderData.anchorIcon,
    c: common_vendor.t($data.SenderData.anchorId),
    d: $data.SenderData.sex === "1"
  }, $data.SenderData.sex === "1" ? {
    e: common_vendor.t($data.SenderData.sex == 1 ? "男" : "女")
  } : {
    f: common_vendor.t($data.SenderData.sex == 1 ? "男" : "女")
  }, {
    g: common_vendor.t($data.SenderData.country),
    h: common_vendor.t($options.formatDate($data.SenderData.pkTime)),
    i: common_vendor.t($data.SenderData.coin),
    j: common_vendor.t($data.SenderData.pkNumber),
    k: $data.ReceiverData.anchorIcon,
    l: common_vendor.t($data.ReceiverData.anchorId),
    m: $data.ReceiverData.sex === "1"
  }, $data.ReceiverData.sex === "1" ? {
    n: common_vendor.t($data.ReceiverData.sex == 1 ? "男" : "女")
  } : {
    o: common_vendor.t($data.ReceiverData.sex == 1 ? "男" : "女")
  }, {
    p: common_vendor.t($data.ReceiverData.country),
    q: common_vendor.t($options.formatDate($data.ReceiverData.pkTime)),
    r: common_vendor.t($data.ReceiverData.coin),
    s: common_vendor.t($data.ReceiverData.pkNumber),
    t: $data.PkIDInfodata.pkStatus === 0 && $data.ReceiverData.senderId !== $data.id
  }, $data.PkIDInfodata.pkStatus === 0 && $data.ReceiverData.senderId !== $data.id ? {
    v: common_vendor.o(($event) => $options.AcceptHint()),
    w: common_vendor.o(($event) => $options.RefuseHint())
  } : {}, {
    x: $data.ReceiverData.senderId === $data.id && $data.PkIDInfodata.pkStatus === 0
  }, $data.ReceiverData.senderId === $data.id && $data.PkIDInfodata.pkStatus === 0 ? {} : {}, {
    y: $data.PkIDInfodata.pkStatus === 1
  }, $data.PkIDInfodata.pkStatus === 1 ? {} : {}, {
    z: $data.PkIDInfodata.pkStatus === 2
  }, $data.PkIDInfodata.pkStatus === 2 ? {} : {}, {
    A: common_vendor.o(($event) => $options.operation(1)),
    B: common_vendor.o(($event) => $options.closeHint()),
    C: common_vendor.sr("popups", "cadadfe7-0"),
    D: common_vendor.p({
      type: "center",
      ["border-radius"]: "10px 10px 0 0"
    }),
    E: common_vendor.o(($event) => $options.operation(2)),
    F: common_vendor.o(($event) => $options.RefuseHintcloseHint()),
    G: common_vendor.sr("Refusepopup", "cadadfe7-1"),
    H: 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-cadadfe7"]]);
_sfc_main.__runtimeHooks = 2;
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/PKMessageprocessing/PKMessageprocessing.js.map
