<template>
	<view class="page__view">
		
		<view class="bg"></view>

		<view class="main">

			<view class="swiper">
				<uv-swiper 
					:list="bannerList" keyName="image" 
					indicator 
					indicatorMode="dot" 
					indicatorActiveColor="#62BBFF"
					indicatorInactiveColor="#FFFFFF" 
					height="340rpx"
					:autoplay="false"
				></uv-swiper>
			</view>

			<view class="flex flex-column card">
				<view class="title">公司风险检测</view>
				<image class="icon" src="@/static/image/icon-index.png" mode="widthFix"></image>
				<button class="btn" @click="onStartTest">开始测评</button>
			</view>

			<unfinishTestPopup ref="unfinishTestPopup"></unfinishTestPopup>

			<tabber select="home" />

		</view>

	</view>
</template>

<script>
	import tabber from '@/components/base/tabbar.vue'
	import unfinishTestPopup from '@/components/home/unfinishTestPopup.vue'

	export default {
		components: {
      tabber,
			unfinishTestPopup,
		},
		data() {
			return {
				bannerList: [],
			}
		},
		onLoad() {
			if(uni.getStorageSync('token')){
				this.$store.commit('getUserInfo')
			}
			this.fetchUnfinish()
			this.fetchBanner()
		},
		methods: {
			async fetchBanner() {
				try {

					this.bannerList = (await this.$fetch('queryBannerList', { type: '0' }))?.records // type：0-首页

				} catch (err) {

				}
			},
			async fetchUnfinish() {
				// todo: delete
				// let data = { id: '001', unfinishCount: 15, current: 18, }
				// this.$refs.unfinishTestPopup.open(data)

				// todo: fetch
			},
			onStartTest() {
				uni.navigateTo({
					url: `/pages_order/test/start`
				})
			},
		},
	}
</script>

<style scoped lang="scss">

	.bg {
		width: 100%;
		height: 376rpx;
		background: linear-gradient(164deg, #014FA2 30%, #4C8FD6);
	}

	.main {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		padding: 174rpx 30rpx 0 30rpx;
    box-sizing: border-box;
	}

	.swiper {
		border-radius: 10rpx;
		overflow: hidden;
	}

	.card {
		margin-top: 32rpx;
		justify-content: space-between;
		min-height: 803rpx;
		padding: 135rpx 0 55rpx 0;
		box-sizing: border-box;
		background: linear-gradient(rgba($color: #FCFDFE, $alpha: 0.93), rgba($color: #FCFDFE, $alpha: 0.93) 180rpx, rgba($color: #3381D4, $alpha: 0.43));
		border-radius: 25rpx;
		border: 3rpx solid #FFFFFF;
		box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16); 

		.title {
			font-size: 32rpx;
			font-weight: 600;
			color: #000000;
		}

		.icon {
			margin: 99rpx 0 86rpx;
			width: 285rpx;
			height: auto;
		}
		
		.btn {
			padding: 20rpx 212rpx;
			font-size: 30rpx;
			white-space: nowrap;
			color: #FFFFFF;
	    line-height: 1.4;
			background: #014FA2;
			border-radius: 42rpx;
		}
	}

</style>