"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_TimeFormatting = require("../../components/TimeFormatting.js");
const tabBar = () => "../../components/tabBar/tabBar.js";
const _sfc_main = {
  data() {
    return {
      userinfo: {},
      pkInformationdata: [],
      myPkRecorddata: [],
      SignStatus: null,
      AnchorList: []
    };
  },
  onShow() {
    common_vendor.index.getStorage({
      key: "userinfo",
      success: (res) => {
        components_request.request({
          url: "user/getUserInfo",
          method: "POST",
          data: {
            id: res.data.id
          },
          userInfo: true
        }).then((res2) => {
          if (res2.code == 200) {
            this.userinfo = res2.data;
            common_vendor.index.setStorageSync("userinfo", res2.data);
            this.getpkInformation();
            this.getmyPkRecord();
            this.getSignStatus();
            this.getAnchorList();
          } else {
            common_vendor.index.__f__("log", "at pages/Mine/Mine.vue:268", res2.msg);
          }
        });
      }
    });
  },
  methods: {
    //获取个人信息
    getUserInfo() {
      components_request.request({
        url: "user/getUserInfo",
        method: "POST",
        data: {
          id: this.userinfo.id
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.userinfo = res.data;
          common_vendor.index.setStorageSync("userinfo", res.data);
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/Mine.vue:289", res.msg);
        }
      });
    },
    // 获取主播列表
    getAnchorList() {
      components_request.request({
        url: "anchor/list",
        method: "POST",
        data: {
          id: this.userinfo.id
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.AnchorList = res.data.slice(0, 4);
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/Mine.vue:306", res.msg);
        }
      });
    },
    // 获取签到状态
    getSignStatus() {
      components_request.request({
        url: "user/checkSignStatus",
        method: "GET",
        data: {
          userId: Number(this.userinfo.id)
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.SignStatus = res.data;
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/Mine.vue:323", res.msg);
        }
      });
    },
    //签到
    sign() {
      components_request.request({
        url: "user/signIn",
        method: "POST",
        data: {
          userId: this.userinfo.id
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          common_vendor.index.showToast({
            title: "签到成功",
            icon: "none",
            duration: 2e3
          });
          this.getSignStatus();
          this.getUserInfo();
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/Mine.vue:346", res.msg);
        }
      });
    },
    formatDate: components_formatDate.formatDate,
    TimeFormatting: components_TimeFormatting.TimeFormatting,
    //获取pk信息
    getpkInformation() {
      components_request.request({
        url: "user/queryMyAllPkData",
        method: "POST",
        data: {
          userId: this.userinfo.id,
          page: 0,
          size: 4
        },
        userInfo: true
      }).then((res) => {
        if (res.code == 200) {
          this.pkInformationdata = res.data;
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/Mine.vue:367", res.msg);
        }
      });
    },
    //获取pk记录
    getmyPkRecord() {
      components_request.request({
        url: "user/handlePkInfo",
        method: "POST",
        data: {
          type: 1,
          userId: this.userinfo.id,
          page: 0,
          size: 4
        },
        userInfo: false
      }).then((res) => {
        if (res.code == 200) {
          this.myPkRecorddata = res.data;
        } else {
          common_vendor.index.__f__("log", "at pages/Mine/Mine.vue:387", res.msg);
        }
      });
    },
    // 跳转到PK记录详情页面
    onItemClick(item) {
      common_vendor.index.navigateTo({
        url: "/pages/Mine/minecomponents/DetailsPKRecords/DetailsPKRecords",
        success: (res) => {
          res.eventChannel.emit("itemDetail", {
            item
          });
        }
      });
    },
    // 跳转到积分页面
    goPoints() {
      common_vendor.index.navigateTo({
        url: "/pages/Mine/minecomponents/points"
      });
    },
    // 跳转到主播库页面
    anchorLibrary() {
      common_vendor.index.navigateTo({
        url: "/pages/Mine/minecomponents/anchorLibrary"
      });
    },
    // 跳转到PK信息页面
    pkInformation() {
      common_vendor.index.navigateTo({
        url: "/pages/Mine/minecomponents/pkInformation"
      });
    },
    // 跳转到PK记录页面
    pkRecord() {
      common_vendor.index.navigateTo({
        url: "/pages/Mine/minecomponents/pkRecord"
      });
    },
    // 跳转到联系客服页面
    contact() {
      common_vendor.index.navigateTo({
        url: "/pages/Mine/minecomponents/contact"
      });
    },
    // 跳转到设置页面
    goSetting() {
      common_vendor.index.navigateTo({
        url: "/pages/Setting/Setting"
      });
    },
    // 跳转到服务协议页面
    serviceProtocol() {
      common_vendor.index.navigateTo({
        url: "/pages/Mine/minecomponents/serviceProtocol"
      });
    },
    // 退出登录
    logout() {
      this.$refs.popupExpurgate.open("center");
    },
    //确认退出登录
    onExpurgateConfirm() {
      common_vendor.index.clearStorage();
      common_vendor.A.logout();
      common_vendor.index.reLaunch({
        url: "/pages/login/login"
      });
    },
    // 关闭弹窗
    closePopupExpurgate() {
      this.$refs.popupExpurgate.close();
    }
  },
  components: {
    tabBar
  }
};
if (!Array) {
  const _easycom_tabBar2 = common_vendor.resolveComponent("tabBar");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  (_easycom_tabBar2 + _easycom_uni_popup2)();
}
const _easycom_tabBar = () => "../../components/tabBar/tabBar.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
  (_easycom_tabBar + _easycom_uni_popup)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: $data.userinfo.headerIcon,
    b: common_vendor.t($data.userinfo.nickName),
    c: $data.SignStatus === true
  }, $data.SignStatus === true ? {
    d: common_vendor.o$1((...args) => $options.sign && $options.sign(...args))
  } : {}, {
    e: $data.SignStatus === false
  }, $data.SignStatus === false ? {} : {}, {
    f: common_vendor.o$1((...args) => $options.goSetting && $options.goSetting(...args)),
    g: common_vendor.t($data.userinfo.points),
    h: common_vendor.o$1((...args) => $options.goPoints && $options.goPoints(...args)),
    i: common_vendor.o$1((...args) => $options.anchorLibrary && $options.anchorLibrary(...args)),
    j: $data.AnchorList.length !== 0
  }, $data.AnchorList.length !== 0 ? {
    k: common_vendor.f($data.AnchorList, (item, index, i0) => {
      return {
        a: item.headerIcon,
        b: common_vendor.t(item.anchorId),
        c: common_vendor.t(item.country),
        d: index
      };
    })
  } : {}, {
    l: $data.AnchorList.length === 0
  }, $data.AnchorList.length === 0 ? {} : {}, {
    m: common_vendor.o$1((...args) => $options.anchorLibrary && $options.anchorLibrary(...args)),
    n: common_vendor.o$1((...args) => $options.pkInformation && $options.pkInformation(...args)),
    o: $data.pkInformationdata.length !== 0
  }, $data.pkInformationdata.length !== 0 ? {
    p: common_vendor.f($data.pkInformationdata, (item, index, i0) => {
      return {
        a: item.anchorIcon,
        b: common_vendor.t($options.formatDate(item.pkTime)),
        c: common_vendor.t(item.coin),
        d: index
      };
    })
  } : {}, {
    q: $data.pkInformationdata.length === 0
  }, $data.pkInformationdata.length === 0 ? {} : {}, {
    r: common_vendor.o$1((...args) => $options.pkInformation && $options.pkInformation(...args)),
    s: common_vendor.o$1((...args) => $options.pkRecord && $options.pkRecord(...args)),
    t: $data.myPkRecorddata.length !== 0
  }, $data.myPkRecorddata.length !== 0 ? {
    v: common_vendor.f($data.myPkRecorddata, (item, index, i0) => {
      return common_vendor.e({
        a: item.anchorIconA,
        b: item.winnerAnchorId !== item.anchorIdA && item.winnerAnchorId !== null
      }, item.winnerAnchorId !== item.anchorIdA && item.winnerAnchorId !== null ? {} : item.winnerAnchorId === item.anchorIdA && item.winnerAnchorId !== null ? {} : {}, {
        c: item.winnerAnchorId === item.anchorIdA && item.winnerAnchorId !== null,
        d: common_vendor.t(item.pkNumber),
        e: common_vendor.t($options.TimeFormatting(item.pkTime)),
        f: index,
        g: common_vendor.o$1(($event) => $options.onItemClick(item), index)
      });
    })
  } : {}, {
    w: $data.myPkRecorddata.length === 0
  }, $data.myPkRecorddata.length === 0 ? {} : {}, {
    x: common_vendor.o$1((...args) => $options.contact && $options.contact(...args)),
    y: common_vendor.o$1((...args) => $options.serviceProtocol && $options.serviceProtocol(...args)),
    z: common_vendor.o$1((...args) => $options.logout && $options.logout(...args)),
    A: common_vendor.p({
      tabIndex: 4
    }),
    B: common_vendor.o$1((...args) => $options.onExpurgateConfirm && $options.onExpurgateConfirm(...args)),
    C: common_vendor.o$1((...args) => $options.closePopupExpurgate && $options.closePopupExpurgate(...args)),
    D: common_vendor.sr("popupExpurgate", "402ad917-1"),
    E: 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-402ad917"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/Mine/Mine.js.map
