import common from '../../utils/util';
import server from '../../utils/main';

const app = getApp();

Page({
  data: {
    FileUrl: app.globalData.imageUrl,
    IsShowButton:0,
  },
  onLoad: function (options) {
    var IsShowButton = 0;
    if (options.IsShowButton)
      IsShowButton=options.IsShowButton;
    this.setData({
      Containnerheight: common.getSystemHeight(),
      IsShowButton: IsShowButton
    });
    this.init();
  },
  onUnload: function () {
    app.globalData.IsRefresh=true;
  },
  init: function () {
    var that = this;
    server.getData('GetWXUsersAllTime?ProductID=' + app.globalData.ProgramID + '&UserID=' + app.globalData.userInfo.UserID, function (data) {
      if (data) {
        for (var i = 0; i < data.length; i++) {
          var date = common.formatDateCHS(common.formatTime(new Date()));
          if (data[i].Time >= date) 
            data[i].Member = "会员";
          else
            data[i].Member = "非会员";
        }
        that.setData({
          ProductList: data,
        });
      }
    });
  },
  gotoFeedback: function () {
    server.gotoFeedback();
  },
  gotoFinish:function(){
    wx.reLaunch({
      url: '../../pages/index/index',
    });
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
});