<template>
	<view class="container">
		<view>
			<view class="popular">
				<view class="all_top">
					<view class="title">
						全部遊戲
					</view>
					<view class="filter" @click="show = true">
						篩選
					</view>
				</view>
				<scroll-view scroll-y="true" style="height: 97%;">
					<view class="accountnum">
						<view class="numberitem" v-for="(item,index) in accountList" :key="index" @click="toaccountdetails(item)">
							<view class="n_img">
								<image :src="BASE_URL + item.img" mode=""></image>
							</view>
							<view class="n_tit">
								{{item.type_cn}}
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>
		<!-- p[opu[]] -->
		<u-popup :show="show" mode="bottom" @close="close" round="10" :closeable="true">
			<view style="min-height: 330rpx; padding: 30rpx;">
					<view class="accounts">遊戲類型</view>
					<view class="type">
						<view 
							class="titem"
							v-for="(item,index) in gamesList" :key="index"
							@click="toItemType(item)"
						>
							{{ item.tag_cn }}
						</view>
					</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
    import { BASE_URL } from '@/request/config.js'
    import {_getpubaccount,_getaccounttype,_getaccounttag} from "@/request/api.js"

	export default {
		data() {
			return {
                BASE_URL,
				show: false,
                gamesList:[],
				accountList:[]
			};
		},
        mounted() {
			this.getAccountype("");
			this.getGamesType();
        },
		methods: {
			async getAccountype(type){
				let res = await _getaccounttype({tag_cn:type});
				if(res.code === 1){
					this.accountList = res.data;
				}
			}, 
			async getGamesType(){
				let res = await _getaccounttag();
				if(res.code === 1){
					this.gamesList = res.data;
				}
			},
			toItemType(item){
				this.getAccountype(item.tag_cn);
				this.show = false
			},
			close() {
				this.show = false
			},
			toaccountdetails(data) {
				uni.navigateTo({
					url: '/pages/game/accounttrading?type=' + data.type_cn
				})
			}
		}
	}
</script>

<style lang="scss">
	.container {
		border-top: 1px solid dimgrey;
		width: 100vw;
		min-height: 100vh;
		padding: 10px;
		box-sizing: border-box;
		background: linear-gradient(to bottom, #000033, #51599b);

		image {
			width: 100%;
			height: 100%;
			border-radius: 20rpx;
		}

		.popular {
			background-color: #383d84;
			padding: 30rpx;
			border-radius: 20rpx;
			height: 90vh;
			color: #fff;
			width: 100%;
			box-sizing: border-box;

			.all_top {
				display: flex;
				justify-content: space-between;
			}

			.title {
				border-bottom: 1rpx solid #41468d;
				margin-bottom: 20rpx;
			}
			.p_top {
				display: flex;
				align-items: center;
				justify-content: space-between;
				background-color: #fdf7f2;
				width: 100%;
				height: 60rpx;
				font-size: 28rpx;
				border-radius: 20rpx;
				margin-bottom: 30rpx;
				padding: 0 20rpx;
				box-sizing: border-box;

				.tit {
					color: #EAA97D;
					font-size: 24rpx;
				}
			}

			.accountnum {
				display: flex;
				flex-wrap: wrap;
				border-top: 1rpx solid #41468d;
				padding-top: 30rpx;

				//xinjia
				.numberitem {
					width: calc(100% / 3);
					height: 200rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					margin-bottom: 20rpx;
					.n_img{
						height: calc(100% - 60rpx);
						width: 90%;
					}
					.n_tit{
						height: 60rpx;
						line-height: 60rpx;
					}
				}
			}
		}

		.accounts {
			width: 100%;
			font-size: 34rpx;
			border-bottom: 2rpx solid #f6f6f6;
			padding-bottom: 15rpx;
		}

		.type {
			display: flex;
			margin: 40rpx;
			flex-wrap: wrap;
			justify-content: flex-start;

			.titem {
				padding: 0 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				background-color: #4f5ad8;
				color: #fff;
				border-radius: 30rpx;
			}
		}
	}
</style>