var util = require('../../../../utils/util.js');
var api = require('../../../../config/api.js');
var user = require('../../../../utils/user.js');
var app = getApp();

Page({
  data: {
    userInfo: {
      nickName: '点击登录',
      avatarUrl: '/static/images/my.png',
      isDis: false
    }, 
    hasLogin: false
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
  },
  onReady: function () {

  },
  onShow: function () { 
    //获取用户的登录信息
    if (app.globalData.hasLogin) {
      let userInfo = wx.getStorageSync('userInfo');
      this.setData({
        userInfo: userInfo,
        hasLogin: true
      });
 
      let that = this;
      util.request(api.UserIndex).then(function (res) {
        if (res.errno === 0) {
          console.log(res);
          that.setData({
            order: res.data.order,
            isdis: res.data.isdis,
            isnid: res.data.isnid
          });
        }
      });
    }

  },
  onHide: function () {
    // 页面隐藏

  },
  goExchange(){
    wx.showToast({
      title: '功能完善中，敬请期待',
      icon: 'none',
      duration: 2000
    });
  },
  onUnload: function () {
    // 页面关闭
  },
  goLogin() {
    if (!this.data.hasLogin) {
      wx.navigateTo({
        url: "/pages/auth/login/login"
      });
    }
  }, 
})