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

var app = getApp();
var arrInformation = [
  {},
  {
    PageID: 1,
    text1: "课外课",
    text2: "如何制作合格的题卡——添加题卡 资料格式篇",
    text3: "制作题卡的操作步骤，各种常用的题卡格式，利用秒过的+资料功能怎么快速完成文科内容的题卡制作。"
  },
  {
    PageID: 2,
    text1: "课外课",
    text2: "如何制作合格的题卡——添加题卡 便捷操作篇",
    text3: "录入长篇幅内容，比如文字较多没有算式的概念题、英语例句等内容的技巧，重复利用手机的强大能力。"
  },
  {
    PageID: 3,
    text1: "课外课",
    text2: "如何制作合格的题卡——内容写法 语文篇",
    text3: "“大而全”的题卡是极其不适宜的做法，做题卡是有讲究的。怎么做既有效率又能帮助孩子理出头绪更有成效呢？"
  },
  {
    PageID: 4,
    text1: "课外课",
    text2: "如何制作合格的题卡——内容写法 数学英语篇",
    text3: "数学计算题、应用题，英语单词、语法、辩词的具体写法。检验孩子是不是在单纯背诵答案选项？如何避免与应对。"
  },
  {
    PageID: 5,
    text1: "课外课",
    text2: "怎么开展学习——流程篇",
    text3: "题卡的作用是促使孩子通过“回想”记住知识。不能容纳庞大繁复的书本内容，对摘录方法有一定的要求。"
  },
  {
    PageID: 6,
    text1: "课外课",
    text2: "怎么开展学习——要点篇",
    text3: "在学习中怎么打分，记忆评价的使用；用工具栏实现快捷操作控制学习进度；调节任务量灵活控制学习时间。"
  },

]

Page({
  data: {
    ImagePath: app.globalData.uploadImageUrl,
    PanelShow: -2,
  },
  onPullDownRefresh: function () {
    wx.reLaunch({
      url: '../../pages/index/index?type=userbook',
    })
    wx.stopPullDownRefresh();
  },
  onLoad: function () {
    var that = this;

    var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime)));
    var endDate=common.formatTime(common.addDate("y", 1, new Date(app.globalData.userInfo.ProductServiceTime)));
    
    var arr = [];
    for (var i = arrInformation.length - 1; i >= 1; i--) {
      arr.push(arrInformation[i]);
    }
    that.setData({
      Containnerheight: main.getWindowHeight(),
      NickName: app.globalData.userInfo.NickName,
      AvatarUrl: app.globalData.userInfo.AvatarUrl,
      ProductServiceTime: productServiceTime,
      EndDate: endDate,
      ArrInformation: arr,
      IsShow: app.globalData.userInfo.IsShow,
      IsMember: app.globalData.userInfo.IsMember,
      IsPay: app.globalData.userInfo.IsPay,
      IsLoseEfficacy: app.globalData.userInfo.IsLoseEfficacy,
      ClassTotalDayNumber: app.globalData.userInfo.ClassTotalDayNumber,
      ChildUserID: app.globalData.userInfo.ChildUserID,
      UserID:app.globalData.userInfo.UserID,
    });

    that.init();

    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: "#FF9F33",
    });
  },
  init: function () {
    var that = this;
    var panelShow = 0;
    if (app.globalData.userInfo.Subscribe == 1 && app.globalData.userInfo.IsProbation == 1) {
      panelShow = 1;
      if (app.globalData.userInfo.IsMember == 1 && app.globalData.userInfo.ClassID > 0) {

        var ClassTimeStart = common.formatDateCHS(app.globalData.userInfo.ClassStartDate);
        var ClassTimeEnd = common.formatDateCHS(app.globalData.userInfo.ClassEndDate);

        var earlyBirdTimeStart = common.formatDateCHS(common.formatTime(common.addDate("d", that.data.ClassTotalDayNumber-4, new Date(app.globalData.userInfo.ClassStartDate))));
        var earlyBirdTimeEnd = common.formatDateCHS(common.formatTime(common.addDate("d", that.data.ClassTotalDayNumber-1, new Date(app.globalData.userInfo.ClassStartDate))));

        var ClassDayNumber = app.globalData.userInfo.ClassDayNumber;
        //console.log("ClassDayNumber:" + ClassDayNumber);

        that.setData({
          ClassTimeStart: ClassTimeStart,
          ClassTimeEnd: ClassTimeEnd,
          EarlyBirdTimeStart: earlyBirdTimeStart,
          EarlyBirdTimeEnd: earlyBirdTimeEnd,
          ClassDayNumber: ClassDayNumber,
        });

        panelShow = 2;
      }
    }
    else if (app.globalData.userInfo.Subscribe == 0) {
      panelShow = -1;
    }

    if (panelShow==0){
      wx.redirectTo({
        url: '../other/newuser',
      })
    }
    else{
      that.setData({
        PanelShow: panelShow,
      });
    }
  },
  copyManager: function (e) {
    var copytype = e.currentTarget.dataset.copytype;
    var str1 = "changyibzr";
    var str2 = "请在微信添加用户中长按粘贴。";
    if (copytype && copytype == "公众号") {
      str1 = "秒过学习法";
      str2 = "请在微信添加公众号中长按粘贴。";
    }

    wx.setClipboardData({
      data: str1,
      success(res) {
        wx.showModal({
          title: '已复制',
          showCancel: false,
          content: str2,
          confirmText: "知道了",
        });
      }
    })
  },
  goto: function (e) {
    var url = e.currentTarget.dataset.url;
    wx.navigateTo({
      url: url,
    });
  },
  gotoIndex: function () {
    wx.reLaunch({
      url: '../index/index?type=userbook',
    })
  },
  onShareAppMessage: function () {
    return {
      title: "用户手册",
      path: app.globalData.SharePath + '?type=userbook&UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.uploadImageUrl +"web/program_screenshot_usermanual.png",
    }
  },
})