<!-- 
http://localhost:5173/custom/#/pages/xfl/challenge/index?pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
https://oss-mbh5.colormaprun.com/custom/#/pages/xfl/challenge/index?pagetype=challenge_result&distance=1320&status=success&name=天生我材必有用&cal=13500100&duration=3600&accuracy=50&syscount=25
 -->
<template>
	<view class="body">
		<view class="main">
			<view class="main-content">
				<view class="rank">
					<view class="statistic">
						<view class="statistic-left">
							<image class="statistic-ico" mode="aspectFit" src="../../../static/xfl/challenge/ico1.png">
							</image>
							<text class="statistic-title">总用时：</text>
						</view>
						<view class="statistic-right">
							<text class="statistic-value">{{durationMin}}</text><text class="statistic-unit">min</text>
						</view>
					</view>
					<view class="statistic">
						<view class="statistic-left">
							<image class="statistic-ico" mode="aspectFit" src="../../../static/xfl/challenge/ico2.png">
							</image>
							<text class="statistic-title">总里程：</text>
						</view>
						<view class="statistic-right">
							<text class="statistic-value">{{distanceKm}}</text><text class="statistic-unit">Km</text>
						</view>
					</view>
					<view class="statistic">
						<view class="statistic-left">
							<image class="statistic-ico" mode="aspectFit" src="../../../static/xfl/challenge/ico3.png">
							</image>
							<text class="statistic-title">脑力值：</text>
						</view>
						<view class="statistic-right">
							<text class="statistic-value">{{accuracy}}</text><text class="statistic-unit">分</text>
						</view>
					</view>
				</view>
				<view class="line"></view>
				<text class="name">选手: {{nameSub}}</text>
			</view>
			<text class="memo">请至活动查看排名详情</text>
		</view>
		
		<my-fab></my-fab>
	</view>
</template>

<script>
	import tools from '../../../common/tools';

	export default {
		data() {
			return {
				status: "",		// success: 挑战成功, ok: 挑战完成(没在规定时间完成，但打了所有点), fail: 挑战结束
				name: "",		// 用户名
				duration: 0,	// 总用时，秒
				distance: 0,	// 总里程，米
				cal: 0,			// 卡路里，卡 int
				accuracy: 0,	// 脑力值百分比
				syscount: 0		// 点数
			}
		},
		computed: {
			nameSub() {
				return this.name;
				/* const maxlen = 8;
				const nameLen = tools.calStrLen(this.name);
				console.log('nameLen', nameLen);
				if (nameLen <= 6) {
					return '选手: ' + this.name;
				}
				else {
					return this.name;
				} */
			},
			durationMin() {
				return Math.round(this.duration * 10 / 60) / 10;
			},
			distanceKm() {
				return Math.round(this.distance * 10 / 1000) / 10;
			}
		},
		onLoad(event) { // 类型非必填，可自动推导
			console.log('[challenge result] onLoad');
			this.status = event["status"] ?? "";
			this.name = event["name"] ?? "";
			this.duration = event["duration"] ?? 0;
			this.distance = event["distance"] ?? 0;
			this.cal = event["cal"] ?? 0;
			this.accuracy = event["accuracy"] ?? 0;
			this.syscount = event["syscount"] ?? 0;
		},
		methods: {
		}
	}
</script>

<style>
	.body {
		display: flex;
		width: 100vw;
		height: 100vh;
		flex-direction: column;
		align-items: center;
		justify-content: flex-end;
		/* background-color: black; */
		background-image: url("/static/xfl/challenge/success_bg.jpg");
		background-repeat: no-repeat;
		background-position-x: center;
		background-position-y: bottom;
		background-size: cover;
		/* background-size: 100% 100%; */
	}

	.main {
		margin-bottom: 430rpx;
		align-items: center;
	}

	.main-content {
		width: 80vw;
		height: 375rpx;
		background-color: #ffffff;
		border-radius: 25rpx;
		align-items: center;
	}

	.rank {
		width: 500rpx;
		/* height: 500rpx; */
		margin-top: 20rpx;
	}

	.statistic {
		height: 86rpx;
		/* margin-bottom: 16rpx; */
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.statistic-left {
		flex-direction: row;
		align-items: center;
	}

	.statistic-right {
		flex-direction: row;
		align-items: baseline;
	}

	.statistic-ico {
		width: 50rpx;
		height: 50rpx;
		margin-right: 10rpx;
	}

	.statistic-title {
		font-family: Source Han Sans CN;
		font-weight: 500;
		font-size: 36rpx;
		color: #333333;
	}

	.statistic-value {
		font-family: Source Han Sans CN;
		font-size: 50rpx;
		color: #333333;
		font-weight: bold;
	}

	.statistic-unit {
		font-family: Source Han Sans CN;
		font-size: 20rpx;
		color: #333333;
		padding-left: 10rpx;
	}

	.line {
		width: 500rpx;
		height: 3rpx;
		margin-top: 12rpx;
		background-color: #e6e6e6;
	}

	.name {
		width: 500rpx;
		/* 确保文本在一行内显示 */
		white-space: nowrap;
		/* 超出容器部分的文本隐藏起来 */
		overflow: hidden;
		/* 使用省略号表示被截断的文本 */
		text-overflow: ellipsis;
		text-align: center;
		margin-top: 18rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		font-size: 28rpx;
		color: #9e9e9e;
	}

	.memo {
		margin-top: 30rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #ffffff;
		font-size: 36rpx;
		text-align: center;
	}
</style>