"use strict";
const common_vendor = require("../../common/vendor.js");
const request_api = require("../../request/api.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
  data() {
    return {
      menuTop: common_vendor.inject("menuTop"),
      menuH: common_vendor.inject("menuHeight"),
      infoTop: "",
      userInfo: null,
      //用户信息
      memberInfo: null,
      //会员信息
      menuList: [
        {
          icon: "/static/icon/mine/aboutUs.png",
          title: "关于我们",
          url: "/pages/mine/web/web?type=1"
        },
        {
          icon: "/static/icon/mine/serviceTerm.png",
          title: "服务条款",
          url: "/pages/mine/web/web?type=2"
        },
        {
          icon: "/static/icon/mine/privacyProtocol.png",
          title: "隐私协议",
          url: "/pages/mine/web/web?type=3"
        },
        {
          icon: "/static/icon/mine/feedback.png",
          title: "意见反馈",
          url: "/pages/mine/feedback/feedback"
        },
        {
          icon: "/static/icon/mine/customerService.png",
          title: "联系客服"
        },
        {
          icon: "/static/icon/mine/logout.png",
          title: "退出登录"
        }
      ]
    };
  },
  onLoad() {
    this.infoTop = common_vendor.inject("navHeight") + 32 / 750 * common_vendor.inject("windowWidth");
  },
  onShow() {
    this.getUserInfoData();
    this.getMemberStatus();
  },
  methods: {
    /**
     * 点击查看个人信息
     */
    clickPersonalInfo() {
      common_vendor.index.navigateTo({
        url: "/pages/mine/basicInfo/basicInfo"
      });
    },
    /**
     * 点击vip
     */
    clickVip() {
      common_vendor.index.navigateTo({
        url: "/pagesMine/vip/vip"
      });
    },
    /**
     * 查看评论收藏点赞
     * @param {Object} index
     */
    clickNumItem(index) {
      if (index == 0) {
        common_vendor.index.navigateTo({
          url: "/pages/mine/commentReply/commentReply"
        });
      } else if (index == 1) {
        common_vendor.index.navigateTo({
          url: "/pages/mine/followCollect/followCollect"
        });
      } else
        common_vendor.index.navigateTo({
          url: "/pages/mine/myLike/myLike"
        });
    },
    /**
     * 点击菜单
     * @param {Object} url
     * @param {Object} index
     */
    clickMenuItem(url, index) {
      if (url) {
        common_vendor.index.navigateTo({
          url
        });
      } else if (index == this.menuList.length - 2) {
        this.$refs["popup"].open();
      } else if (index == this.menuList.length - 1) {
        common_vendor.index.showModal({
          title: "您确定要退出登录么",
          success(res) {
            if (res.confirm) {
              common_vendor.index.removeStorageSync("token");
              common_vendor.index.switchTab({
                url: "/pages/index/index"
              });
            }
          }
        });
      }
    },
    /**
     * 获取用户信息数据
     */
    getUserInfoData() {
      request_api.userInfo().then((res) => {
        if (res.code == 200) {
          this.userInfo = res.data;
        } else
          common_vendor.wx$1.showToast({
            title: res.message
          });
      }).catch((error) => {
      });
    },
    /**
     * 获取会员状态
     */
    getMemberStatus() {
      request_api.membershipStatus().then((res) => {
        if (res.code == 200) {
          this.memberInfo = res.data;
        } else
          common_vendor.index.showToast({
            title: res.message,
            icon: "none"
          });
      }).catch((error) => {
      });
    }
  }
};
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_assets._imports_0,
    b: common_vendor.s("top:" + $data.menuTop + "px;line-height:" + $data.menuH + "px;"),
    c: $data.userInfo
  }, $data.userInfo ? common_vendor.e({
    d: $data.userInfo.basic_info.avatar_url,
    e: common_vendor.t($data.userInfo.basic_info.nickname),
    f: common_vendor.t($data.userInfo.basic_info.phone),
    g: $data.memberInfo && $data.memberInfo.is_member
  }, $data.memberInfo && $data.memberInfo.is_member ? {
    h: common_vendor.t($data.memberInfo.subscription_type)
  } : {}, {
    i: common_assets._imports_1$4,
    j: common_vendor.s("margin-top:" + $data.infoTop + "px;"),
    k: common_vendor.o(($event) => $options.clickPersonalInfo())
  }) : {}, {
    l: $data.userInfo
  }, $data.userInfo ? {
    m: common_vendor.t($data.userInfo.statistics.total_comments),
    n: common_vendor.o(($event) => $options.clickNumItem(0)),
    o: common_vendor.t($data.userInfo.statistics.follows_count),
    p: common_vendor.o(($event) => $options.clickNumItem(1)),
    q: common_vendor.t($data.userInfo.statistics.likes_count),
    r: common_vendor.o(($event) => $options.clickNumItem(2))
  } : {}, {
    s: $data.memberInfo && !$data.memberInfo.is_member
  }, $data.memberInfo && !$data.memberInfo.is_member ? {
    t: common_assets._imports_2$4,
    v: common_vendor.o(($event) => $options.clickVip())
  } : {}, {
    w: common_vendor.f($data.menuList, (item, index, i0) => {
      return {
        a: item.icon,
        b: common_vendor.t(item.title),
        c: index,
        d: common_vendor.o(($event) => $options.clickMenuItem(item.url, index), index)
      };
    }),
    x: common_assets._imports_3$3,
    y: common_assets._imports_4$4,
    z: common_vendor.sr("popup", "dd5840e4-0"),
    A: common_vendor.p({
      type: "center"
    })
  });
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/mine.js.map
