var e;
(e = getApp()),
  Page({
    data: { isShow: !1, canIUseGetUserProfile: !1, userInfo: [] },
    onLoad: function (e) {
      wx.getUserProfile && this.setData({ canIUseGetUserProfile: !0 });
    },
    onShow: function () {
      this.userdata();
    },
    gotologo: function () {
      wx.navigateTo({ url: "/pages/login/login" });
    },
    userdata: function () {
      var n = this;
      e.util.getUserInfo(function (e) {
        e.memberInfo
          ? (n.setData({ memberInfo: e.memberInfo }),
            wx.setStorageSync("uid", e.memberInfo.uid),
            n.firstin(e.memberInfo, 0))
          : n.setData({ isShow: !0 });
      });
    },
    hideDialog: function () {
      this.setData({ isShow: !this.data.isShow });
    },
    updateUserInfo: function (n) {
      var t = this;
      console.log("用户数据", n),
        e.util.getUserInfo(function (e) {
          wx.setStorageSync("uid", e.memberInfo.uid),
            t.hideDialog(),
            t.firstin(e.memberInfo, 0);
        }, n.detail);
    },
    getUserProfile(n) {
      var t = this;
      console.log("用户数据", n),
        wx.getUserProfile({
          desc: "用于完善会员资料",
          lang: "zh_CN",
          success: (n) => {
            console.log("登录信息", n.userInfo),
              t.setData({ userInfo: n.userInfo, hasUserInfo: !0 }),
              e.util.getUserInfo(function (e) {
                var i = {
                  uid: e.memberInfo.uid,
                  avatar: n.userInfo.avatarUrl,
                  nickname: n.userInfo.nickName,
                };
                t.firstin(i, 1);
              });
          },
        });
    },
    getUserInfo: function (n) {
      var t = this;
      console.log("用户数据", n),
        e.util.getUserInfo(function (e) {
          wx.setStorageSync("uid", e.memberInfo.uid),
            t.hideDialog(),
            t.firstin(e.memberInfo, 1);
        }, n.detail);
    },
    firstin: function (n, t) {
      var i = this;
      console.log("提交数据", n),
        e.util.request({
          url: "entry/wxapp/Api",
          data: {
            m: "monai_market",
            r: "me.detail",
            uid: n.uid,
            type: t,
            head_image: n.avatar,
            nickname: n.nickname,
          },
          success: function (e) {
            console.log(e),
              i.setData({
                detail: e.data.data,
                is_member: e.data.data.user.is_member,
                store_img: e.data.data.user.store_img,
              }),
              1 == t && i.userdata();
          },
        });
    },
    goset: function () {
      wx.navigateTo({ url: "/pages/mine/info/index" });
    },
    retopublicity: function () {
      wx.navigateTo({ url: "/pages/publicity/index" });
    },
    binding: function () {
      wx.navigateTo({ url: "/pages/enter/enter" });
    },
    retocollection: function () {
      wx.navigateTo({ url: "/pages/collection/index" });
    },
    weizhang: function () {
      wx.reLaunch({ url: "/pages/reporlist/reporlist" });
    },
    tuiguang: function () {
      wx.navigateTo({ url: "/pages/mine/sale/index" });
    },
    mefabu: function () {
      wx.navigateTo({ url: "/pages/salelist/index" });
    },
    goPartOrder: function () {
      wx.navigateTo({ url: "/pages/part/apply/index" });
    },
    onReachBottom: function () {},
  });