<template>
	<view class="content">
		<view class="top-bg">

		</view>
		<view class="top-wrap">
			<view class="tit">
				·我的收益
			</view>
			<view class="val">
				{{userInfo.points || 0}}
			</view>
			<view class="">
				累计收益
			</view>
		</view>
		<view class="gg-wrap flex" v-for="(item,index) in ggInfo.day_video_count">
			<image src="../../static/icon/jiang.png" mode=""></image>
			<view class="gg-tit">
				<view class="tit">
					观看视频赚阅读积分
				</view>
				<view class="">
					观看可获得阅读积分
				</view>
			</view>
			<view class="gg-btn" :class="{pass: ggInfo.valid_bcount*1 > index}" @click="ggInfo.valid_bcount*1 > index? '': goLock(index)">
				{{ggInfo.valid_bcount*1 > index? '已观看': '去观看'}}
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';

	import {
		getGG,
		createGG
	} from '@/api/zero.js'
	import {
		getUserInfo,
		getLevelList
	} from '@/api/user.js';
	export default {
		data() {
			return {
				ggInfo: {},
				id: 0
			}
		},
		computed: {
			...mapState('user', ['userInfo', 'hasLogin'])
		},
		onLoad(opt) {
			this.id = opt.id
		},
		onShow() {
			this.loadBaseData()
			this.getGG()
		},
		onReachBottom() {

		},
		onReady() {

		},
		methods: {
			...mapMutations('user', ['setUserInfo']),
			loadBaseData() {
				const obj = this
				getUserInfo({})
					.then(({
						data
					}) => {
						obj.setUserInfo(data);
						// obj.getLevelList()
					})
					.catch(e => {
						console.log(e);
					});
			
			},
			getGG() {
				getGG().then(res => {
					console.log(res)
					this.ggInfo = res.data
				})
			},
			goLock() {
				createGG({
					ad_id: 0
				}).then(res => {
					uni.navigateTo({
						url: '/pages/zero/gg?id=' + res.data.id
					})
				})

			}
		}
	}
</script>

<style lang="scss" scoped>
	.top-bg {
		height: 210rpx;
		background-color: #f53935;
	}

	.top-wrap {
		width: 684rpx;
		height: 254rpx;
		background: linear-gradient(-70deg, #FF6362, #FF9465);
		box-shadow: 0rpx 11rpx 17rpx 4rpx rgba(255, 76, 76, 0.1);
		border-radius: 16rpx;
		margin: -180rpx auto 20rpx;
		text-align: center;
		font-size: 20rpx;
		font-weight: 500;
		color: #fff;
		padding: 30rpx;

		.tit {
			text-align: left;
			font-size: 28rpx;
			padding: 10rpx 0;
		}

		.val {
			padding-bottom: 15rpx;
			font-size: 80rpx;
			font-weight: bold;
		}
	}

	.gg-wrap {
		width: 660rpx;
		height: 140rpx;
		background: #FEFEFE;
		box-shadow: 0rpx 0rpx 29rpx 0rpx rgba(231, 71, 68, 0.09);
		border-radius: 4rpx;
		margin: 20rpx auto;
		padding: 30rpx 40rpx 40rpx 90rpx;
		position: relative;

		image {
			position: absolute;
			top: 0;
			left: 26rpx;
			width: 45rpx;
			height: 60rpx;

		}

		.gg-tit {
			font-size: 24rpx;
			font-weight: 500;
			color: #999999;

			.tit {
				padding-bottom: 20rpx;
				font-size: 32rpx;
				font-weight: bold;
				color: #333333;
			}
		}

		.gg-btn {
			width: 125rpx;
			height: 46rpx;
			background: linear-gradient(60deg, #FF8F3B, #FF3106);
			border-radius: 23rpx;
			font-size: 24rpx;
			font-weight: 500;
			color: #FFFFFF;
			text-align: center;
			line-height: 45rpx;
		}
	}

	.pass {
		background: #999 !important;
	}
</style>