<!-- 成绩查询 -->
<template>
    <view id="resultInquiry">
        <scroll-view scroll-y @scrolltolower="scrollGet" class="max-list-box">
            <view class="for-list-box" v-for="(item,index) in dataList" :key="index">
                <view class="left-box">考试时间：<view>{{item.createTime}}</view></view>
                <view class="right-box">
                    <view class="min-left">考试成绩：<view>{{item.title}}</view></view>
                    <view class="min-right">是否合格：<view>{{item.userScore>=item.qualifyScore?'是':'否'}}</view></view>
                </view>
            </view>
            <view class="get-null-box" v-if="getData.nullDataType">暂无更多数据</view>
        </scroll-view>
    </view>
</template>

<script>
    import { getExamList } from '@/api/index.js'
    export default {
        data() {
            return {
                dataList:[],
                //列表请求参数
                getData:{
                    page:1,
                    pageSize:20,
                    getType:true,
                    nullDataType:true,
                }
            }
        },
        onLoad() {

        },
        onShow(){
            this.clearData();
            this.getList();
        },
        methods: {
            //清除
            clearData(){
                this.infoList = [];
                this.getData.page = 1;
                this.getData.getType = true;
                this.getData.nullDataType = true;
            },
            //滚动事件
            scrollGet(){
                if(this.getData.getType){
                    this.getData.page += 1;
                    this.getList();
                }
            },
            //获取列表数据
            async getList(){
                let self = this;
                let obj = {
                    pageNum:this.getData.page,
                    pageSize:this.getData.pageSize,
                }
                const {data} = await getExamList(obj)
                if(data.code==200){
                    if(self.page==1){
                        if(data.rows.length > 0 && data.rows.length == self.getData.pageSize){
                            self.dataList = data.rows;
                        }else if(data.rows.length > 0 && data.rows.length != self.getData.pageSize){
                            self.dataList = data.rows;
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }else{
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }
                    }else{
                        if(data.rows.length > 0 && data.rows.length == self.getData.pageSize){
                            self.dataList = self.dataList.concat(data.rows)
                        }else if(data.rows.length > 0 && data.rows.length != self.getData.pageSize){
                            self.dataList = self.dataList.concat(data.rows);
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }else{
                            self.getData.getType = false;
                            self.getData.nullDataType = true;
                        }
                    }
                }
            },
        }
    }
</script>

<style lang="stylus" scoped>
    #resultInquiry{
        height:100%;
        width:100%;
        display flex
        .max-list-box{
            flex:1;
            overflow: scroll
            .for-list-box{
                background #fff
                overflow hidden
                .left-box{
                    border-top:1rpx solid #E0E0E0;
                    color:#999999;
                    display flex
                    font-size:30rpx;
                    line-height:30rpx;
                    margin:0 29rpx 0;
                    padding:24rpx 9rpx 0;
                    view{
                        line-height:30rpx;
                        color:#333333;

                    }
                }
                .right-box{
                    margin:32rpx 29rpx 0;
                    padding:0 9rpx 24rpx;
                    display flex
                    .min-left{
                        flex:2;
                        font-size:30rpx;
                        line-height:30rpx;
                        color:#999999;
                        display flex
                        view{
                            width:280rpx;
                            font-size:30rpx;
                            color:#333333;
                            /*
                            display block
                            overflow:hidden;
                            text-overflow:ellipsis;
                            white-space:nowrap;
                            */
                        }
                    }
                    .min-right{
                        flex:1;
                        font-size:30rpx;
                        line-height:30rpx;
                        color:#999999;
                        display flex
                        view{
                            font-size:30rpx;
                            color:#333333;

                        }

                    }
                }
            }
            .for-list-box:nth-child(1){
                .left-box{
                    border:none;
                }
            }
            .get-null-box{
                height:100rpx;
                line-height:100rpx;
                color:#999;
                text-align center
            }
        }
    }
</style>
