<template>
	<view class="pages" v-if="title">
		<image class="img" :src="img_src+ 'answer_success.png'" mode=""></image>
		<text class="title">{{title}}</text>
		<button class="btn" @click="toPrize">{{btn_text}}</button>
	</view>
</template>

<script>
	import config from "@/utils/js/config.js"
	export default {
		data() {
			return {
				img_src: config.img_url,
				title: "",
				btn_text: "知道了，感谢!",
				isback_: true
			}
		},
		onLoad(options) {
			this.title = `恭喜答对${options.num}题，获得${options.integer}元兑购金`
		},
		onUnload() {
			if(this.isback_) {
				this.toAnswerQuestionsPrize(1)
			}
		},
		methods: {
			// 跳转答题区域
			toPrize() {
				// uni.redirectTo({
				// 	url: "./../index"
				// })
				this.isback_ = false;
				this.toAnswerQuestionsPrize(2)
			},
			// 返回到答题列表
			toAnswerQuestionsPrize(index) {
				var that = this;
				let page_url = getCurrentPages()
				if (page_url.length > 1) {
					var url = page_url[page_url.length-2].route;
					console.log(url,"----------------------------");
					if (url == "pagesB/homeGridList/answerQuestionsPrize/detale/detale") {
						// 返回到答题列表 1为返回一次 因为还有自己的返回 2为点击btn返回所以两次
						uni.navigateBack({
							delta:index
						})
					}
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
.pages{
	display: flex;
	flex-direction: column;
	align-items: center;
	.img{
		margin-top: 71rpx;
		width: 380rpx;
		height: 380rpx;
		border-radius: 50%;
	}
	.title{
		margin-top: 56rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #01AEEA;
	}
	.btn{
		margin-top: 85rpx;
		width: 536rpx;
		height: 76rpx;
		border-radius: 26rpx;
		border: 3rpx solid #01AEEA;
		background-color: #fff;
		font-size: 30rpx;
		color: #01AEEA;
		display: flex;
		justify-content: center;
		align-items: center;
	}
}
</style>
