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

const app = getApp();

Page({
  data: {
  },
  onLoad: function (options) {
    var that = this;
    that.setData({
      Containnerheight: main.getWindowHeight(),
    });

    that.init(options.id);
  },
  init: function (id) {
    var that = this;
    var card={};
    var list = app.globalData.CardList;
    var arrStudyPlay=constant.arrStudyPlay;
    for (var i = 0; i < list.length; i++) {
      if (id == list[i].MiaoguoCardID) {
        card.CreateTimeStr = common.formatDateCHS(list[i].CreateTime);
        card.LimitTimeStr = common.formatDateCHS(list[i].LimitTime);
        card.LearnNumber = list[i].LearnNumber;
        card.CardID=id;
        for(var j=0;j<arrStudyPlay.length;j++){
          if (list[i].CardType==arrStudyPlay[j].CardType){
            card.CardTypeStr=arrStudyPlay[j].Name;
            card.CardType=list[i].CardType;
            break;
          }
        }
        if (list[i].FirstTime=="1900-01-01 00:00:00"){
          card.Status="新题卡";
        }
        else{
          card.Status="旧题卡";
        }

        break;
      }
    }
    
    that.setData({
      CardInfo: card
    });
  },
  goto: function (e) {
    var url = e.currentTarget.dataset.url;
    wx.navigateTo({
      url: url,
    });
  },
  onShareAppMessage: function () {
    return {
      title: app.globalData.ShareTitle,
      path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.ShareImage,
    }
  },
})
