<template>
	<view>
		<view class="page" v-for="i in processedResult">
			<view>
				<image :src="`http://124.93.196.45:10091/Neusoft/times-model${i[2]}`"></image>
			</view>
			<view>
				<p>中宣部授予{{i[0]}}“时代楷模”</p>
				<p>模特姓名：{{i[0]}}</p>
				<p>{{i[1]}}</p>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			end: {
				type: Number,
				default: 5
			}
		},
		data() {
			return {
				result: []
			}
		},
		computed: {
			processedResult(){
				return this.result.slice(0,this.end)
			}
		},
		async mounted() {
			this.result = (await this.requests("down", `/appModel/app-o/list`)).rows
			this.result = this.result.map(x => [x.modelName, x.content, x.picPath])
			console.log(this.result);
		},
		methods: {
			async requests(updown = "down", path) {
				let response
				if (updown == "up") {
					response = await fetch(`http://124.93.196.45:10091/Neusoft/times-model${path}`, {
						method: "POST",
						headers: {
							"Content-Type": "application/json",
						},
						body: JSON.stringify({
							"password": "0CYdq6Hn",
							"username": "6dOMIgIU"
						})
					})
				} else if (updown == "down") {
					response = await fetch(`http://124.93.196.45:10091/Neusoft/times-model${path}`, {
						method: "GET",
						headers: {
							"Content-Type": "application/json",
							"Authorization": "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImJjYtrrMxSx0OvYuqZ_0UL738RhVLuq-IxBIyHH1kt0gXAANbdsg"
						},
					})

				}
				const data = await response.json()
				console.log(data)
				return data
			}
		}
	}
</script>

<style>
	.page {
		border-radius: 15px;
		background-color: #fff;
		height: 12vh;
		display: flex;
		align-items: center;
		margin: 10px;
	}

	.page view:first-of-type {
		width: 30%;
		height: 95%;
		margin: 3%;

	}

	.page view:first-of-type image {
		width: 100%;
		height: 100%;
	}

	.page view:nth-child(2) {
		width: 65%;
	}

	.page view:nth-child(2) p:first-of-type {
		font-size: 1.2rem;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.page view:nth-child(2) p:nth-child(2) {
		font-size: 0.9rem;

	}

	.page view:nth-child(2) p:nth-child(3) {
		width: 100%;
		font-size: 0.9rem;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>
