<template>
	<view class="container">
		<view style="padding: 20rpx;">
			<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="gameitem" v-for="(item,index) in list" :key="index" @click="tostrateydetails(item)">
						<view class="g_img">
							<image :src="BASE_URL + item.img" mode=""></image>
						</view>
						<view class="g_rig">
							<view class="g_top">
								<view class="g_name">
									{{item.title_cn}}
								</view>
							</view>
							<view class="ga_cont">
								{{item.desc_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;box-sizing: border-box;">
				<!-- <view class="" v-for="(item,index) in 2" :key="index"> -->
					<view class="accounts">遊攻略類型</view>
					<view class="type">
						<view 
							class="titem"
							v-for="(item,index) in typeList" :key="index"
							@click="toItemType(item)"
						>
							{{ item.type_cn }}
						</view>
					</view>
				</view>
			<!-- </view> -->
		</u-popup>
	</view>
</template>

<script>
    import { BASE_URL } from '@/request/config.js'
    import { _getpubguide , _getpubtype } from "@/request/api.js"
	export default {
		data() {
			return {
                BASE_URL,
				show: false,
                typeList:[],
                list:[],
                page:1,
				listrow:99999
			};
		},
        async mounted() {
			this.getPubTypeList();
            this.loadData("","")
        },
		methods: {
			toItemType(item){
				this.loadData(item.type_cn,item.type_en);
				this.show = false
			},
			async getPubTypeList(){
				let res = await _getpubtype();
				if(res.code === 1){
					this.typeList = res.data;
				}
			},
            async loadData(type_cn,type_en){
             const res =  await _getpubguide({type_cn,type_en,page:this.page,listrow:this.listrow}) 
             this.list = res.data.data;
            },
			close() {
				this.show = false
			},
			tostrateydetails(item) {
				uni.navigateTo({
					url: '/pages/game/gamestrategydetails?id='+item.id
				})
			}
		}
	}
</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;
				border-bottom: 1rpx solid #41468d;
				margin-bottom: 20rpx;
			}

			.title {
				border-bottom: 1rpx solid #41468d;
				margin-bottom: 20rpx;
			}

			.filter {
				font-size: 22rpx;
			}

			.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;
				}
			}

			.gameitem {
				width: 100%;
				height: 160rpx;
				display: flex;
				padding: 1rpx;
				align-items: center;
				margin-bottom: 20rpx;

				.g_img {
					width: 150rpx;
					height: 150rpx;
					background-color: #51599b;
					border-radius: 20rpx;
				}

				.g_rig {
					flex: 1;
					padding: 1rpx;
					margin-left: 10rpx;
					display: flex;
					justify-content: space-between;
					flex-direction: column;

					.g_top {
						display: flex;
						justify-content: space-between;
						margin-bottom: 20rpx;

						.g_btn {
							width: 90rpx;
							height: 50rpx;
							background-color: #4f5ad6;
							display: flex;
							justify-content: center;
							align-items: center;
							border-radius: 40rpx;
							font-size: 26rpx;
						}
					}

					.ga_cont {
						font-size: 22rpx;
						color: #D7D8E6;
						display: -webkit-box;
						/* 将对象作为弹性伸缩盒子模型显示 */
						-webkit-box-orient: vertical;
						/* 从上到下垂直排列子元素 */
						-webkit-line-clamp: 2;
						/* 限制显示的行数为2行 */
						overflow: hidden;
						/* 溢出隐藏 */
						text-overflow: ellipsis;
					}
				}
			}
		}

		.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>