<template>
	<view class="content">
		<view class="header">
			客户列表
			<text>共{{count.all}}客户</text>
		</view>
		<block v-if="users.length > 0">
			<view class="team-item" v-for="(item, index) in users" :key="index">
				<u-avatar :src="item.avatar" size="40"></u-avatar>
				<view class="name nowrap">
					{{item.nickname}}
					<text class="identity identity-2" v-if="item.identity.order == 2">业务员</text>
					<text class="identity identity-1" v-if="item.identity.order == 1">普通用户</text>
					<text class="identity identity-3" v-if="item.identity.order == 3">顾问</text>
				</view>
				<view class="mobile">{{item.username}}</view>
			</view>
		</block>
		<block v-else>
			<view class="list-null">
				<u-empty
					mode="data"
					icon="http://cdn.uviewui.com/uview/empty/data.png"
					text="暂无客户数据"
				>
				</u-empty>
			</view>
		</block>
	</view>
</template>

<script>
	import { relations } from '@/apis/interfaces/user.js'
	export default {
		data() {
			return {
				users: [],
				count: {
					all: 0
				}
			};
		},
		created() {
			relations({
				larer: 1
			}).then(res => {
				let { users, count } = res;
				this.users = users.data
				this.count = count
			}).catch(err => {
				uni.showToast({
					title: err.message,
					icon : 'none'
				})
			})
		}
	}
</script>

<style lang="scss">
	.content{
		box-sizing: border-box;
	}
	// 统计数据
	.header{
		display: flex;
		justify-content: space-between;
		padding:  0 30rpx;
		line-height: 100rpx;
		font-weight: bold;
		text{
			font-size: 28rpx;
			color: gray;
			font-weight: normal;
		}
	}
	// 团队列表
	.team-item{
		background: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx;
		border-radius: 20rpx;
		margin: 0 30rpx 30rpx 30rpx;
		.name{
			width: calc(100% - 200rpx - 40px);
			padding: 0 20rpx;
			box-sizing: border-box;
			font-weight: bold;
			font-size: 30rpx;
			color: #333333;
			.identity{
				display: inline-block;
				background: #F6F6F6;
				color: #999999;
				font-weight: normal;
				margin-left: 20rpx;
				border-radius: 20rpx;
				height: 40rpx;
				line-height: 36rpx;
				padding: 0 10rpx;
				font-size: 24rpx;
				border:solid 1rpx #000;
				box-sizing: border-box;
				&.identity-2{
					background: #ECF0FF;
					border-color: #443DE2;
					color: #443DE2;
				}
				&.identity-1{
					background: #F6F6F6;
					border-color: #999999;
					color: #999999;
				}
				&.identity-3{
					background: #FFF7EC;
					border-color: #FEAD45;
					color: #FEAD45;
				}
			}
		}
		.mobile{
			width: 200rpx;
			color: #666666;
			text-align: right;
			font-size: 30rpx;
		}
	}
</style>
