<template>
		<yf-more-list url="/api/user/exam/my-paging" :params="queryParams" ref="moreList">
			<template v-slot:item="{ data }">
				<uni-list-item>
					<view slot="body">
						<view class="list-body">
							<view class="list-flex">
								<view style="flex-grow: 1;">
									<view style="font-weight: 700;">{{data.title}}</view>
									<view style="color: #666;">最高分：{{data.maxScore}}</view>
									<view style="color: #888; font-size: 10px;">最近考试：{{data.updateTime}}</view>
								</view>
								<view>
									<view v-if="data.passed" class="pass">通过</view>
									<view v-else class="fail">不通过</view>
								</view>
							</view>
							<view class="list-flex">
								<view style="width: 49%; ">
									<button type="warn" @click="navtoBook(data.examId)">错题训练</button>
								</view>

								<view style="width: 49%;">
									<button type="primary" @click="navtoPaper(data.examId)">考试记录</button>
								</view>


							</view>
						</view>
					</view>
				</uni-list-item>

			</template>
			
		</yf-more-list>
</template>

<script>
	export default {
		data() {
			return {
				queryParams: {
					
				}
			}
		},
		onReachBottom() {
			// 加载数据
			this.$refs.moreList.loadData()
		},
		onShow() {
			if(this.$refs.moreList){
				this.$refs.moreList.initData()
			}
		},

		onBackPress(e) {

			//正常返回页面
			uni.switchTab({
				url: "/pages/user/index"
			})

			return true;
		},

		methods: {

			// 考试详情页
			navtoBook(id) {
				uni.navigateTo({
					url: '/pages/paper/book?id=' + id
				});
			},

			navtoPaper(id) {
				uni.navigateTo({
					url: '/pages/paper/list?id=' + id
				});
			}
		}
	}
</script>

<style scoped>
	.list-body {
		width: calc(100vw - 32px);
	}

	.list-flex {
		display: flex;
		align-items: center;
		margin-bottom: 10px;
		justify-content: space-between;
	}

	.pass {
		color: #007AFF !important;
		margin-right: 5px;
	}

	.fail {
		color: #ff0000 !important;
		margin-right: 5px;
	}
</style>
