<template>
	<view class="container" style="background-color: #F8F8F8;">
		<ourLoading isFullScreen :active="pageLoading" :text="pageLoadingText" />
		<image class="w-100" :src="fetch.config.home_top" mode="widthFix"></image>
		<view class="content">
			
			<!-- member card begin -->
			<view class="member-card">
				<view class="entrance" v-if="fetch.user.id <= 0">
					<view class="item" @tap="login">
						<view class="title">快速登录</view>
					</view>
				</view>
				
				<view class="info" v-if="fetch.user.id > 0" style="margin-top: -28rpx;">
					<image @tap="user" :src="fetch.user.avatar" class="avatar"></image>
					<view class="title" style="margin-left: 26rpx;margin-top: -40rpx;">
						<view class="wenyue-font" @tap="user">{{fetch.user.username}}</view>
						<view class="tips" @tap="user">
							<view v-if="fetch.user.title">{{fetch.user.title}}</view>
							<view v-if="!fetch.user.title">无头衔</view>
						</view>
					</view>
					<view class="badage" style="left:180rpx;bottom: 32rpx;word-break: break-all;overflow: auto;">
						<view v-if="fetch.user.info">{{fetch.user.info}}</view>
						<view v-if="!fetch.user.info">暂无签名</view>
					</view>
				</view>
				<view class="row">
					<view class="grid" v-for="(v, k) in fetch.row" :key="k">
						<view class="value">{{v.value}}</view>
						<view class="title">{{v.name}}</view>
					</view>
				</view>
			</view>
			<!-- member card end -->
			<!-- 星球播报 begin -->
			<view class="xinqiubobao member-news" style="display: none;">
				<view class="title">小记播报</view>
				<view class="list">
					<swiper class="item" autoplay :interval="3000" indicator-dots>
						<swiper-item v-for="(v, k) in fetch.xuanchuan" :key="k" @click="xuanchuan(v.link)">
							<view class="item">
								<image :src="v.pic"></image>
								<view class="title">{{v.name}}</view>
							</view>
						</swiper-item>
					</swiper>
					
				</view>
			</view>
			<!-- 星球播报 end -->
			<!-- 任务中心 begin -->
			<view class="task-center" @tap="taskCenter" style="display: none;">
				<view class="intro">
					<view class="title">任务中心</view>
					<view class="subtitle">MISSION CENTER</view>
				</view>
				<view class="image-wrapper">
					<image src="/static/images/my/b3d3a98e3c7f450aaa32fbec6aecdfaf.png"></image>
				</view>
			</view>
			<!-- 任务中心 end -->
		</view>
		<!-- 开通礼包 begin -->
		<view class="open-gift">
			<view class="header">
				<view class="title">我的道具</view>
				<view class="subtitle" @tap="openGift">规则</view>
			</view>
			<view class="row">
				<view class="grid">
					<image src="/static/images/my/member_benefits/me_rights_icon_free.png"></image>
					<view class="title">
						<view>置顶</view>
						<view class="number">x0</view>
					</view>
				</view>
				<view class="grid">
					<image src="/static/images/my/member_benefits/me_rights_icon_1jia1.png"></image>
					<view class="title">
						<view>买一赠一券</view>
						<view class="number">x1</view>
					</view>
				</view>
				<view class="grid">
					<image src="/static/images/my/member_benefits/me_rights_icon_2jia1.png"></image>
					<view class="title">
						<view>买二赠一券</view>
						<view class="number">x2</view>
					</view>
				</view>
				<view class="grid">
					<image src="/static/images/my/member_benefits/me_rights_icon_qingshi.png"></image>
					<view class="title">
						<view>喜茶轻食券</view>
						<view class="number">x2</view>
					</view>
				</view>
				<view class="grid">
					<image src="/static/images/my/member_benefits/me_rights_icon_youxian_new.png"></image>
					<view class="title">
						<view>优先券</view>
						<view class="number">x2</view>
					</view>
				</view>
				<view class="grid">
					<image src="/static/images/my/member_benefits/me_rights_icon_waimai_new.png"></image>
					<view class="title">
						<view>免运费券</view>
						<view class="number">x2</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 开通礼包 end -->
		
		<list-cell hover arrow @click="invite">
			<view class="list-cell-wrapper">
				<view view="title">我的身份</view>
				<view class="subtitle">不同的身份，不同的人生</view>
			</view>
		</list-cell>
		<list-cell hover arrow @click="invite">
			<view class="list-cell-wrapper">
				<view view="title">购物中心</view>
			</view>
		</list-cell>
		<list-cell hover arrow @click="invite">
			<view class="list-cell-wrapper">
				<view view="title">订单列表</view>
			</view>
		</list-cell>
		<list-cell hover arrow @click="invite">
			<view class="list-cell-wrapper">
				<view view="title">联系客服</view>
			</view>
		</list-cell>
		<list-cell hover arrow @click="invite">
			<view class="list-cell-wrapper">
				<view view="title">消息中心</view>
			</view>
		</list-cell>
		
		<dever-share ref="share" :data="fetch.share" v-if="fetch.share"></dever-share>
	</view>
</template>

<script>
	import deverShare from '@/lib/dever/components/share.vue';
	import listCell from '@/lib/list-cell/list-cell.vue'
	export default {
		components: {
			listCell,deverShare
		},
		data() {
			return {
				boardcast: [],
				fetch : {
					user : {},
					config : {
						home_top : '',
					},
					score : {},
					xuanchuan : [],
					share : false,
				},
			}
		},
		onShow() {
			this.getData();
		},
		// 重新加载
		onPullDownRefresh: function() {
			this.getData();
		},
		methods: {
			getData : function() {
				this.Dever.get(this, 'app/collection/?l=api.home', {id:-1});
			},
			view : function(id) {
				this.Dever.location('dream/index?id=' + id);
			},
			
			xuanchuan : function(link) {
				this.Dever.location(link);
			},
			
			login : function() {
				this.Dever.location('user/login');
			},
			
			jiyi : function() {
				this.Dever.alert('敬请期待');
			},
			
			user : function() {
				this.Dever.location('user/index');
			},
			
			invite : function() {
				this.Dever.alert('敬请期待');
			},
			
			openGift : function() {
				this.Dever.alert('敬请期待');
			}
		}
	}
</script>

<style lang="scss" scoped>
/* #ifdef H5 */
page {
	height: auto;
	min-height: 100%;
}
/* #endif */

.entrance {
	position: relative;
	margin-top: -80rpx;
	margin-bottom: 30rpx;
	border-radius: 10rpx;
	background-color: #ffffff;
	box-shadow: $box-shadow;
	padding: 30rpx 0;
	display: flex;
	align-items: center;
	justify-content: center;
	
	.item {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		position: relative;
		
		&:nth-child(1):after {
			content: '';
			position: absolute;
			width: 1rpx;
			background-color: #ddd;
			right: 0;
			height: 100%;
			transform: scaleX(0.5) scaleY(0.8);
		}
		
		.icon {
			width: 84rpx;
			height: 84rpx;
			margin: 20rpx;
		}
		
		.title {
			font-size: 30rpx;
			color: $text-color-base;
			font-weight: 600;
		}
	}
}

.content {
	/*padding: 0 30rpx;*/
}

.welcome {
	position: relative;
	margin-top: -136rpx;
	display: flex;
	flex-direction: column;
	font-size: $font-size-lg;
	color: $text-color-warning;
}

.member-card {
	background-color: $bg-color-white;
	padding: 20rpx;
	display: flex;
	flex-direction: column;
	border-radius: $border-radius-base;
	margin-bottom: 40rpx;
	
	.info {
		position: relative;
		margin-top: -50rpx;
		display: flex;
		align-items: center;
		position: relative;
		padding: 20rpx 0;
		border-bottom: 1rpx solid rgba($color: $border-color, $alpha: 0.3);
		
		.title {
			flex: 1;
			font-size: 40rpx;
			color: $text-color-base;
			display: flex;
			align-items: center;
		
			.tips {
				margin-left: 10rpx;
				font-size: $font-size-sm;
				color: $text-color-assist;
				background-color: #e9e9e9;
				padding: 10rpx 30rpx;
				border-radius: 50rem !important;
				display: flex;
				align-items: center;
				
				image {
					width: 20rpx;
					height: 20rpx;
				}
			}
		}
		
		.badage {
			font-family: 'neutra';
			position: absolute;
			bottom: 20rpx;
			left: 0;
			border: 2rpx solid $text-color-base;
			padding: 2rpx 20rpx;
			border-radius: $border-radius-lg;
			font-size: $font-size-base;
		}
	}
	
	.row {
		margin-top: $spacing-row-base;
		width: 100%;
		display: flex;
		align-items: center;

		.grid {
			flex: 1;
			flex-shrink: 0;
			display: flex;
			flex-direction: column;
			align-items: center;
			
			image {
				width: 100rpx;
				height: 100rpx;
			}
			
			.value {
				font-family: 'neutra';
				margin-bottom: $spacing-col-sm;
				font-size: $font-size-lg;
			}
			
			.title {
				font-size: $font-size-sm;
				color: $text-color-grey;
			}
		}
	}
}

.xinqiubobao {
	width: 100%;
	position: relative;
	
	.title {
		margin: 10rpx 0;
		font-size: $font-size-lg;
		font-weight: 500;
	}
	
	.swiper {
		height: 200rpx;
		margin-bottom: 10rpx;
		
		.swiper-item {
			
			.swiper-item-wrapper {
				display: flex;
				background-color: $bg-color-white;
				padding: 40rpx 60rpx;
				border-radius: $border-radius-base;
				align-items: center;
				margin-right: 40rpx;
				
				image {
					width: 100rpx;
					height: 100rpx;
					border-radius: 100%;
					margin-right: 20rpx;
				}
				
				.desc {
					display: flex;
					flex-direction: column;
					
					.title {
						font-size: $font-size-medium;
						font-weight: 500;
						margin-bottom: 10rpx;
					}
					
					.desc {
						font-size: $font-size-sm;
						color: $text-color-grey;
					}
				}
			}
		}
	}
}

.task-center {
	margin: 40rpx 0;
	background-color: $bg-color-white;
	padding: 10rpx 0;
	display: flex;
	align-items: center;
	border-radius: $border-radius-lg;
	
	.intro {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.title {
			font-size: $font-size-lg;
			color: $text-color-base;
		}
		.subtitle {
			font-family: 'neutra';
			font-size: $font-size-sm;
		}
	}
	
	.image-wrapper {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		
		image {
			width: 200rpx;
			height: 200rpx;
		}
	}
}

.open-gift {
	width: 100%;
	background-color: $bg-color-white;
	padding: 30rpx 40rpx;
	margin-bottom: 20rpx;
	
	.header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
		
		.title {
			font-size: $font-size-lg;
			font-weight: 500;
		}
		
		.subtitle {
			font-size: $font-size-base;
			color: $text-color-grey;
		}
	}
	
	.row {
		display: flex;
		flex-wrap: wrap;
		
		.grid {
			width: 33.3333%;
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 20rpx;
			
			image {
				width: 70rpx;
				height: 70rpx;
				margin-bottom: $spacing-row-base;
			}
			
			.title {
				font-size: $font-size-base;
				color: $text-color-base;
				display: flex;
				align-items: baseline;
				
				.number {
					margin-left: 5rpx;
					font-family: 'neutra';
					color: $color-warning;
				}
			}
		}
	}
}

.list-cell-wrapper {
	width: 100%;
	display: flex;
	justify-content: space-between;
	align-items: center;
	
	.title {
		font-size: $font-size-lg;
	}
	
	.subtitle {
		font-size: $font-size-sm;
		color: $text-color-assist;
	}
}
.member-news {
	width: 100%;
	margin-bottom: 30rpx;
	.header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 0;
		
		.title {
			font-size: $font-size-lg;
			font-weight: bold;
		}
		
		.iconfont {
			font-size: 52rpx;
			color: $text-color-assist;
		}
	}
	
	.list {
		width: 100%;
		display: flex;
		flex-direction: column;
		
		.item {
			width: 100%;
			height: 380rpx;
			position: relative;
			
			image {
				width: 100%;
				height: 100%;
				border-radius: 8rpx;
			}
			
			.title {
				position: relative;
				font-size: 32rpx;
				font-weight: 500;
				width: 100%;
				top: -70rpx;
				left: 16rpx;
				color: #ffffff;
			}
		}
	}
}
</style>
