<template>
	<view class="">
		<view class="flex center-box ">
			<view class="flex center-item" @click="navto('/pages/user/xzdl?type=2')">
				<view class="val">
					1000
				</view>
				<view class="name">我的消费包</view>
			</view>
			<view class="line">
			</view>
			<view class="flex center-item" @click="navto('/pages/user/xzdl?type=1')">
				<view class="val">
					1000
				</view>
				<view class="name">我的共富值</view>
			</view>
			<view class="line">
			</view>
			<view class="flex center-item" @click="toTx">
				<view class="val">
					1000
				</view>
				<view class="name">我的通证</view>
			</view>
		</view>
		<view class="flex banne">
			<image src="../../static/img/zjf.png" mode="" @click="navto('/pages/zero/task')"></image>
			<image src="../../static/img/yj.png" mode="" @click="navto('/pages/zero/task')"></image>
		</view>
		<view class="flex nav">
			<view class="nav-item" v-for="(item,index) in navList" :class="{'action': current == index}"
				@click="changeTab(index)">
				{{item.tit}}
			</view>
		</view>
		<swiper disable-touch :current="current"  class="list-wrap" :style="{'height': maxHeight}">
			<swiper-item :style="{'height': maxHeight}" v-for="item in navList">
				<scroll-view scroll-y="true"  class="" :style="{'height': maxHeight}">
					<view class="card-wrap flex" v-for="item in 10">
						<image src="" mode="" class="card-img"></image>
						<view class="flex card-info">
							<view class="name clamp2">
								普通卡
							</view>
							<view class="">
								价值1持包值
							</view>
							<view class="price">
								<image src="../../static/icon/ydjf.png" mode=""></image>
								<text>100</text> 阅读积分
							</view>
						</view>
						<view class="card-btn">
							立即兑换
						</view>
					</view>
					<uni-load-more :status="item.loadingType"></uni-load-more>
				</scroll-view>
			</swiper-item>
		</swiper>
		
	</view>
</template>

<script>
	import {
		saveUrl,
		interceptor
	} from '@/utils/loginUtils.js';
	import {
		getUserInfo,
		userPool,
		goft
	} from '@/api/user.js';
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				maxHeight: '',
				current: 0,
				navList: [{
						tit: '消费包',
						list: [],
						loadingType: 'more',
						loaded: false,
						page: 1,
						limit: 10,
					},
					{
						tit: '阅读积分交易',
						list: [],
						loadingType: 'more',
						loaded: false,
						page: 1,
						limit: 10,
					}
				]
			}
		},
		onLoad() {

		},
		onShow() {

		},
		computed: {
			...mapState('user',['userInfo','hasLogin'])
		},
		onReady(res) {
			var that = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.list-wrap').boundingClientRect();
					query.exec(function(res) {
						that.maxHeight = resu.windowHeight - res[0].top + 'px';
						console.log(that.maxHeight);
					});
				},
				fail: res => {}
			});
			
		},
		methods: {
			changeTab(index) {
				this.current = index
				this.getList('tab')
			},
			getList(type) {

			},
			navto(url) {
				
				if (!this.hasLogin) {
					// 保存地址
					saveUrl();
					// 登录拦截
					interceptor();
				} else {
					uni.navigateTo({
						url,
						 fail() {
						 	uni.switchTab({
						 		url
						 	})
						 }
					})
				}
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	.center-box {
		width: 693rpx;
		height: 152rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
		border-radius: 20rpx;
		margin: 0 auto;
		font-size: 30rpx;
		font-weight: bold;
		color: #333333;

		.center-item {
			flex-grow: 1;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.val {
				font-size: 38rpx;
				font-weight: bold;
				color: #333333;
			}

			.name {
				padding-top: 10rpx;
			}
		}

		.line {
			width: 2rpx;
			height: 74rpx;
			background: #eff1f5;
		}
	}

	.banne {
		justify-content: center;
		padding: 20rpx 0;

		image {
			width: 340rpx;
			height: 204rpx;
			margin: 0 8rpx;
		}
	}

	.nav {
		padding: 30rpx 0;

		.nav-item {
			flex-grow: 1;
			text-align: center;
			font-size: 34rpx;
			font-weight: bold;
			color: #333333;
		}

		.action {
			color: #FF4C4C;
		}
	}
	.list-wrap {
		// background-color: red;
		.card-wrap {
			width: 690rpx;
			height: 197rpx;
			background: #FFFFFF;
			border-radius: 10rpx;
			margin: 0 auto 20rpx;
			padding: 20rpx;
			justify-content: flex-start;
			.card-img {
				flex-shrink: 0;
				width: 158rpx;
				height: 158rpx;
				background-color: #eee;
				margin-right: 20rpx;
			}
			.card-info {
				flex-grow: 1;
				font-size: 24rpx;
				font-weight: 500;
				height: 100%;
				color: #999999;
				flex-direction: column;
				justify-content: space-between;
				align-items: flex-start;
				
				.name {
					font-size: 32rpx;
					font-weight: bold;
					color: #333333;
				}
				.price {
					font-size: 20rpx;
					font-weight: 500;
					color: #FC4141;
					line-height: 35rpx;
					image {
						width: 34rpx;
						height: 33rpx;
						vertical-align:bottom;
					}
					text {
						font-size: 36rpx;
						font-weight: bold;
						color: #FC4141;
						vertical-align:bottom;
						padding: 0 5rpx;
					}
				}
			}
			.card-btn {
				flex-shrink: 0;
				width: 137rpx;
				height: 52rpx;
				background: #ff4c4c;
				border-radius: 26rpx;
				font-size: 26rpx;
				font-weight: 500;
				color: #FFFFFF;
				text-align: center;
				line-height: 50rpx;
				align-self: flex-end;
			}
		}
	}
</style>