// packageD//member/myrelationship/detail/detail.js
const App = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    memberId: 0,
    order: {},
    level: {},
    totalPromotionCount: 0,
    member: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const memberId = options.member_id;
    this.setData({
      memberId,
    });
    wx.setNavigationBarTitle({
      title: "会员概况",
    });
    this.getClients();
  },
  getClients() {
    let url = App.getNetAddresss("plugin.member-center-agent.api.index");
    url += "&member_id=" + this.data.memberId;
    App._getNetWork({
      url,
      success: ({ data: { result, data, msg } }) => {
        console.log(data);
        if (result === 0) {
          wx.showToast({
            title: msg,
            icon: "none",
            duration: 1500,
            mask: false,
            success: (result) => {
              setTimeout(() => {
                wx.redirectTo({
                  url: "/packageD/member/myRelationship/myRelationship",
                });
              }, 1500);
            },
          });
        }
        data.order["orderCount"] = Number(data.order["orderCount"]);
        const setData = {
          level: data.level,
          order: data.order,
          totalPromotionCount: data.count,
          member: data.member,
        };
        this.setData(setData);
      },
    });
  },
});
