<template>
	<view></view>
</template>

<script>
	export default {
		data() {
			return {
			}
		},
		onLoad(event) { // 类型非必填，可自动推导
			// console.log(event);
			const queryString = this.objectToQueryString(event);
			// console.log(queryString);
			const status = event["status"] ?? ""
			
			if (status == 'success') {	// 挑战成功
				uni.reLaunch({
					url: '/pages/challenge/success?' + queryString
				});
			}
			else if (status == 'ok' || status == 'fail') {	// 挑战完成/挑战失败
				uni.reLaunch({
					url: '/pages/challenge/exit'
				});
			}
			else {
				this.showErr();
			}
		},
		methods: {
			showErr() {
				uni.showToast({
					title: '参数错误'
				});
			},
			objectToQueryString(obj) {
				return Object.keys(obj).map(k => k + '=' + obj[k]).join('&');
			}
		}
	}
</script>