var app = getApp();
var $ = require('../../../js/util.js');
Page({
  data: {
    user: []
  },
  onLoad: function (options) {//接收上个页面传的参数
    if (options.invite_key) {
      app.globalData.invite_key = options.invite_key;
    }
  },
  onReady: function () {
    //初始化数据
    var self = this;
    app.getUserInfo(function (ret) {
        self.getIndex();
    });
  },
  getIndex: function () {
    var self = this;
    var action = 'c=Member&a=mymoney';
    app.showLoading('加载中...');
    app.ajaxRequest(action, 'GET', '', function (ret) {
      if (ret.status == 1) {
        self.setData({
          user: ret.data
        });
      }
    }, true);
  },
  goToBalance: function (event) {
    if (this.data.user != '') {
      app.HCnavigateTo('../money/list/list?invite_key=' + app.globalData.init_invite_key);
    }
  },
  goToIntegral: function (event) {
    if (this.data.user != '') {
      app.HCnavigateTo('../integral/list/list?invite_key=' + app.globalData.init_invite_key);
    }
  },
  goToCoupon: function (event) {
    if (this.data.user != '') {
      app.HCnavigateTo('../coupon/list/list?invite_key =' + app.globalData.init_invite_key);
    }
  },
})