<template>
	<view class="container">
		<view class="topNav">
			<view class="hgHeight">
				
			</view>
			<view class="flex">
			<view class="titleItem" @click="tabList(0)" :class="{action:onIndex==0}">
				我的盲盒
			</view>
			<view class="titleItem" @click="tabList(1)" :class="{action:onIndex==1}">
				NFT合成
			</view>
			</view>
		</view>
		<!-- 我的盲盒 -->
		<view class="ls" v-show="onIndex==0">
			<view class="ll" v-for="(item,index) in mh.list">
				<!-- <image class="imgBox" src="" mode="scaleToFill"></image> -->
				<view class="title clamp margin-t-20">
					盲盒首发
				</view>
				<view class="tip flex margin-t-10">
					<view class="clamp">官方发行</view>
					<view class="buttom" @click="navTo(item)">打开</view>
				</view>
			</view>
			<u-loadmore class='clearFloat' lineColor='#FFFFFF' iconColor='#FFFFFF' color="#FFFFFF" :status="mh.loadingType" />
		</view>
		<!-- NFT合成 -->
		<view class="ls" v-show="onIndex==1">
			<u-loadmore class='clearFloat' lineColor='#FFFFFF' iconColor='#FFFFFF' color="#FFFFFF" :status="nft.loadingType" />
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	// #ifdef H5
	import {
		weixindata
	} from '@/utils/wxAuthorized';
	// #endif
	export default {
		data() {
			return {
				onIndex: 0, //当前选中的分类
				// 盲盒里诶啊哦
				mh: {
					page: 1,
					limit: 10,
					list: [{}, {}, {}, {}],
					loaded: false,
					loadingType: 'loadmore'
				},
				// nft合成列表
				nft: {
					page: 1,
					limit: 10,
					list: [],
					loaded: false,
					loadingType: 'loadmore'
				}
			};
		},
		computed: {
			...mapState(['loginInterceptor', 'baseURL']),
			...mapState('user', ['hasLogin', 'userInfo'])
		},
		onLoad: function(option) {},
		methods: {
			info() {

			},
			tabList(index) {
				// 保存当前选中的对象
				this.onIndex = index;
			},
			// 加载盲盒
			lodingMh(source) {
				let navItem = this.mh.list;
				if (source === 'tabChange' && navItem.loaded === true) {
					//tab切换只有第一次需要加载数据
					return;
				}
				if (navItem.loadingType === 'loading') {
					//防止重复加载
					return;
				}
				// 修改当前对象状态为加载中
				navItem.loadingType = 'loading';
				cashList({
						page: navItem.page,
						limit: navItem.limit,
						pm: state
					})
					.then(({
						data
					}) => {
						if (data.list.length > 0) {
							navItem.orderList = navItem.orderList.concat(data.list);
							navItem.page++;
						}
						if (navItem.limit == data.list.length) {
							//判断是否还有数据， 有改为 more， 没有改为noMore
							navItem.loadingType = 'loadmore';
							return;
						} else {
							//判断是否还有数据， 有改为 more， 没有改为noMore
							navItem.loadingType = 'nomore';
						}
						uni.hideLoading();
						navItem.loaded = true;
					})
					.catch(e => {
						console.log(e);
					});
			},
			navTo(url) {
				uni.switchTab({
					url
				})
			},
		}
	};
</script>

<style lang="scss">
	page {
		width: 750rpx;
		min-height: 100%;
		background: #111111;
	}

	.container {
		/* #ifdef APP */
		padding-top: var(--status-bar-height);
		/* #endif */
	}

	.topNav {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		z-index: 999;
		padding: 30rpx;
		background-color: #181820;
		.hgHeight{
			height: var(--status-bar-height);
		}
		.titleItem {
			width: 336rpx;
			height: 80rpx;
			border-radius: 10rpx;
			text-align: center;
			line-height: 80rpx;
			font-size: $font-base;
			color: #FFFFFF;
			border: 1px solid #FFFFFF;

			&.action {
				font-weight: bold;
				color: #9F570E;
				background: linear-gradient(270deg, #FFE7C4, #FFCE8A);
			}
		}
	}

	.ls {
		color: #FFFFFF;
		padding: 30rpx;
		padding-top: 140rpx;

		.clearFloat {
			clear: both;
		}
		.ll:nth-child(even) {
			margin-left: 30rpx;
		}

		.ll {
			width: 330rpx;
			line-height: 1;
			margin-bottom: 30rpx;
			float: left;

			.imgBox {
				background-color: #1D1D22;
				width: 330rpx;
				height: 330rpx;
			}

			.title {
				font-size: $font-sm;
			}

			.tip {
				font-size: $font-sm - 4rpx;

				.buttom {
					width: 98rpx;
					padding: 10rpx 0;
					text-align: center;
					background: linear-gradient(270deg, #FFE7C4, #FFCE8A);
					border-radius: 20rpx;
					color: #9F570E;
				}
			}

		}
	}
</style>
