<template>
    <view class="content">
        <!-- 分类 -->
        <view class="tabs">
        	<view class="item" :class="{'show': larer == ''}" @click="onTabs('')">全部</view>
        	<view class="item" :class="{'show': larer == '1'}" @click="onTabs('1')">直接</view>
        	<view class="item" :class="{'show': larer == '2'}" @click="onTabs('2')">间接</view>
        </view>
        <block v-if="lists.length > 0">
			<view class="partner-list">
				<view class="partner-label" v-for="(item, index) in lists" :key="index" :larer='larer'>
					<image class="partner-avatar" :src="item.avatar ? item.avatar : '/static/user/user-portrait.png'" mode="aspectFill"></image>
					<view class="partner-cont">
						<view class="partner-name">
							<view class="partner-nickname">{{item.nickname}}</view>
							<image v-if="item.identity" class="partner-identity" :src="item.identity.cover" mode="widthFix"></image>
						</view>
						<view class="partner-tel">{{item.username}}</view>
					</view>
				</view>
			</view>
			<uni-load-more :status="pageMore"></uni-load-more>
		</block>
		<block v-else>
			<view class="list-null">
				<image class="icon" src="@/static/icons/approve-icon.png" mode="widthFix"></image>
				<view class="sub-title">暂未数据</view>
			</view>
		</block>
    </view>
</template>

<script>
    import { userPartne } from '@/apis/interfaces/user'
    export default {
    	data() {
    		return {
    			larer	  : '',
    			lists	  : [],
				pageMore  : 'more',
    			page	  : 1
    		};
    	},
    	onShow() {
            this.larer = this.$Route.query.larer
            // 获取伙伴列表
    		this.getPartner()
    	},
		onReachBottom(){
			if(this.pageMore === 'more'){
				this.pageMore = 'loading'
				this.page++
				this.getPartner()
			}
		},
    	methods: {
            // 伙伴列表
    		getPartner() {
                userPartne({
                	larer: this.larer,
					page : this.page
                }).then(res => {
					if(this.page === 1) this.lists = []
                    this.lists		= this.lists.concat(res.users.data)
					this.page		= res.users.page.current
					this.pageMore	= res.users.page.has_more ? 'more': 'noMore'
                })
            },
            
            // tabs
            onTabs(value){
            	if(value == this.larer) return
				this.page = 1
            	this.larer = value
            	this.getPartner()
            }
        }
    }
</script>

<style lang="scss" scoped>
	.content{
		padding-top: 90rpx;
	}
	
	// 空提示
	.list-null{
		width: 100vw;
		height: 100vh;
		padding-bottom: 20vh;
		box-sizing: border-box;
		background: white;
		text-align: center;
		@extend .vertical;
		.sub-title{
			color: $text-gray;
			font-size: $title-size-m;
		}
		.icon{
			width: 288rpx;
		}
		.sub-btn{
			width: 200rpx;
			height: 70rpx;
			line-height: 70rpx;
			text-align: center;
			background: $mian-color;
			color: white;
			display: inline-block;
			margin-top: $margin*2;
		}
	}
    
    // tabs
    .tabs{
    	position: fixed;
    	top: 0;
		//#ifdef H5
		top:100rpx;
		//#endif
    	left: 0;
    	right: 0;
    	z-index: 99;
    	display: flex;
    	justify-content: space-around;
    	background: white;
    	padding: 15rpx 0;
    	font-size: $title-size-lg;
    	color: $text-gray;
		box-shadow: 0 0 5rpx 5rpx rgba($color: $border-color, $alpha: .2);
    	.item{
    		height: 60rpx;
    		line-height: 60rpx;
    		&.show{
    			color: $mian-color;
    			border-bottom: solid 4rpx $mian-color;
    		}
    	}
    }
    
    // 列表
    .partner-list{
        .partner-label {
            padding: ($padding - 10) $padding;
            box-sizing: border-box;
            position: relative;
            border-radius: $radius;
			margin: $margin;
			background-color: white;
            .partner-avatar {
                width: 100rpx;
                height: 100rpx;
                border-radius: 50%;
				vertical-align: top;
            }
            .partner-cont {
                position: absolute;
                width: 100%;
                left: 0;
                top: 0;
                padding: ($padding - 10) $padding ($padding - 10) 150rpx;
                box-sizing: border-box;
                .partner-name {
					padding-top: 10rpx;
					display: flex;
					line-height: 40rpx;
					.partner-nickname {
						font-size: 30rpx;
						font-weight: 600;
						margin-right: 10rpx;
					}
					.partner-identity {
						width: 84rpx;
						margin-top: 5rpx;
						margin-left: 5rpx;
						vertical-align: middle;
					}
				}
				.partner-tel{
					line-height: 40rpx;
					color: $text-gray;
				}
            }
        }
    }
</style>
