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

const app = getApp();

Page({
  data: {
    PayList: null,
  },
  onLoad: function (options) {
    this.setData({
      Containnerheight: common.getSystemHeight(),
    });
    this.init();
  },
  init: function () {
    var that = this;

    server.getData('GetWXUsersAllPayInfo500?UserID=' + app.globalData.userInfo.UserID + "&ProductID=" + app.globalData.ProgramID, function (data) {
      if (data) {
        var list = server.getProgramList();
        for(var i=0;i<data.length;i++){
          for (var k = 0; k < data[i].List.length; k++) {
            var item = data[i].List[k];
            for(var j=0;j<list.length;j++){
              if (item.ProductID == list[j].ID) {
                item.ImageName = list[j].ImageUrl;
                item.ProductName = list[j].Name;
              }
            }
          }
        }
        that.setData({
          PayList: data,
        });
      }
      else {
        that.setData({
          PayList: [],
        });
      }
    });
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
});