<template>
	<view class="warpbox">
		<view class="tablist_new">
			<view class="tabtn" @click="changeTab(1)" :class="{'tabtn_active':active == 1}">{{i18n['未评价']}}</view>
			<view class="tabtn" @click="changeTab(0)" :class="{'tabtn_active':active == 0}">{{i18n['已评价']}}</view>
		</view>
		
		<scroll-view scroll-y class="scrollbox" @scrolltolower="loadMore">
			<view class="listwarp">
				<progressItem :list="list" :type="type"></progressItem>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import progressItem from './item.vue'
	import { netServiceList } from '@/api/api.js'
	
	export default{
		components:{
			progressItem
		},
		
		data() {
			return{
				page:1,
				totalPage:1,
				list:[],
				type:2,    //已评价   2未评价
				active:1,
			}
		},
		computed:{
			i18n() {
				return this.$t("evaluate")
			}
		},
		onShow() {
			uni.setNavigationBarTitle({
				title: this.i18n['评价']
			})
		},
		onLoad() {
			this.init()
		},
		methods:{
			changeTab(e) {
				this.active = e
				if(this.active == 0) {
					this.type = 1
				}else{
					this.type = 2
				}
				this.init()
			},
			init() {
				this.page = 1
				this.list = []
				this.getList()
			},
			loadMore() {
				if(this.page >= this.totalPage) {
					return
				}
				this.page ++
				this.getList()
			},
			getList() {
				let params = {
					page:this.page,
					type:this.type
				}
				netServiceList(params).then(res=>{
					this.list = this.list.concat(res.data.data)
					this.totalPage = res.data.last_page
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.scrollbox{
		width:750rpx;
		height:calc(100vh - 100rpx);
		.listwarp{
			padding:24rpx;
		}
	}
</style>
