<template>
	<view class="content">
		<view class="topcontent">
			<image class="logo" :src="finishlogo"></image>
			<view class="text-area">
				<text class="title">感谢您的填写，请到积分商城兑换好礼</text>
			</view>
		</view>
		<view class="btn">
			<u-button type="primary" text="兑换好礼" shape="circle" color="#00A8EA"
				@click="navigateToHinge"></u-button>
			<u-button type="primary" :plain="true" text="再次填写" shape="circle" color="#00A8EA"
				@click="navigateBack"></u-button>
		</view>
	</view>
</template>

<script>
	import api from '@/api/api.js'
	import {store} from '@/store/coupon.js'
	import {acstore} from '@/store/activities.js'
	import {authState} from '@/util/auth.js'
	export default {
		data(){
			return {
				finishlogo:require('@/static/images/finishicon.png'),
				activityId:undefined
			}
		},
		methods: {
			navigateBack: () => {
				uni.reLaunch({
					url:'/pages/coupons/coupon/index'
				})
			},
			// navigateToShop:()=>{
			// 	uni.switchTab({
			// 		url:'/pages/simpleshop/index/index'
			// 	})
			// },
			navigateToHinge:()=>{
				uni.navigateTo({
					url:'/pages/coupons/hinge/index'
				})
			},
			
		},
		mounted(){
			if(authState.isLogin()){
				acstore.dispatch('getactivitId').then((res)=>{
					this.activityId =  parseInt(res.activitId)
				})
				store.dispatch('getanswer').then((ares)=>{
					if(ares.answer.length>0){
						api.answerFinished({
							id:this.activityId,
							answer:ares.answer
						}).then((res)=>{
							if(res.data.code == 200){
								store.commit('setanswer',[])
							}else{
								uni.showToast({
									title: res.data.message,
									icon: "none"
								})
							}
						})	
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: start;
		height: 100%;
	}

	.topcontent {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: space-between;
	}

	.logo {
		height: 346rpx;
		width: 382rpx;
		margin-top: 430rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 36rpx;
	}

	.title {
		font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
		font-weight: 500;
		font-size: 24rpx;
		color: #999999;
		line-height: 44rpx;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}

	.btn {
		display: flex;
		flex-direction: column;
		margin-top: 46rpx;
		width: 100%;
		height: 300rpx;
		width: 572rpx;
		gap: 44rpx;
	}
</style>


