<template>
	<view class="">
		<view class="empty-page" v-if="vuex_agenter_type == '普通用户'">
			<image src="@/static/icon/empty.png" mode=""></image>
			<block v-if="!$isEmpty(vuex_userId)">
				<view class="tips">
					<text>您当前还不是代理身份</text>
					<text>快去查看代理权益吧~</text>
				</view>
				<view class="cu-btn btn round" @click="view">
					点击查看
				</view>
			</block>
			
			<block v-else>
				<view class="tips">
					<text>当前用户还未登录</text>
					<text>快去登录查看代理权益吧~</text>
				</view>
				<view class="cu-btn btn round" @click="login">
					点击登录
				</view>
			</block>
			
		</view>
		<view class="page" v-else>
			<view class="card">
				<view class="top">
					<image :src="info.agenterAvatar" ></image>
					<view class="center text-lg" style="margin-left: 20rpx;margin-right: 10rpx;">{{info.agenterName}}</view>
					<view class="center margin-left-10">
						<view class="cu-tag btn-bg-color sm" style="border-radius: 20rpx 20rpx 20rpx 0;padding: 10rpx;">
							{{info.agenterType}}
						</view>
					</view>
				</view>
				<view class="bottom">
					<view >
						<text>今日收益</text>
						<text class="text-price">{{info.todayEarning}}</text>
					</view>
					<view @click="$jump('/pagesB/pages/agent/myIncome/myIncome')" style="margin: 0 50rpx;">
						<text>总收益</text>
						<text class="text-price">{{info.totalEarning}}</text>
					</view>
					<view @click="$jump('/pagesB/pages/agent/myPromote')">
						<text>我的推广</text>
						<text >{{info.promoteNum}}</text>
					</view>
				</view>
				
				<view @click="$jump('/pagesB/pages/withdraw/withdraw')" class="btn-withdraw">
					<view class="cu-btn round sm btn" style="font-size: 26rpx;">
						提现
					</view>
				</view>
			</view>
			
			<view class="menu">
				<view class="title">推广服务</view>
				<view class="margin-top-30">
					<view @click="$jump(item.path)" class="item" v-for="(item,index) in menuList" :key="index">
						<view class="center">
							<image style="width: 38rpx;height: 38rpx;margin-right: 10rpx;" :src="item.icon"></image>
							<text>{{item.name}}</text>
						</view>
						<view class="center">
							<text class="cuIcon-right"></text>
						</view>
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				info:{},
				menuList:[
					{
						icon:'/static/icon/topromote.png',
						name:'去推广',
						path:'/pagesB/pages/agent/draw-poster'
					},
					{
						icon:'/static/icon/mypromote.png',
						name:'我的推广',
						path:'/pagesB/pages/agent/myPromote'
					},
					{
						icon:'/static/icon/myearnings.png',
						name:'我的收益',
						path:'/pagesB/pages/agent/myIncome/myIncome'
					},
					{
						icon:'/static/icon/bank1.png',
						name:'我的银行卡',
						path:'/pagesB/pages/userBank/userBank'
					},
					{
						icon:'/static/icon/bank1.png',
						name:'提现记录',
						path:'/pagesB/pages/withdraw/records'
					},
				]
			}
		},
		created() {
			this.fetchStatistics()
		},
		methods:{
			login(){
				this.$emit('login')
			},
			view(){
				uni.navigateTo({
					url:"/pages/agent/agentDetail"
				})
			},
			fetchStatistics(){
				let params={
					userId:this.vuex_userId
				}
				this.$api.agenter.statistics(params).then(res=>{
					this.info=res.data
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	.btn-withdraw{
		position: absolute;
		right: -30rpx;
		top: 26rpx;
		
		.btn{
			padding: 16rpx 38rpx;
			background-color: #FFE6CD;
			color: #EF9944;
		}
	}
	
	.page{
		background-color: #f6f6f6;
		height: 80vh;
		display: flex;
		margin: 20rpx;
		flex-direction: column;
		justify-content: flex-start;
		align-items: center;
		
		.card{
			overflow: hidden;
			position: relative;
			padding:40rpx 40rpx;
			width: 100%;
			border-radius: 20rpx;
			background-image: linear-gradient(#1F2349,#465274);
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			
			
			.top{
				color: #FFFFFF;
				display: flex;
				
				image{
					border-radius: 50%;
					width: 60rpx;
					height: 60rpx;
				}
			}
			
			.bottom{
				width: 100%;
				padding-top: 30rpx;
				display: flex;
				text-align: center;
				justify-content: space-around;
				
				view{
					text-align: center;
					display: flex;
					flex-direction: column;
					
					text:first-child{
						color: #A9ADB4;
						font-size: 26rpx;
						margin-bottom: 10rpx;
					}
					text:last-child{
						font-size: 34rpx;
						color: #F3D4B4;
					}
				}
			}
		}
		
		.menu{
			margin-top: 30rpx;
			width: 100%;
			background-color: #FFFFFF;
			border-radius: 20rpx;
			padding: 0 20rpx;
			
			.title{
				padding-top: 30rpx;
				padding-left: 20rpx;
				font-weight: 800;
				font-size: 34rpx;
			}
			
			.item{
				border-bottom: 1rpx solid #EFEFEF;
				padding:30rpx 20rpx;
				color: #252525;
				font-size: 30rpx;
				display: flex;
				justify-content: space-between;
			}
			
			.item:last-child{
				border: none;
			}
		}
	}
	
	.empty-page{
		background-color: #f6f6f6;
		height: 70vh;
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		
		image{
			width: 280rpx;
			height: 240rpx;
		}
		
		.tips{
			margin-top: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			
			text:first-child{
				font-size: 32rpx;
				font-weight: 800;
			}
			
			text:last-child{
				margin-top: 20rpx;
				color: #999;
				font-size: 26rpx;
			}
		}
		
		.btn{
			width: 250rpx;
			margin-top: 100rpx;
			background-color: #F6F6F6;
			border: 1rpx solid #EF9944;
			color: #EF9944;
		}
	}
</style>
