<template>
	<view>
		<view class="head">
			<view class="portrait">
				<image class="image" src="../../static/images/login/logo.png" mode="scaleToFill"></image>
			</view>
			<view>
				<view v-if="token" class="nickname">{{nickname}}</view>
				<view v-else class="nickname">您还未登录</view>
				<view>
					<text v-show="user_type===3" class="wddz">网店店主</text>
					<text v-show="user_type===2" class="zgcj">直供厂家</text>
				</view>
			</view>
			<view class="invite">
				<view class="invite-code">邀请码：{{invite_code}}</view>
				<view class="invite-progress">
					<view class="item active"></view>
					<view class="item active"></view>
					<view class="item active"></view>
					<view class="item"></view>
					<view class="item"></view>
				</view>
				<view class="invite-notes">再邀请3人获得代理会员</view>
			</view>
		</view>
		<view class="body">
			<view class="money">
				<view class="row">
					<view class="col">可提现金额(元)：<text class="warning">{{$store.state.user.money}}</text></view>
					<view class="col"><button class="btn tixian-btn" @tap="goToWithdrew">立即提现</button></view>
				</view>
				<view v-if="user_type===2" class="row">
					<view class="col">保证金(元)：<text>0.00</text><text class="tips">（保证金2000元）</text></view>
					<view class="col"><button class="btn jiaona-btn">立即缴纳</button></view>
				</view>
				<view v-if="user_type===3" class="row">
					<view class="col">不可提现金额：<text>0</text></view>
					<!-- <view class="col"><button class="btn jiaona-btn">立即缴纳</button></view> -->
				</view>
			</view>
			
			<navigator url="/pages/user/agent" open-type="navigate" hover-class="none">
				<view class="vip-center">
					<view class="text">代理会员中心<text class="sub">（特权独享）</text></view>
				</view>
			</navigator>

			<view class="menu">
				<view class="menu-item">
					<navigator url="/pages/user/money-log" open-type="navigate" hover-class="none">

						<view class="icon">
							<image class="image" src="../../static/images/menu/b8.png" mode="scaleToFill"></image>
						</view>
						<view class="name">账单明细</view>
					</navigator>

				</view>
				<view class="menu-item">
					<navigator url="/pages/order/order" open-type="navigate" hover-class="none">
						<view class="icon">
							<image class="image" src="../../static/images/menu/b7.png" mode=""></image>
						</view>
						<view class="name">订单管理</view>
					</navigator>
				</view>
				<view v-if="user_type===2">
					<navigator url="/pages/product/my-product" open-type="navigate" hover-class="none">
						<view class="icon">
							<image class="image" src="../../static/images/menu/b2.png" mode=""></image>
						</view>
						<view class="name">我的商品</view>
					</navigator>
				</view>
				<view v-if="user_type===3">
					<navigator url="/pages/user/collection" open-type="navigate" hover-class="none">
						<view class="icon">
							<image class="image" src="../../static/images/menu/b2.png" mode=""></image>
						</view>
						<view class="name">我的收藏</view>
					</navigator>
				</view>
				<view>
					<navigator url="/pages/user/strategy" open-type="navigate" hover-class="none">
						<view class="icon">
							<image class="image" src="../../static/images/menu/b1.png" mode=""></image>
						</view>
						<view class="name">新手攻略</view>
					</navigator>
				</view>
			</view>
			<view class="menu">
				<view>
					<navigator url="/pages/user/problem" open-type="navigate" hover-class="none">
						<view class="icon">
							<image class="image" src="../../static/images/menu/b3.png" mode=""></image>
						</view>
						<view class="name">常见问题</view>
					</navigator>
				</view>
				<view>
					<navigator url="/pages/user/kefu" open-type="navigate" hover-class="none">
						<view class="icon">
							<image class="image" src="../../static/images/menu/b4.png" mode=""></image>
						</view>
						<view class="name">联系客服</view>
					</navigator>
				</view>
				<view>
					<navigator url="/pages/user/notice" open-type="navigate" hover-class="none">
						<view class="icon">
							<image class="image" src="../../static/images/menu/b5.png" mode=""></image>
						</view>
						<view class="name">官方公告</view>
					</navigator>
				</view>
				<view>
					<navigator url="/pages/user/feedback" open-type="navigate" hover-class="none">

						<view class="icon">
							<image class="image" src="../../static/images/menu/b6.png" mode=""></image>
						</view>
						<view class="name">意见反馈</view>
					</navigator>

				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'

	export default {
		data() {
			return {
				balance: '',
				deposit: ''
			};
		},
		computed: mapState({
			nickname: state => state.user.nickname,
			user_type: state => state.user.group_id,
			invite_code: state => state.user.invite_code,
			token: state => state.user.token,
		}),
		onTabItemTap(e) {
			uni.$emit("refresh_userinfo");
		},
		onNavigationBarButtonTap(e) {
			// console.log(e)
			switch (e.index) {
				case 0:
					uni.navigateTo({
						url: '/pages/user/setting'
					});
					break;
				case 1:
					uni.navigateTo({
						url: '/pages/message/message'
					});
					break;
				default:
					break;
			}
		},
		methods: {
			goToWithdrew() {
				uni.navigateTo({
					url: "/pages/user/withdraw"
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.head {
		background: $primary-color;
		display: flex;
		align-items: center;
		padding-bottom: 140upx;
		padding-top: 20upx;
	}

	.portrait {
		margin: 0 20upx;
		border: 10upx solid rgba(255, 255, 255, 0.5);
		border-radius: 128upx;
		overflow: hidden;
		width: 128upx;
		height: 128upx;

		.image {
			width: 128upx;
			height: 128upx;
			background: white;
		}
	}

	.nickname {
		font-size: 30upx;
		color: white;
		margin-bottom: 10upx;
	}

	.wddz,
	.zgcj {
		font-size: 24upx;
		color: white;
		border: 2upx solid white;
		border-radius: 20upx;
		width: 140upx;
		height: 36upx;
		line-height: 36upx;
		text-align: center;
		text-indent: 20upx;
		display: inline-block;
		padding: 0;
		background: url(../../static/images/do.png) no-repeat;
		background-size: 21upx 21upx;
		background-position: 10upx;
	}

	.invite {
		text-align: right;
		flex-grow: 1;
		margin-right: 20upx;
		color: white;

		.invite-code {
			font-size: 30upx;
		}

		.invite-notes {
			font-size: 24upx;
		}

		.invite-progress {
			.item {
				border: 2upx solid white;
				display: inline-block;
				width: 36upx;
				transform: scaleX(0.9);
				font-size: 0;
				border-radius: 2upx;

				&.active {
					border-color: yellow;
				}
			}

			&::after {
				content: "";
				background: url(../../static/images/vip.png) no-repeat;
				background-size: 42upx 42upx;
				width: 42upx;
				height: 42upx;
				display: inline-block;
				position: relative;
				top: 16upx;
			}

			margin-bottom: 20upx;
		}
	}

	.body {
		padding: 20upx;
		position: relative;
		top: -120upx;

		.money {
			background: white;
			border-radius: 20upx;
			padding: 20upx;

			font-family: "Roboto", sans-serif;

			.row {
				color: #333;
				display: flex;
				align-items: center;
				margin-bottom: 20upx;

				.warning {
					color: $primary-color;
					font-weight: bold;
					font-family: "Roboto-Bold", sans-serif;
				}

				.tips {
					color: #CCC;
					font-size: 24upx;
				}

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

				& .col:first-child {
					flex-grow: 1;
					font-size: 28upx;
				}

				& .col:last-child {
					// text-align: right;
					font-size: 28upx;
				}
			}

			.btn {
				background-color: $primary-color;
				color: white;
				font-size: 26upx;
				padding: 5upx 20upx;
				border-radius: 40upx;
				line-height: normal;
			}
		}
	}

	.vip-center {
		background: url(../../static/images/center5.png) no-repeat;
		background-size: 710upx 78upx;
		color: white;
		padding: 0 20upx;
		margin-top: 20upx;
		height: 78upx;

		.text {
			margin-left: 50upx;
			background-color: #ff5454;
			font-weight: bold;
			line-height: 60upx;
			display: inline-block;
			margin-top: 10upx;

			.sub {
				font-size: 24upx;
			}
		}
	}

	.menu {
		display: flex;
		background: white;
		border-radius: 20upx;
		padding: 30upx 20upx;
		margin-top: 20upx;
		justify-content: space-between;

		.name {
			font-size: 28upx;
			margin-top: 10upx;
		}

		.icon {
			text-align: center;
		}

		.icon .image {
			width: 60upx;
			height: 60upx;
		}
	}
</style>
