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

const app = getApp();

Page({
  data: {
    ImagePath: app.globalData.uploadImageUrl,
  },
  onLoad: function () {
    var that = this;
    that.setData({
      CheckListUserID: app.globalData.userInfo.UserID,
      Containnerheight: main.getWindowHeight(),
      UserID: app.globalData.userInfo.UserID,
    });

    var userid = app.globalData.userInfo.UserID;
    main.getData("GetMiaoguoLesson2?UserID=" + userid, function (data) {
      if (data) {
        
        var arr=[];
        for(var i=0;i<4;i++)
          arr.push(data[i]);

        that.setData({
          List: arr,
        });

        wx.setStorageSync("LessonList", data);
      }
    });
  },
  gotoLesson: function (e) {
    var id = e.currentTarget.dataset.id;
    var idchild="";
    if (e.currentTarget.dataset.idchild && id>1)
      idchild = '&LessonPage=' +e.currentTarget.dataset.idchild;
    
    if (e.currentTarget.dataset.url){
      wx.navigateTo({
        url: '../other/video?LessonID=' + id +idchild+"&imageurl="+e.currentTarget.dataset.imageurl+"&url="+e.currentTarget.dataset.url,
      });
    }
    else{
      if (id!=2 && id!=3){
        wx.navigateTo({
          url: '../other/lesson?LessonID=' + id +idchild,
        });
      }
    }
  },
  onShareAppMessage: function () {
    return {
      title: "教学课程",
      path: app.globalData.SharePath + '?type=lesson&LessonID=all&UserID=' + app.globalData.userInfo.UserID,
      imageUrl: app.globalData.uploadImageUrl+"web/program_screenshot_lesson_a00.png",
    }
  },
})
