<template>
	<view>
		<view class="cu-bar bg-white solid-bottom">
			<view class="action">
				<text class="cuIcon-title text-orange "></text> 团队收益
			</view>
		</view>
		<view class="lw-table">
			<view class="lw-table-item padding">
				<view :class="{'text-price':brokerinfo.type == 1}" class="lw-table-value text-bold text-red">
					{{statistics.income_total}}
				</view>
				<view class="lw-table-title text-gray padding-top-xs">总收益</view>
			</view>
			<view class="lw-table-item padding">
				<view :class="{'text-price':brokerinfo.type == 1}" class="lw-table-value text-bold text-red">
					{{statistics.income}}
				</view>
				<view class="lw-table-title text-gray padding-top-xs">当前收益</view>
			</view>
		</view>
		<view class="cu-bar bg-white solid-bottom margin-top">
			<view class="action">
				<text class="cuIcon-title text-orange "></text> 我的下线
			</view>
		</view>
		<view class="lw-table">
			<view class="lw-table-item padding" @click="goNavPage('/pages/partner/user')">
				<view class="lw-table-value text-bold text-black">{{statistics.user}}</view>
				<view class="lw-table-title text-gray padding-top-xs">求职用户</view>
			</view>
			<view class="lw-table-item padding" @click="goNavPage('/pages/partner/broker')">
				<view class="lw-table-value text-bold text-black">{{statistics.broker}}</view>
				<view class="lw-table-title text-gray padding-top-xs">经纪人</view>
			</view>
		</view>
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				userinfo: {},
				brokerinfo: {},
				statistics: {
					income_total: 0,
					income: 0,
					user: 0,
					worker: 0,
					agent: {},
				},
				modalName: '',
			};
		},
		onLoad: function() {
			_this = this;
			_this.userinfo = uni.getStorageSync('userinfo') || false;
			_this.brokerinfo = uni.getStorageSync('brokerinfo') || false;
			if (_this.userinfo === false || _this.brokerinfo === false) {
				uni.reLaunch({
					url: "/pages/my/my"
				});
				return false;
			}
			_this.init();
		},
		methods: {
			init: function() {
				_this.$req.ajax({
					path: "broker/partnerCenter",
					data: {
						brokerid: _this.brokerinfo.id
					}
				}).then((data) => {
					_this.statistics = data
				}).catch((err) => {
					uni.showModal({
						title: '信息提示',
						content: err,
						showCancel: false
					});
				});
			},
			goNavPage: function(pageurl) {
				_this.userinfo = _this.checkLogin("/pages/my/my");
				if (_this.userinfo === false) {
					return false;
				}
				uni.navigateTo({
					url: pageurl,
					fail: function() {
						uni.switchTab({
							url: pageurl
						});
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.header {
		height: 146rpx;
		position: relative;
		display: flex;
		align-items: center;
		justify-content: flex-end;

		.header-image {
			width: 750rpx;
			position: absolute;
			top: 0;
			left: 0;
			z-index: -1;
		}

		.header-notice {
			padding-right: 40rpx;
			font-size: 25rpx;
			color: #E0E0E0;
			display: flex;
			flex-direction: column;
			justify-content: center;
		}
	}

	.lw-table {
		display: flex;
		align-items: center;
		justify-content: space-around;
		background: white;
		padding: 20rpx 0;
	}

	.lw-table .lw-table-item {
		text-align: center;
	}

	.lw-table .lw-table-value {
		font-size: 40rpx;
	}
</style>