<template>
	<view class="memberCenter">
		<zs-header title="会员中心" :background="background"></zs-header>
		<view class="top-box target">
			<view class="user-info">
				<image class="image" :src="userInfo.imgPath || defaultImg" lazy-load mode=""></image>
				<view class="info">
					<view class="user-name">{{userInfo.nickname ||'用户'}}</view>
					<view class="tel">{{userInfo.phoneNum ||'您当前未开通会员'}}</view>
				</view>

			</view>

			<swiper @change="changeSwiper" :current="current" class="swiper" previous-margin="70rpx"
				next-margin="40rpx">
				<swiper-item class="swiper-item" v-for="(item,index) in list" :key="item">
					<view class="content" :class="[current == index?'active':'']">
						<view :style="{background:item.color}" v-if="userInfo.setMealId == index" class="tag">
							当前等级
						</view>
						<image class="icon" :src="item.url" mode=""></image>
						<view class="price" :style="{color:item.color}">
							{{`开通会员${item.price}/月`}}
						</view>
						<view class="notice" :style="{color:item.color}">
							开通会员预计节省 <text class="num">￥99元</text>
						</view>
					</view>
				</swiper-item>
			</swiper>

		</view>


		<view class="title-box">
			<view class="title">
				餐饮
			</view>
			<view class="desc">
				享受多达24种餐饮权益
			</view>
		</view>

		<u-grid :border="false" col="3">
			<u-grid-item v-for="(item,listIndex) in list1" :key="listIndex">
				<image class="icon" :src="item.icon" mode=""></image>
				<text class="title">{{item.title}}</text>
				<text class="desc">{{item.desc}}</text>
			</u-grid-item>
		</u-grid>
		
		
		<view class="title-box">
			<view class="title">
				娱乐
			</view>
			<view class="desc">
				享受多达24种娱乐权益
			</view>
		</view>
		
		<u-grid :border="false" col="3">
			<u-grid-item v-for="(item,listIndex) in list1" :key="listIndex">
				<image class="icon" :src="item.icon" mode=""></image>
				<text class="title">{{item.title}}</text>
				<text class="desc">{{item.desc}}</text>
			</u-grid-item>
		</u-grid>



		<view class="fixed-box">
			<view class="left-box">
				<image class="icon" src="../../static/phone.png" mode=""></image>
				<view class="info">
					<view class="tel">
						10086
					</view>
					<view class="desc">
						套餐咨询
					</view>
				</view>
			</view>
			<view class="btn">
				立即开通
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				background: false,
				defaultImg: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fci.xiaohongshu.com%2Fc34b7b74-ba38-0456-982a-43c0f97522fe%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fci.xiaohongshu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1693532127&t=a2e186c12aecaab7723611cb52a6778f',
				userInfo: {
					imgPath: "",
					isAuth: 1,
					lastLogin: "",
					nickname: "",
					openId: "",
					phoneNum: "",
					score: 0,
					setMealId: 0,
					sex: 1,
					userId: "",
				},
				list: [
					
					{
						url: 'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/VXjgNzREXaLm34375320879043fd01ef78548b828ff5.png/1.png',
						price: 10,
						color: '#8B97BC'
					},
					{
						url: 'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/lDVkXHSqADn3e2d4da72a4807077a435dcf58d1e3d9d.png/1.png',
						price: 10,
						color: '#3E5C91'
					},
					{
						url: 'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/DPFfUdNJ8gON5dded7da8e6b8447b2d3d6baaf07dc6d.png/1.png',
						price: 20,
						color: '#FF532A'
					},
					{
						url: 'http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/fbBsRJWDEGuB567f38e56cd936f4420701c00e7df8c4.png/1.png',
						price: 30,
						color: '#5488FF'
					}
				],
				list1:[
					{
						icon:"http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/QrH1JQHzmpa33b795d99f971897d53e94cea47ba18df.png/1.png",
						title:"7-Eleven",
						desc:"免费领取大额券",
					},
					{
						icon:"http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/zWIsNbwQcmQge4240fa235d866f75bbc322e1ef7756f.png/1.png",
						title:"麦当劳",
						desc:"免费领取5.5折优惠券",
					},
					{
						icon:"http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/MjZqLNBMHNtEfe0a7f6ac7120012b62b33138bab2e10.png/1.png",
						title:"星巴克",
						desc:"免费领取5.5折优惠券",
					},
					{
						icon:"http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/VZhjgXDiHKQgd2766fddc816dad7c6b9ac8021026b75.png/1.png",
						title:"瑞幸咖啡",
						desc:"免费领取5.5折优惠券",
					},
					{
						icon:"http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/QyMgjyjtcgW24aa6472ddcd269575c14f9eae02bd884.png/1.png",
						title:"海底捞",
						desc:"一元秒杀无限购",
					},
					{
						icon:"http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/7sZ1eKfRy10d2a01d9d6f15945535f8319a3a4fe28ea.png/1.png",
						title:"KFC",
						desc:"免费领取5.5折优惠券",
					},
					{
						icon:"http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/niFQ6Pcda58Sa6a4ace3d302fdd2eae6b3e4beef70a1.png/1.png",
						title:"汉堡王",
						desc:"免费领取5.5折优惠券",
					}
				]
			}
		},
		methods: {
			changeSwiper(val) {
				this.current = val.target.current
			}
		},
		onPageScroll(e) {
				if (e.scrollTop >= 50) {
					this.background = true
				} else {
					this.background = false
				}
		},
		created() {
			if(uni.getStorageSync('userInfo')) {
				this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
			}
			this.current = this.userInfo.setMealId 
		}
	}
</script>

<style lang="scss">
	.memberCenter {
		min-height: 100vh;
		background: #FFF;
		padding-bottom: 180rpx;
		.swiper {
			width: 750rpx !important;
			height: 272rpx !important;
			position: relative;
			left: -30rpx;
			top: 20rpx;
		}

		.swiper-item {
			width: 600rpx !important;
			height: 272rpx !important;
			position: relative;

			.active {
				transform: scale(1) !important;
			}

			.content {
				transform: scale(.9);
				transition: transform .3s;
				transform-origin: center center;

				.icon {
					width: 600rpx;
					height: 272rpx;
					border-radius: 16rpx;
				}


				.tag {
					width: 104rpx;
					height: 34rpx;
					line-height: 34rpx;
					text-align: center;
					font-size: 22rpx;
					color: #fff;
					border-radius: 16rpx 0rpx 16rpx 0rpx;
					position: absolute;
					top: 0%;
					left: 0;
					z-index: 2;
				}

				.price {
					font-size: 24rpx;
					position: absolute;
					left: 40rpx;
					top: 140rpx;
				}

				.notice {
					font-size: 24rpx;
					position: absolute;
					left: 40rpx;
					bottom: 40rpx;

					.num {
						font-weight: bold;
						font-size: 36rpx;
					}
				}
			}

		}


		.top-box {
			width: 750rpx;
			height: 600rpx;
			padding: 150rpx 30rpx 0;
			box-sizing: border-box;
			background: linear-gradient(180deg, #C0F3FE 0%, #F8F3FF 47%, #C3DEFF 80%, #FFFFFF 100%);
			position: relative;

			.user-info {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 15rpx 0;
				color: #222222;

				.image {
					width: 108rpx;
					height: 108rpx;
					background: #f1f1f1;
					border-radius: 50%;
				}

				.info {
					flex: 1;
					margin-left: 30rpx;

					.user-name {
						font-size: 32rpx;
						font-weight: bold;
						color: #222222;
					}

					.tel {
						font-size: 24rpx;
						margin-top: 10rpx;
						color: #AAAAAA;
					}
				}

			}
		}

		.title-box {
			display: flex;
			align-items: center;
			margin: 30rpx 30rpx 0;

			.title {
				color: #222222;
				font-weight: bold;
				font-size: 32rpx;
			}

			.desc {
				margin-left: 10rpx;
				font-size: 22rpx;
				color: #AAAAAA;
			}
		}
		
		.u-grid{
			.u-grid-item{
				padding-top:30rpx ;
			}
			.icon{
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
			}
			.title{
				font-size: 28rpx;
				color: #222222;
				margin-top: 10rpx;
			}
			.desc{
				color: #AAAAAA;
				font-size: 20rpx;
			}
		}

		.fixed-box {
			position: fixed;
			bottom: 0%;
			left: 0%;
			width: 100%;
			background: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 15rpx 20rpx 40rpx;
			box-sizing: border-box;

			.left-box {
				display: flex;
				align-items: center;

				.icon {
					width: 80rpx;
					height: 80rpx;
				}

				.info {
					margin-left: 20rpx;

					.tel {
						color: #222222;
						font-weight: bold;
						font-size: 32rpx;
					}

					.desc {
						font-size: 22rpx;
						color: #999999;
					}
				}
			}

			.btn {
				width: 340rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				background: #FF4C3A;
				color: #fff;
				font-size: 28rpx;
				font-weight: bold;
				border-radius: 40rpx 40rpx 40rpx 40rpx;
			}
		}

	}
</style>