(function () {
    //数据
    var studentSeeData = {
        dataTimeList: [{
            value: "1",
            text: "2014-2015学年第一学期5月月考"
        }, {
            value: "2",
            text: "2014-2015学年第一学期4月月考"
        }],
        data: {
            classRanking: 11,
            achievement: 400,
            dataList: [
                { name: '酒店管理1（礼仪、会议）', achievement: '98' },
                { name: '酒店管理2（礼仪、会议）', achievement: '96' }
            ]
        }
    }

    var dataTimeList = studentSeeData.dataTimeList;
    var page = {
        isScroll: false,
        init: function ($page) {
            //获取学年学期列表
            learun.httpget(config.webapi + "scoreSearch/academicAndSemesterList", {}, (data) => {
                if (data == null || data.length <= 0) {
                    $('.studSeeSec2 .studSeeSec2Top').hide();
                    $('.studSeeSec2 .tips').show();
                    return;
                }
                studentSeeData.dataTimeList = data;
                dataTimeList = studentSeeData.dataTimeList;
                //获取成绩列表
                studentSeeAjax(dataTimeList[0].value);
                //学年学期选择框
                $page.find('.studSeeSec1Box').lrpicker({
                    placeholder: dataTimeList[0].text,
                    data: dataTimeList,
                    callbacks: function (res) {
                        studentSeeAjax(res.value)
                    }
                });
            });

        }
    };
    //数据处理
    function studentSeeAjax(id) {
        var param = { value: id };
        learun.httpget(config.webapi + "scoreSearch/scoreList", param, (data) => {
            if(data != null){
                var html1 = '<div class="studSeeSec2Txt">' +
                    '<div><span>' + data.Rank + '</span>名</div><div>班级排名</div>' +
                    '</div>' +
                    '<div class="studSeeSec2Line"></div>' +
                    '<div class="studSeeSec2Txt">' +
                    '<div><span>' + data.TotalScore + '</span>分</div><div>综合成绩</div>' +
                    '</div>';
                $('.studSeeSec2TopBox').html(html1);
                var html2 = '';
                $.each(data.ScoreList, function (i, n) {
                    html2 += '<li><img src="images/book.png" alt="" />' + n.LessonName + '<span>' + n.Score + '分</span></li>';
                });
                $('.studSeeSec2List').html(html2);
            }
        });
    }
    return page;
})();