<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>
        
        <view class="partner-list">
            <view class="partner-label" v-for="(item, index) in lists" :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>
    </view>
</template>

<script>
    import { userPartne } from '@/apis/interfaces/user'
    export default {
    	data() {
    		return {
    			larer	  : '',
    			lists	  : [],
    			pages	  : {}
    		};
    	},
    	onShow() {
            this.larer = this.$Route.query.larer
            // 获取伙伴列表
    		this.getPartner()
    	},
    	methods: {
            // 伙伴列表
    		getPartner() {
                userPartne({
                	larer: this.larer
                }).then(res => {
                    this.lists = res.users
                })
            },
            
            // tabs
            onTabs(value){
            	if(value == this.larer) return
            	this.lists = []
            	this.larer = value
            	this.getPartner()
            }
        }
    }
</script>

<style lang="scss" scoped>
	.content{
		padding-top: 90rpx;
	}
    
    // tabs
    .tabs{
    	position: fixed;
    	top: 0;
    	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;
    	.item{
    		height: 60rpx;
    		line-height: 60rpx;
    		&.show{
    			color: $text-price;
    			border-bottom: solid 4rpx $text-price;
    		}
    	}
    }
    
    // 列表
    .partner-list{
    	margin: calc(#{$padding} - 10rpx);
    	display: flex;
    	flex-wrap: wrap;
        background-color: #FFFFFF;
        .partner-label {
            padding: 20rpx;
            box-sizing: border-box;
            position: relative;
            border-radius: 4rpx;
            width: 100%;
            &::after {
                position: absolute;
                content: '';
                left: 0;
                bottom: 0;
                width: 100%;
                height: 1rpx;
                background-color: #f8f8f8;
            }
            &:last-child::after {
                display: none;
            }
            .partner-avatar {
                width: 100rpx;
                height: 100rpx;
                border-radius: 50%;
            }
            .partner-cont {
                position: absolute;
                width: 100%;
                left: 0;
                top: 0;
                padding: 22rpx 20rpx 20rpx 150rpx;
                box-sizing: border-box;
                .partner-name {
                    display: flex;
                    margin-bottom: 15rpx;
                    .partner-nickname {
                        font-size: 30rpx;
                        font-weight: 600;
                        margin-right: 10rpx;
                    }
                    .partner-identity {
                        width: 120rpx;
                    }
                }
            }
        }
    }
</style>
