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

const app = getApp();

Page({
  data: {
    List:[],
  },
  onLoad: function (options) {
    this.setData({
      Containnerheight: common.getSystemHeight(),
    });
    this.init();
  },
  init:function(){
    var that = this;
    wx.showLoading({
      title: '请稍后',
    })
    server.getData('GetProductGivePresent?UserID=' + app.globalData.userInfo.UserID + "&ProductID=" + app.globalData.ProgramID, function (data) {
      wx.hideLoading({});
      if (data) {
        var arr=server.getProgramList();
        for(var i=0;i<arr.length;i++){
          for(var j=0;j<data.length;j++){
            if (arr[i].ID==data[j].ProgramID){
              data[j].ProgramName=arr[i].Name;
              data[j].ProgramUrl=arr[i].ImageUrl;
              break;
            }
          }
        }
        that.setData({
          List: data,
        });
      }
    });
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
})