(function () {
    //数据   status 1正常  2早退 3旷课 4请假
    var weekData2 = [
        {
            week: '1',
            weekList: [
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 1 },
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 2 },
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 3 },
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 4 },
            ]
        },
        {
            week: '2',
            weekList: [
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 1 }
            ]
        },
        {
            week: '3',
            weekList: [
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 2 }
            ]
        },
        {
            week: '4',
            weekList: []
        },
        {
            week: '5',
            weekList: [
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 3 }
            ]
        },
        {
            week: '6',
            weekList: [
                { title: '现代经济的研究与发现', time: '08：00 - 09：00', teacher: '郑中基', classRoom: '网络1220班', status: 4 }
            ]
        },
        {
            week: '7',
            weekList: []
        }
    ];

    var weekTimeSpan2;
    var weekTimeI2;

    var todayWeek = weekday();

    var page = {
        isScroll: false,
        init: function ($page) {
            weekTimeSpan2 = $page.find('#weekTime2 span');
            weekTimeI2 = $page.find('#weekTime2 i');
            judgeDate()
            weekTimeSpan2.eq(0).text(todayWeek.Monday).end().eq(1).text(todayWeek.Sunday);
            studentCheckData(todayWeek.Monday, todayWeek.Sunday);
            $page.find('.tSec2Top2 li').on('tap',
                function () {
                    $(this).addClass('active').siblings().removeClass('active');
                    var ind = $(this).index();
                    $('.tSec2Con2').css('display', 'none').eq(ind).stop().fadeIn();
                });
            //上下周切换
            var weekDayTime = 7 * oneDayTime;
            weekTimeI2.on('tap',
                function () {
                    var index = weekTimeI2.index($(this));
                    if (index == 0) {
                        todayWeek.MondayTime = todayWeek.MondayTime - weekDayTime;
                        todayWeek.SundayTime = todayWeek.SundayTime - weekDayTime;
                    } else {
                        todayWeek.MondayTime = todayWeek.MondayTime + weekDayTime;
                        todayWeek.SundayTime = todayWeek.SundayTime + weekDayTime;
                    }
                    todayWeek.Monday = fmtDate(todayWeek.MondayTime);
                    todayWeek.Sunday = fmtDate(todayWeek.SundayTime);
                    weekTimeSpan2.eq(0).text(todayWeek.Monday).end().eq(1).text(todayWeek.Sunday);
                    judgeDate(todayWeek.SundayTime);
                    studentCheckData(todayWeek.Monday, todayWeek.Sunday);
                });
        }
    };
    function studentCheckData(Monday, Sunday) {
        var studCheckList = $('.studCheckList');
        learun.httpget(config.webapi + "learun/adms/timetable/StuLessonInfo", {}, (data) => {
            console.log(data);
            $.each(data, function (i, n) {
                var html = '';
                if (n.weekList.length == 0) {
                    html = '<li>暂时没有信息</li>';
                } else {
                    $.each(n.weekList, function (j, k) {
                        var statusName = k.Sort;
                        var sort;
                        switch (statusName) {
                            case "迟到":
                                sort = "2";
                                break;
                            case "早退":
                                sort = "2";
                                break;
                            case "病假":
                                sort = "4";
                                break;
                            case "事假":
                                sort = "2";
                                break;
                            case "准时":
                                sort = "1";
                                break;
                            case "旷课":
                                sort = "3";
                                break;
                            default:
                        }
                        html += '<li>' +
                            '<div class="studCheckT"><img src="images/book.png" alt="" />' + k.LessonName + '</div>' +
                            '<div class="studCheckTxt">' +
                            '<img src="images/time.png" alt="" />' + k.LessonDate +
                            '<span><img src="images/person.png" alt="" />' + k.Teacher + '</span>' +
                            '<img src="images/location.png" alt="" />' + k.ClassRoomName +
                            '</div>' +
                            '<div class="studCheckStatue studCheckStatue' + sort + '">' +
                            '<span></span>' + statusName +
                            '</div>' +
                            '</li>';
                    })
                }
                studCheckList.eq(parseInt(n.week) - 1).html(html)
            })


        })


    }
    return page;
})();