<!-- 我的违规 -->
<template>
    <view id="meViolation">
        <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>{{item.violationContent}}</view>
                </view>
                <view class="right-box" :class="{'colorA':item.penaltyType!=0}">线下约谈</view>
                <img src="@/images/icon_wdwg_gd.png" v-if="item.penaltyType==0">
            </view>
            <view class="get-null-box" v-if="getData.nullDataType">暂无更多数据</view>
        </scroll-view>
    </view>
</template>

<script>
    import { getViolationList } 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: {
            //去考试
            goExamList(item){
				if(item.penaltyType == 0){
					uni.navigateTo({
					    url: '/pages_student/workbench/exam/examList?violationId='+encodeURIComponent(JSON.stringify(item.id))
					});
				}
            },
            //清除
            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,
                }
                let {data} = await getViolationList(obj)
                if(data.code==200){
                    if(self.getData.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>
    #meViolation{
        height:100%;
        width:100%;
        display flex
        .max-list-box{
            flex:1;
            overflow: scroll
            .for-list-box{
                background #fff
                border-top:1rpx solid #E0E0E0;
                display flex
                .left-box{
                    flex:1;
                    view:nth-child(1){
                        line-height:22rpx;
                        font-size:22rpx;
                        margin:21rpx 0 0 19rpx;
                        color: #666
                    }
                    view:nth-child(2){
                        line-height:29rpx;
                        font-size:29rpx;
                        margin:27rpx 0 0 19rpx;
                        color: #333

                    }
                }
                .right-box{
                    line-height:120rpx;
                    width:140rpx;
                    color:#0183FA;
                    text-align: right
                    margin-right:20rpx;
                }
                .colorA{
                    color:#999;
                    margin-right:60rpx;
                }
                img{
                    height:20rpx;
                    width:20rpx;
                    margin:51rpx 20rpx 50rpx 0;
                }
            }
            .get-null-box{
                height:100rpx;
                line-height:100rpx;
                color:#999;
                text-align center
            }
        }
    }
</style>
