"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);
    this.getPkyourInfo();
    this.getPkmineInfo();
    this.getPkIDInfo();
  },
  methods: {
    //根据当前消息ID查询pk信息
    async getPkIDInfo() {
      await components_request.request({
        url: "pk/singleRecord",
        method: "POST",
        data: {
          id: this.customData.id
        },
        userInfo: true
      }).then((res) => {
        this.PkIDInfodata = res.data;
      });
    },
    //发布者
    async getPkyourInfo() {
      await components_request.request({
        url: "pk/pkInfoDetail",
        method: "POST",
        data: {
          id: this.customData.pkIdA
        },
        userInfo: true
      }).then((res) => {
        this.SenderData = res.data;
      });
    },
    //被邀请者
    async getPkmineInfo() {
      await components_request.request({
        url: "pk/pkInfoDetail",
        method: "POST",
        data: {
          id: this.customData.pkIdB
        },
        userInfo: true
      }).then((res) => {
        this.ReceiverData = res.data;
      });
    },
    //返回上一页
    goBack() {
      common_vendor.wx$1.navigateBack({
        delta: 1
      });
    },
    formatDate: components_formatDate.formatDate,
    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();
          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
          });
        }
      });
    }
  }
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: common_vendor.o$1((...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$1(($event) => $options.operation(1)),
    w: common_vendor.o$1(($event) => $options.operation(2))
  } : {}, {
    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 ? {} : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-cadadfe7"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/PKMessageprocessing/PKMessageprocessing.js.map
