<template>
	<view>
		
		<!-- 设置圆角 -->
		<view style="padding: 10px 30px 10px 30px;">
			<uni-search-bar :radius="100" @input="search" placeholder="搜题库"></uni-search-bar>
		</view>
		
		
		<yf-more-list url="/api/repo/user-paging" :params="queryParams" ref="moreList">
			<template v-slot:item="{ data }">
				
				<uni-list-item
				 :show-arrow="true" 
				 :title="data.title" 
				 :note="data.quCount+'道题'"
				 link="navigateTo"
				 :to="'/pages/repo/detail?id='+data.id"
				 >
				 </uni-list-item>
				
			</template>
		</yf-more-list>

	</view>
</template>

<script>
	import { checkProcess } from '@/api/repo/repo'
	export default {
		components: {  },
		data() {
			return {
				
				queryParams:{
					isTran: true,
					title: ''
				},
				trainData: {}
			}
		},
		
		onPullDownRefresh(){
			this.$refs.moreList.initData()
		},
		
		onReachBottom() {
			// 加载数据
			this.$refs.moreList.loadData()
		},
		onShow() {
			if(this.$refs.moreList){
				this.$refs.moreList.initData()
			}
			this.checkRepo()
		},
		
		methods: {
			
			checkRepo(){
				
				checkProcess().then(data => {
				      if(data!=null && data.id!=null){
						  
						  uni.showModal({
						  	cancelText: "取消", // 取消按钮的文字  
						  	confirmText: "确认", // 确认按钮文字 
						  	title: '删除提示',
						  	content: '是否要继续上一次的训练?',
						  	success: res => {
						  		if (res.confirm) {
						  			this.conTrain(data)
						  		}
						  	}
						  });
					  }
				})
			},

			search(e) {
				this.queryParams.title = e
			},
			
			conTrain(data) {
			  uni.navigateTo({
			      url: '/pages/repo/train?repoId='+data.repoId+'&mode='+data.mode
			  });
			}
		}
	}
</script>

<style>
	
	.container {
		font-size: 14rpx;
	}
	
	.exam-item{
		display: flex; align-items: center;
		line-height: 25px;
	}
	.exam-item .left{
		width: 80%; text-align: left;
	}
	.exam-item .left .title{
		font-size: 14px;
	}
	
	.exam-item .left .desc{
		font-size: 14px;
		color: #888;
	}
	
	.exam-item .left .icons{
		font-size: 10px; 
		display: flex; 
		align-items: center; 
		color: #666;
	}
	
	.exam-item .right{
		width: 20%; text-align: right;
	}
</style>
