var app = getApp();
var $ = require('../../../js/util.js');
Page({
  data: {
    info: [],
    other: [],
    user: [],
    param:{
    },
    goods_list:{},
    header_img:'/images/header_1.jpg',

  },
  onLoad: function (options) {//接收上个页面传的参数
    var self = this;
    if (options.invite_key) {
      app.globalData.invite_key = options.invite_key;
    }
  },
  onShow: function () {
    var self = this;
    app.getUserInfo(function (ret) {
      if (ret.username != ' ') {
        self.setData({
          info: ret,
        });
        self.getIndex();
      } else {
        self.setData({
          show_q: true
        })
      }
    });

  },
  getIndex: function () {
    var self = this;
    var action = 'c=LittleShop&a=index';
    app.showLoading('加载中...');
    app.ajaxRequest(action, 'GET', '', function (ret) {
      // console.log(ret);console.log('1-------------');
      if (ret.status == 1 && ret.data.info) {
        self.setData({
          info:ret.data.info,
          header_img :ret.data.info.logo,
        });
        if (ret.data.goods_list){
          self.setData({ goods_list:ret.data.goods_list,});
        }
      }
    }, true);
  },


  //获取用户信息授权
  // bindGetUserInfo: function (e) {
  //   var self = this;
  //   app.getUserInfo(function (ret) {
  //     self.setData({
  //       show_q: false,
  //       info: ret,
  //     })
  //     self.getIndex();
  //   })
  // },
  onShareAppMessage: function () {
    return {
      title: '超越无限',
      desc: '超越无限欢迎你!',
      path: '/' + $.getCurrentPageUrl() + '?invite_key=' + app.globalData.init_invite_key
    }
  },
})