<template>
	<div class="detail">
        <mt-header class="detail_head" fixed title="我的评分">
            <router-link to="" slot="left">
                <mt-button icon="back" v-on:click="jumpBack()"></mt-button>
            </router-link>
        </mt-header>
        <div class="detail_body">
            <div class="noList" v-if="list.length==0">
                <img src="../../assets/image/noList.png">
            </div> 
            <ul v-else class="recordBox" v-infinite-scroll="loadMore" infinite-scroll-disabled="loading" infinite-scroll-distance="10">
                <li v-for="item in list" class="one_recordBox detailBox">
                    <div class="record_head">
                        <div>{{parseInt(item.scoringYearMonth.split('-')[1])}}月得分：&nbsp;&nbsp;&nbsp;<span>{{item.total}}分</span></div>
                    </div>
                    <div class="record_body">
                        <div>个人分：{{item.personalScore}}分</div>
                        <div>建议分：{{item.ideaScore}}分</div>
                        <div>评分人：{{item.rater}}</div>
                        <div>时间：{{item.scoringYearMonth}} <span class="toDetail" v-on:click="toDetail(item.uid,item.scoringYearMonth)">查看详情 ></span></div>
                    </div>
                </li>
                <div class="order" v-if="haveMore">
                    <span class="line"></span>
                    <span class="txt">没有更多了</span>
                    <span class="line"></span>
                </div>
            </ul>
        </div>
    </div>
</template>

<script>
	export default {
		data() {
			return {
                user: JSON.parse(sessionStorage.getItem("user")),
                list: [],
                pageNum: 1,
                pages: 1,
                haveMore: false,
			}
		},
		methods: {
            // 评分列表
            getList() {
                this.$indicator.open();
                this.http.post(this.port.my.scoreList, {
                    'uid': this.user.id,
                    'pageNum': 1
                } , 
                res => {
                    this.$indicator.close();
                    if (res.code == "ok") {
                        this.list = res.data.list;
                        this.pages = res.data.pages==0?1:res.data.pages;
                    } else {
                        this.$toast({
                            message: res.msg,
                            duration: 2000
                        });
                    }
                }, error => {
                    this.$indicator.close();
                    this.$toast({
                        message: error,
                        duration: 2000
                    });
                })
            },

            loadMore() {
                if(this.pageNum == this.pages) {
                    this.haveMore = true;
                } else if(this.pageNum < this.pages) {
                    this.$indicator.open();
                    this.http.post(this.port.my.scoreList, {
                        'uid': this.user.id,
                        'pageNum': ++this.pageNum
                    } , 
                    res => {
                        this.$indicator.close();
                        if (res.code == "ok") {
                            this.pages = res.data.pages==0?1:res.data.pages;
                            if(res.data.list.length != 0) {
                                for(var i in res.data.list) {
                                    this.list.push(res.data.list[i]);
                                }
                            }
                        } else {
                            this.$toast({
                                message: res.msg,
                                duration: 2000
                            });
                        }
                    }, error => {
                        this.$indicator.close();
                        this.$toast({
                            message: error,
                            duration: 2000
                        });
                    })
                }
            },

            toDetail(uid,time) {
                this.$router.push("/myScore/" + uid + "/" + time)
            },

            jumpBack() {
                this.$router.go(-1);
            }
        },
        created() {
            this.getList();
        },
		mounted() {
            
		}
	}

</script>

<style scoped>
    body {
        background: #EFEFEF;
    }
    
    .detail {
        background: #EFEFEF;
    }

    .detail_head {
        background: #fff;
        color: #333;
        height: 0.4rem;
    }

    .detail_body {
        margin-top: 0.4rem;
        padding-bottom: 0.15rem;
        background: #EFEFEF;
    }

    .detailBox {
        background: #fff;
        margin-bottom: 0.11rem;
    }

    .recordBox {
        margin: 0.12rem 0 0 0;
    }

    .one_recordBox {
        padding: 0.12rem 0.2rem;
    }

    .record_head {
        padding: 0 0 0.1rem 0;
        border-bottom: 1px solid #ccc;
    }

    .record_head > div {
        width: 100%;
        display: inline-block;
        vertical-align: middle;
    }

    .record_head > div span {
        color: #5FA1F0;
    }

    .record_body {
        color: #777;
        font-size: 0.12rem;
        line-height: 0.23rem;
        margin-top: 0.12rem;
    }

    .record_body .toDetail {
        float: right;
        color: #5FA1F0;
    }

    .noList {
        text-align: center;
        padding: 1.5rem 0;
    }

    .noList img {
        width: 1.2rem;
        height: 1.2rem;
    }

    .order {
        height: 0.6rem;
        line-height: 0.6rem;
        text-align: center;
    }

    .order .line {
        display: inline-block;
        width: 1.2rem;
        border-top: 1px solid #ccc ;
        vertical-align: middle;
    }

    .order .txt {
        color: #ccc;
        font-size: 0.13rem;
        vertical-align: middle;
    }
</style>