<template>
	<!-- title="我的" -->
	<view class="full-container">
		<uni-nav-bar id="nav-bar" status-bar="true"  @clickLeft="onBack()"
		  color="#000000" fixed="true" :border="false">
			<!-- <view slot="left">
				<view class=" flex align-center margin-left">
					<image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
				</view>
			</view> -->
			<view slot="right">
				<!-- <view class="flex justify-center align-center"
					style="margin-left: 220rpx; ">
					<view class="flex align-center" style="margin-right: 40rpx; padding: 0 18px; height: 56rpx; background-color: rgba(183,183,183,0.33); border-radius: 13.5px;">
						<image class="png-more" style="margin-right: 16rpx;"
							src="/static/common/sideBar/sGold.png"></image>
						<view class="text-14px" style="line-height: 28rpx;">{{cGold}}</view>
					</view>
					<view class="flex  align-center" style="padding: 0 18px; height: 56rpx; background-color: rgba(183,183,183,0.33); border-radius: 13.5px;">
						<image class="png-more" style="margin-right: 16rpx; "
							src="/static/common/sideBar/sDiamond.png"></image>
						<view  class="text-14px" style="line-height: 28rpx;">{{cDiamond}}</view>
					</view>
				</view> -->
				
				<view class="flex justify-center align-center" style="margin-right: 400rpx;">
					<view class="flex align-center justify-between"
						style="margin-right: 40rpx; padding: 0 16rpx; height: 56rpx; background-color: rgba(183,183,183,0.33); border-radius: 13.5px;">
						<image class="png-more" style="margin-right: 16rpx;"
							src="/static/common/sideBar/sGold.png">
						</image>
						<view class="text-15px text-center" style="line-height: 56rpx; min-width: 100rpx;">{{cGold}}</view>
					</view>
					<view class="flex align-center justify-between"
						style="padding: 0 16rpx; height: 56rpx; background-color: rgba(183,183,183,0.33); border-radius: 13.5px;">
						<image  style="margin-right: 16rpx; width: 38rpx; height: 34rpx; "
							src="/static/common/sideBar/sDiamond.png">
						</image>
						<view class="text-15px text-center" style="line-height: 56rpx; min-width: 100rpx;">{{cDiamond}}</view>
					</view>
				</view>
			</view>
		
		</uni-nav-bar>
		<!-- <view class="cu-bar ">
			<view class="action">
			</view>
			<view class="action">
				<text class="text-df text-purple" @tap="onNavUser">编辑</text>
			</view>
		</view> -->
		<image class="bg-image" src="../../../static/loginBg.png" mode="aspectFill"></image>
		
		<scroll-view  :style="{ height: scrollviewHight + 'px' }" scroll-y="true">
			<view class="card-view flex align-center " style="position: relative; margin-top: 113px;">
				<view class="avatar-size">
					<image class="avatar-img round" :src="avatarUrl"></image>
				</view>
				<view class="avatar-group text-upload">
					<view class="text-lg flex justify-between align-center justify-center">
						<text class="text-black text-bold">{{userName}}</text>
						<view style="width: 126rpx;height: 50rpx; position: relative;" class="flex align-center justify-center" >
							<image style="height: 50rpx; width: 100%;" src="/static/bg-days.png"></image>
							<text class="text-white text-13px" style="line-height: 50rpx; position: absolute;top: 3rpx;right: 10rpx;">{{days}}天</text>
						</view>
					</view>
					<!-- <view class="text-xs padding-top">
						<text class="text-black">{{days}}</text>
					</view> -->
					<view class="text-gray padding-top">{{signature}}</view>
				</view>
			
				<view class="only-arrow" @tap="onNavUser"></view>
			
			</view>
			
			<view class="card-view flex align-center " style="position: relative; height: 132rpx; margin-top: 8px;">
				<image class="achievement-img round" src="../../../static/achievement/11-07@2x.png"></image>
				<view class="text-lg flex justify-between align-center justify-center">
					<text class="text-gray text-14px">我的成就</text>
				</view>
				<view class="only-arrow" @tap="onNavAchievement"></view>
			
			</view>
			<!-- 上线华为 隐藏 -->
			<view v-if="versionCodeState.showGame" class="card-view article ">
				<view class="title">
					最近在玩
				</view>
				<view class="cu-item shadow">
					<view class="cu-form-group margin-top">
						<view v-if="playGames.length!=0" class="grid col-3 homepage-grid-square flex-sub ">
							<view v-for="(item,index) in playGames" :key="index" v-if="index<6" @tap="onViewImage(item)">
								<image class="item-img" :src="item.gameIcon" mode="aspectFill"></image>
								<view class="border text-center text-cut">{{item.gameName}}</view>
							</view>
						</view>
						<view v-else class="text-center text-gray" :style="{width:'100%'}">去玩吧~</view>
						<view v-if="playGames.length!=0" class="homepage-arrow" @tap="onNavList('recently')"></view>
					</view>
				</view>
			</view>
			<!-- 上线华为 隐藏 -->
			<block v-if="versionCodeState.showVideo">
				<view v-if="favoriteGames.length==0" class="card-view flex align-center">
					<view class="content flex flex-direction align-start margin-top">
						<view class="title">关注</view>
						<view class="text-grey" style="margin: 0rpx 40rpx 40rpx;">有好多好玩的视频等着你关注哦</view>
					</view>
					<view class=" margin-sm button-fav " @tap="onGoToFollow">
						<image style="width: 21px;height: 21px; margin-right: 12rpx;" src="../../../static/add_w.png"></image>
						去关注
					</view>
				</view>
				<view v-else class="card-view article">
					<view class="title">
						已关注的
					</view>
					<view class="cu-item shadow">
						<view class="cu-form-group margin-top">
							<view v-if="favoriteGames.length!=0" class="grid col-3 homepage-grid-square flex-sub ">
								<view  class="text-center "  v-for="(item,index) in favoriteGames" :key="index" v-if="index<6" @tap="onViewImage(item)">
									<image class="item-img" :src="item.gameIcon" mode="aspectFill"></image>
									<view class="border text-cut">{{item.gameName}}</view>
								</view>
							</view>
							<view v-else class="text-center text-gray" :style="{width:'100%'}">去关注更多的游戏吧~</view>
							<view v-if="favoriteGames.length!=0" class="homepage-arrow" @tap="onNavList('watchGame')"></view>
						</view>
					</view>
				</view>
				
			</block>
			
			<view class="homepage-action-row">
				<view class=" ">哔蹦</view>
				<view class="text-bold text-decoration" style="
			color: #007AFF; border-bottom: solid 1rpx #007AFF;" @tap="onSwitchAgree('agreement')">用户协议</view>
				<view class=" ">和</view>
				<view class="text-bold text-decoration" style="
			color: #007AFF; border-bottom: solid 1rpx #007AFF;" @tap="onSwitchAgree('privacy')">隐私政策</view>
			</view>
		</scroll-view>
		
		
	</view>
</template>

<script>
	import config from '../../../common/config.js';
	import reqUtil from "@/util/util-js/requstUtil.js";
	import {
		mapState
	} from 'vuex'

	export default {
		computed: mapState(['forcedLogin', 'hasLogin', 'userName', 'avatarUrl', 'playGames', 'favoriteGames', 'days',
			'signature','platform','gamePlatform','cGold','cDiamond',
			'systemInfo','navHeight','tabbarHeight','versionCodeState'
		]),
		data() {
			return {
				scrollviewHight:0
			}
		},
		onLoad() {
			let that = this;
			reqUtil.requestData(config.URL.RECENTLYPLAYINGGETBYPLATFORM).then(res => {
					console.log('RECENTLYPLAYINGGETBYPLATFORM =====', res);
					if (res.code == 0) {
						that.$store.state.playGames = res.data.gameList;
					}

				},
				e => {
					console.log(e)
				});

			reqUtil.requestData(config.URL.FAVORITESGETBYPLATFORM).then(res => {
					console.log('FAVORITESGETBYPLATFORM =====', res);
					if (res.code == 0) {
						that.$store.state.favoriteGames = res.data.gameList;
					}

				},
				e => {
					console.log(e)
				});
		},
		onReady() {
			let phoneHeight = this.systemInfo.windowHeight;
			// 计算组件的高度
			this.scrollviewHight = phoneHeight - this.navHeight - this.tabbarHeight - this.systemInfo.statusBarHeight;
		},
		methods: {
			onViewImage(item) {
				let temItem = encodeURIComponent(JSON.stringify(item));
				uni.navigateTo({
					url: "../../game-page/game-detail/game-detail?item=" + temItem
				})
			},
			onNavUser() {
				uni.navigateTo({
					url: '../userInfo/userInfo'
				});
			},
			onNavAchievement(){
				uni.navigateTo({
					url: '../achievement/achievement'
				});
			},
			onNavList(type) {
				if (type == "recently" && this.playGames.length == 0) {
					uni.showModal({
						title: "提示",
						content: "没有最近在玩的游戏数据"
					})
					return;
				} else if (type == "watchGame" && this.favoriteGames.length == 0) {
					uni.showModal({
						title: "提示",
						content: "没有关注的游戏数据"
					})
					return;
				}


				uni.navigateTo({
					url: '../../personal-page/list/list?type='+type
				});
			},
			onGoToFollow() {
				// uni.showModal({
				// 	title: "提示",
				// 	content: "功能尚未开放"
				// })
				uni.switchTab({
					url: '../../game-page/game-video/game-video'
				});
			},
			onBack(){
				uni.navigateBack({
					delta:1
				})
			},
			onSwitchAgree(data) {
				uni.navigateTo({
					url: "../../login-page/userAgreement/userAgreement?type=" + data
				})
			},
		}
	}
</script>

<style>
	.avatar-group {
		display: flex;
		flex-direction: column;
		/* justify-content: center; */
		/* align-items: center; */
		text-align: start;
		background-color: #FFFFFF;
		display: block;
		border-radius: 10rpx;
		margin: 0 54rpx 0 30rpx;
		width: 100%;
	}


	.avatar-size {
		position: relative;
		margin-left: 47rpx;
		width: 140rpx;
		height: 140rpx;
		flex-shrink: 0;
	}

	.avatar-img {
		position: absolute;
		top: 0px;
		left: 0;
		width: 140rpx;
		height: 140rpx;
	}
	
	.achievement-img{
		margin: 0 26rpx 0 46rpx;
		width: 82rpx;
		height: 82rpx;
	}

	.text-upload {
		font-size: 13px;
		color: rgba(166, 166, 166, 1);
		padding: 40px 35rpx 40px 0;
	}

	.homepage-grid-square {
		width: 250rpx;
		/* height: 250rpx; */
		align-items: start;

	}

	.homepage-grid-square image {
		width: 176rpx;
		height: 176rpx;
	}

	.homepage-arrow {
		position: relative;
		width: 35rpx;
	}

	.homepage-arrow::before {
		position: absolute;
		top: 0;
		right: 0upx;
		bottom: 0;
		display: block;
		margin: auto;
		width: 30upx;
		height: 30upx;
		color: #8799a3;
		content: "\e6a3";
		text-align: center;
		font-size: 34upx;
		font-family: cuIcon;
		line-height: 30upx
	}

	.button-fav {
		background-color: rgba(153, 150, 252, 255);
		color: #FFFFFF;
		border-radius: 10px;
		width: 184rpx;
		height: 90rpx;
		display: flex;
		justify-content: center;
		text-align: center;
		align-items: center;
	}

	.title {
		text-align: justify;
		/* padding: 40rpx 30rpx; */
		font-size: 15px;
		position: relative;
		height: 30px;
		line-height: 60upx;
		margin: 20rpx 40rpx;
		font-weight: 400;
		color: rgba(26, 26, 26, 1);
	}

	.bg-image {
		position: fixed;
		top: 46px;
		left: 0;
		width: 100%;
		height: 164px;
		opacity: 1;
	}
	
	.border{
		width: 176rpx;
		font-size: 30rpx;
		color:rgba(175, 175, 175, 1);
		font-weight: 400;
		text-align: center;
		margin-top: 22rpx;
		margin-bottom: 40rpx;
	}
	
	.item-img{
		border-radius: 20rpx;
		/* border: 1rpx solid #EEEEEE; */
		box-shadow: 0px 1px 2px 0px rgba(113, 113, 219, 0.23);
	}
	
	.homepage-action-row{
		margin-top: 25px;
		display: flex;
		flex-direction: row;
		justify-content: center;
		padding: 20px;
	}
</style>
