<template>
	<view>
		<image src="@/static/bg.png" mode="widthFix" class="bg" style="width: 100%;height: 928rpx;"></image>
		<view class="top" :style="{'padding-top': top+'px'}">
			<view class="xuzou">
				<text class="title" style="margin-left: 25rpx;">我的</text>
			</view>
			<image src="@/static/bg.png" mode="widthFix" class="hs"></image>
		</view>
		<view class="content" :style="{'top': (top+44)+'px'}">
			<view class="mendian" @click="gengx">
				<image class="img" :src="userxixin.avatar?userxixin.avatar:avatar" mode=""></image>
				<view class="xinxi" v-if="userxixin.mobile">
					<view class="">{{userxixin.nickname?userxixin.nickname:'微信用户'}}</view>
					<view class="">{{userxixin.mobile?userxixin.mobile:'暂无手机号'}}</view>
				</view>
				<view class="xinxi" v-else>
					<view class=""style="text-align: left;">登录</view>
				</view>
				<view class="renlbtn" v-if="userxixin.mobile" @click.stop="face(userxixin.face_id)">{{userxixin.face_id!=0?'已认证':'人脸录入'}}</view>
			</view>
			<view class="huiy" v-if="viplist.length>0">
				<view class="" v-for="(item,index) in viplist" :key="index" style="height: 223rpx;">
					<image class="huiyimg" src="@/static/hbg.png" mode=""></image>
					<view class="huiybox">
						<image class="huiyboximg" src="@/static/huangguan.png" mode=""></image>
						<view class="huiywz">会员套餐<text style="float: right; font-weight: normal;  font-size: 26rpx; margin-right: 50rpx;">{{item.status_name}}</text></view>
					</view>
					<view class="huiyxx">
						<view class="">{{item.card_name}}
							<text v-if="item.card_type!==2">{{item.validity_day}}天</text>
						</view>
						<view class="" v-if="item.card_type==2">{{item.validity_num}}次</view>
						<view class="" v-else>
							<text v-if='item.validity_date'>
								到期时间：{{item.validity_date}}
							</text>
						</view>
					</view>
				</view>
			</view>
			<template v-else>
				<view class="huiy" v-if="!userxixin.mobile" @click="face()">
					<image class="huiyimg" src="@/static/hbg.png" mode=""></image>
					<view class="huiybox">
						<image class="huiyboximg" src="@/static/huangguan.png" mode=""></image>
						<view class="huiywz">会员套餐</view>
					</view>
					<view class="huiyxx">
						<view class="">9.9元套餐
							<text>7天</text>
						</view>
					</view>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userxixin: {},
				avatar: require("@/static/logo.png"),
				viplist: [],
				top: 0
			}
		},
		onLoad() {
			this.top = uni.getSystemInfoSync().statusBarHeight
		},
		onShow() {
			if(uni.getStorageSync("token")){
				this.memberInfo()
			}else{
				this.userxixin={}
			}
		},
		onShareAppMessage() {
			 return {
			      title: '运动湾24小时健身',
			      path: '/pages/uesr/index'
			    }
		},
		methods: {
			chooseAvatar(e) {
				console.log(123, e);
			},

			gengx() {
				if(!uni.getStorageSync("token")) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return ;
				}
				uni.navigateTo({
					url: "/pages/user/portrait/portrait"
				})
			},
			memberInfo() {
				this.$api.memberInfo().then(res => {
					this.userxixin = res.data
				})
				this.memberCardList()
			},
			memberCardList(page) {
				this.$api.memberCardList(page).then(res => {
					this.viplist = res.data.list;
				})
			},
			previous() {
				uni.navigateBack()
			},
			face(face_id) {
				if(!uni.getStorageSync("token")) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return ;
				}
				if (face_id != 0) {
					uni.showToast({
						icon: "none",
						title: '人脸已认证',
						duration: 3000
					});
				} else {
					uni.navigateTo({
						url: "/pages/face/face"
					})
				}

			}
		}
	}
</script>

<style scoped>
	
	.bg{
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		z-index: 1;
		background: #f5f5f5;
	}
	.content{
		width: 100%;
		position: relative;
		left: 0;
		top: 0;
		z-index: 2;
	}
	.top {
		width: 100%;
		left: 0;
		z-index: 22;
		top: 0;
		height: 88rpx;
		overflow: hidden;
		position: fixed;
	}
	.top .xuzou{
		width: 100%;
		height: 88rpx;
		display: flex;
		position: fixed;
		align-items: center;
		position: relative;
		z-index: 23;
	}
	.top .hs{
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		z-index: 1;
	}
	.huiybox {
		display: flex;
		margin-left: 50rpx;
		position: relative;
		top: -200rpx;
		font-family: PingFang SC;
		align-items: center;
		font-weight: bold;
		font-size: 34rpx;
		color: #E7CAAD;
	}

	.huiywz {
		margin-left: 22rpx;
		margin-top: 10rpx;
		flex: 1;
	}

	.huiyxx {
		display: flex;
		justify-content: space-between;
		margin-left: 50rpx;
		margin-right: 50rpx;
		margin-top: 41rpx;
		position: relative;
		top: -200rpx;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 30rpx;
		color: #E7CAAD;

	}

	.huiyboximg {
		width: 70rpx;
		height: 55rpx;
	}

	.huiy {
		padding: 0 25rpx 25rpx;
		overflow: hidden;
	}

	.huiyimg {
		width: 722rpx;
		height: 230rpx;

	}

	.img {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;
	}

	.xinxi {
		margin-left: 26rpx;
		width: 365rpx;
	}

	.renlbtn {
		width: 200rpx;
		height: 80rpx;
		background: #F8A617;
		box-shadow: 0rpx 4rpx 13rpx 0rpx rgba(19, 14, 4, 0.14);
		border-radius: 40rpx;
		text-align: center;
		line-height: 80rpx;
		font-family: PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
	}

	.title {
		padding-left: 14rpx;
	}

	.mddz1img2 {
		width: 44rpx;
		height: 44rpx;
		float: right;
	}

	.mddz2 {
		margin-top: 32rpx;
	}

	.dz {
		margin-left: 17rpx;
	}

	.mddz1img1 {
		width: 22rpx;
		height: 27rpx;
	}

	.mddz1 {
		display: flex;
	}

	.mddz1img {
		width: 60rpx;
		height: 60rpx;
	}

	.mddz1wz {
		font-family: PingFang SC;
		font-weight: bold;
		font-size: 30rpx;
		color: #222222;
		margin-left: 21rpx;
		margin-top: 12rpx;
	}

	.mddz {
		width: 680rpx;
		height: 152rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 3rpx 9rpx 0rpx rgba(19, 14, 4, 0.08);
		border-radius: 20rpx;
		margin-top: 24rpx;
		padding: 20rpx 17rpx;
	}

	.mendian {
		padding: 40rpx 25rpx 20rpx;
		display: flex;
		align-items: center;
		overflow: hidden;
	}
</style>