// packageH/stock/index/index.js
const App = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    agent: null,
    relatedLink: [
      {
        name: "plaen_order",
        title: "订货",
        url: "/packageH/stock/guide/guide",
        icon: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/stock/plean_order.png",
      },
      {
        name: "my_inventory",
        title: "我的库存",
        url: "/packageH/stock/my/my",
        icon: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/stock/my_inventory.png",
      },
      {
        name: "my_order",
        title: "零售",
        url: "/packageH/stock/guide/guide?target=retail",
        icon: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/images/stock/my_order.png",
      },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    this.getAgent();
    wx.setNavigationBarTitle({
      title: "云库存",
    });
  },
  onShareAppMessage() {},
  onShareTimeline() {},

  getAgent() {
    wx.showLoading({
      title: "加载中",
      mask: true,
    });
    let urlStr = App.getNetAddresss("plugin.agency.api.agency.index");
    App._postNetWork({
      url: urlStr,
      success: ({ data: { data, result, msg } }) => {
        if (result === 0) {
          wx.hideLoading();
          wx.showToast({
            title: msg,
            success: () => {
              wx.redirectTo({
                url: "/packageG/member_v2/member_v2",
              });
            },
          });
          return;
        }
        this.setData({
          agent: data,
        });
        wx.hideLoading();
      },
    });
  },
});
