<template>
	<view class="page">
		<!-- 导航栏 -->
		<navbar title="个人中心" leftClick @leftClick="$utils.navigateBack" bgColor="#E3441A" color="#fff" />

		<!-- 头部 -->
		<view class="head">
			<view class="headImage">
				<image :src="userInfo.headImage" mode="widthFix"></image>
			</view>

			<view class="user-info">
				<view class="user-base-info">
					<view class="user-base-top">
						<view class="user-name">倾心.临时决定离开军队费时费力士大夫</view>
						<view class="member-level">
							<image src="@/static/image/center/diamond-min.png" mode="widthFix" class="level"></image>
							<image v-if="false" src="@/static/image/center/gold-min.png" mode="widthFix" class="level">
							</image>
							<image v-if="false" src="@/static/image/center/sliver-min.png" mode="widthFix"
								class="level">
							</image>
						</view>
						<view class="user-tag">
							合伙人
						</view>
					</view>

					<view class="edit-user">
						<image src="@/static/image/center/edit-icon.png" mode="widthFix" class="edit-icon"></image>
						<view class="edit-btn">
							修改资料
						</view>
					</view>
				</view>

				<view class="user-phone">
					手机号:1820000000
				</view>
			</view>
		</view>

		<!-- 会员卡片 -->
		<view @click="$utils.navigateTo({url : '/pages_order/mine/memberCenter' })" class="earnings">
			<view v-if="index==1" v-for="(item,index) in memberList" :key="item.id" class="member-item">
				<image :src="item.memberBg" mode="widthFix" class="member-image"></image>

				<view class="member-info">
					<view class="profile-photo">
						<image src="@/pages_order/static/card/profilePhoto.png" mode="widthFix" class="pro-img"></image>
						<view class="open-status">
							已开通29天
						</view>
					</view>
					<view class="open">
						剩余一天到期
					</view>
				</view>
			</view>
		</view>

		<!-- 佣金数据 -->
		<view class="brokerage-data">
			<view class="brokerage">
				<image src="@/static/image/center/brokerage.png" mode="widthFix" class="brokerage-img"></image>

				<div class="main">
					<div class="title">我的佣金</div>
					<div class="money">￥240</div>
				</div>
			</view>

			<view class="balance">
				<image src="@/static/image/center/balance.png" mode="widthFix" class="balance-img"></image>

				<div class="main">
					<div class="title">我的余额</div>
					<div class="money">￥1200</div>
				</div>
			</view>
		</view>

		<!-- 我的服务 -->
		<view class="myServer">
			<view class="server-title">
				我的服务
			</view>

			<view class="box">
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=1')">
					<image src="@/static/image/center/1.png" mode="widthFix" />
					<view class="title">我的订单</view>
				</view>
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=2')">
					<image src="@/static/image/center/2.png" mode="widthFix" />
					<view class="title">我的团队</view>
				</view>
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=3')">
					<image src="@/static/image/center/3.png" mode="widthFix" />
					<view class="title">联系客服</view>
				</view>
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=4')">
					<image src="@/static/image/center/4.png" mode="widthFix" />
					<view class="title">邀请好友</view>
				</view>
			</view>

			<view class="box">
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=1')">
					<image src="@/static/image/center/5.png" mode="widthFix" />
					<view class="title">广告招商</view>
				</view>
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=2')">
					<image src="@/static/image/center/6.png" mode="widthFix" />
					<view class="title">会员权益</view>
				</view>
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=3')">
					<image src="@/static/image/center/7.png" mode="widthFix" />
					<view class="title">优惠券</view>
				</view>
				<view class="boxs" @click="$utils.navigateTo('/pages/index/order?type=4')">
					<image src="@/static/image/center/8.png" mode="widthFix" />
					<view class="title">帮助与反馈</view>
				</view>
			</view>
		</view>

		<!-- 广告 -->
		<div v-if="showAdvertising" class="ad">
			<swiper class="swiper" circular :indicator-dots="indicatorDots" :autoplay="true" :interval="2000"
				:duration="duration">
				<swiper-item v-for="item in 10" :key="item">
					<view class="swiper-main">
						<view @click="closeAdvertising" class="close">
							<image src="@/static/image/center/close.png" mode="widthFix" class="close-img"></image>
						</view>
						<image src="@/static/image/center/ad.png" mode="widthFix" class="swiper-main-img"></image>
						<div class="ad-tag">
							<image src="@/static/image/center/ad-tag.png" mode="widthFix" class="ad-tag-img"></image>
						</div>
					</view>
				</swiper-item>
			</swiper>
		</div>

		<customerServicePopup ref="customerServicePopup" />

		<tabber select="center" />
	</view>
</template>

<script>
	import tabber from '@/components/base/tabbar.vue'
	import {
		mapState
	} from 'vuex'
	import customerServicePopup from '@/components/config/customerServicePopup.vue'
	export default {
		components: {
			tabber,
			customerServicePopup,
		},
		computed: {
			...mapState(['userInfo', 'riceInfo']),
		},
		data() {
			return {
				vipType: ['普通会员', '黄金会员', '渠道商'],
				vipImage: ['vip_vip', 'vip_user', 'vip_shop'],
				memberList: [{
						id: 1,
						memberBg: "/pages_order/static/card/diamond.png",
					},
					{
						id: 2,
						memberBg: "/pages_order/static/card/gold.png",
					},
					{
						id: 3,
						memberBg: "/pages_order/static/card/silver.png",
					}
				],
				showAdvertising: true,
			}
		},
		onShow() {
			this.$store.commit('getUserInfo')
			this.$store.commit('getRiceInfo')
		},
		methods: {
			clickNo() {
				uni.showModal({
					title: '暂未开放',
				})
			},

			//关闭广告
			closeAdvertising() {
				this.showAdvertising = false;
			}
		}
	}
</script>

<style scoped lang="scss">
	.page {

		// 头部
		.head {
			display: flex;
			align-items: center;
			padding: 60rpx 20rpx 120rpx 20rpx;
			background: $uni-color;

			.headImage {
				width: 130rpx;
				height: 130rpx;
				background-image: url(/static/image/center/head-img.png);
				background-repeat: no-repeat;
				background-position: 50%, 50%;
				background-size: 100%;
				overflow: hidden;
				border-radius: 50%;
				margin-right: 40rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.user-info {
				width: calc(100% - 130rpx);

				.user-base-info {
					display: flex;
					flex-wrap: wrap;
					justify-content: space-between;

					.user-base-top {
						width: 65%;
						display: flex;
						align-items: center;
						flex-wrap: wrap;
						color: white;

						.user-name {
							max-width: calc(100% - 240rpx);
							white-space: nowrap;
							text-overflow: ellipsis;
							overflow: hidden;
							font-size: 34rpx;
						}

						.member-level {
							margin-left: 10rpx;

							.level {
								width: 120rpx;
							}
						}

						.user-tag {
							display: flex;
							align-items: center;
							justify-content: center;
							background: #000;
							width: 100rpx;
							height: 40rpx;
							border-radius: 20rpx;
							font-size: 24rpx;
							margin-left: 10rpx;
						}
					}

					.edit-user {
						width: 35%;
						display: flex;
						align-items: center;
						justify-content: flex-end;

						.edit-icon {
							width: 30rpx;
						}

						.edit-btn {
							color: white;
							margin-left: 10rpx;
						}
					}
				}

				.user-phone {
					color: white;
					font-size: 24rpx;
				}
			}
		}

		// 会员卡片
		.earnings {
			padding: 20rpx;
			box-sizing: border-box;
			margin-top: -22%;

			.member-item {
				position: relative;

				.member-image {
					width: 100%;
				}

				.member-info {
					position: absolute;
					bottom: 30rpx;
					left: 0rpx;
					display: flex;
					align-items: center;
					padding: 0rpx 40rpx;
					box-sizing: border-box;
					width: 100%;

					.profile-photo {
						display: flex;
						justify-content: center;
						align-items: center;

						.pro-img {
							width: 60rpx;
							height: 60rpx;
						}

						.open-status {
							color: #F8A95F;
							border: 1px solid #F8A95F;
							border-radius: 30rpx;
							padding: 7rpx 20rpx;
							margin-left: 10rpx;
						}
					}

					.open {
						font-size: 26rpx;
						margin-left: 20rpx;
					}
				}
			}
		}

		// 佣金数据
		.brokerage-data {
			padding: 20rpx;
			background: white;
			border-radius: 20rpx;
			display: flex;
			flex-wrap: wrap;
			box-sizing: border-box;
			margin: 0rpx 20rpx 20rpx 20rpx;

			.brokerage,
			.balance {
				display: flex;
				flex-wrap: wrap;
				width: 50%;

				.brokerage-img,
				.balance-img {
					width: 50%;
				}

				.main {
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					width: 50%;
					box-sizing: border-box;
					padding: 30rpx 0rpx;

					.title {
						font-size: 34rpx;
					}

					.money {
						font-size: 40rpx;
						color: #DC2828;
						font-weight: bold;
					}
				}
			}
		}

		// 我的服务
		.myServer {
			margin: 0rpx 20rpx 20rpx 20rpx;
			background: white;
			border-radius: 20rpx;
			padding: 20rpx;
			box-sizing: border-box;

			.server-title {
				margin-bottom: 20rpx;
				font-size: 34rpx;
			}

			.box {
				display: flex;
				width: 100%;
				justify-content: space-around;
				margin-bottom: 20rpx;

				.boxs {
					width: 25%;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					image {
						width: 60rpx;
						height: 60rpx;
						display: block;
						margin: 0rpx auto 10rpx auto;
					}
				}

				&:last-child {
					margin-bottom: 0rpx;
				}
			}
		}

		// 广告
		.ad {
			margin: 0rpx 20rpx;

			.swiper {
				.swiper-main {
					position: relative;

					.close {
						position: absolute;
						top: 20rpx;
						right: 20rpx;

						.close-img {
							width: 40rpx;
							height: 40rpx;
						}
					}

					.swiper-main-img {
						width: 100%;
					}

					.ad-tag {
						position: absolute;
						left: 20rpx;
						bottom: 20rpx;

						.ad-tag-img {
							width: 100rpx;
						}
					}
				}
			}
		}
	}
</style>