<template>
	<view class="main-container">
		<view class="test-list" v-if="List.length > 0">
			<view class="list-li" v-for="(book,index) in List" :key="index">
				<view><image :src="book.img" mode="aspectFill"></image></view>
				<view>
					<p>
						<span>{{ book.name }}</span>
						<!-- <span>{{book.createtime}}</span> -->
					</p>
					<p>{{ book.content }}</p>
					<p>
						<span>{{book.price}} 元</span>
						<span v-if="Inv == 0" @click="goresult(book.name_id)">继续答题</span>
						<span v-else-if="Inv == 1" @click="goresult(book.oid)">查看结果</span>
					</p>
				</view>
			</view>
		</view>
		<view class="empty" v-else>
			<image src="../../static/img/emptys.jpg" mode="aspectFit"></image>
			<view>暂无数据~</view>
		</view>
	</view>
</template>

<script>
export default {
	components: {
	},
	props: ['Inv','List'],
	data() {
		return {
			
		};
	},
	onLoad() {
	},
	methods: {
		goresult(oid) {
			console.log('this.Inv',typeof this.Inv)
			if(this.Inv === 0){
				uni.navigateTo({
					url: '/pages/test/test?id='+oid
				})
			} else {
				uni.setStorageSync('oid', oid)
				uni.navigateTo({
					url: '/pages/result/result'
				})
			}
		}
	}
};
</script>

<style lang="scss" scoped>
	.main-container{
		height: 100%;
		.list-img{
			image{
				width: 170upx;
				height: 40upx;
			}
		}
		.test-list{
			.list-li{
				overflow: hidden;
				padding: 24upx 24upx;
				margin-top: 20upx;
				background-color: #FFFFFF;
				&:last-child{
					border-bottom: 0;
				}
				image{
					min-width: 186upx;
					max-width: 100%;
					height: 148upx;
				}
				view{
					float: left;
					display: inline-block;
					&:nth-child(1){
						width: 30%;
					}
					&:nth-child(2){
						width: 70%;
						text-indent: 20upx;
						p{
							text-overflow:ellipsis;
							white-space: nowrap;
							&:nth-child(1){
								overflow: hidden;
								font-size: 30upx;
								font-weight: 600;
								color: #292929;
							}
							&:nth-child(2){
								overflow: hidden;
								font-size: 26upx;
								font-weight: 400;
								color: #848484;
								margin: 20upx 0upx 26upx 0upx;
							}
							&:nth-child(3){
								position: relative;
								span{
									display: inline-block;
									&:nth-child(1){
										display: contents;
										font-size: 20upx;
										font-weight: 400;
										color: #FA564C;
									}
									&:nth-child(2){
										width: 150upx;
										right: 0;
										position: absolute;
										height: 50upx;
										line-height: 50upx;
										background: #EFD140;
										opacity: 1;
										border-radius: 26upx;
									}
									
								}
							}
						}
					}
				}
			}
		}
		.empty{
			text-align: center;
			margin-top: 20upx;
			background-color: #FFFFFF;
			image{
				width: 400upx;
				height: 400upx;
				margin: 70upx auto 20upx auto;
			}
			view{
				text-align: center;
				padding-bottom: 200upx;
				color: #8C8C8C;
			}
		}
	}
	
</style>
