<template>
    <view class="follow">
        <view class="sosuo" @click="searchValue">
            <image src="/static/image/common/10.png"></image>
            <text>输入达人名称</text>
        </view>
        <view class="list" style="margin-left:-20rpx">
            <darenItem style="margin-top:20rpx;margin-left:20rpx;" v-for="item in recommendList" :key="item.id" :info="item"  v-on:pChangeType="changeType"></darenItem>
        </view>
    </view>
</template>
<style lang="scss" scoped>
.follow{
    background-color: #ECECEC;
    min-height: calc(100vh - var(--window-top));
    padding: 20rpx 30rpx;
    .sosuo{
        width: 100%;
        height: 60rpx;
        border-radius: 30rpx;
        background-color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        >image{
            width: 29rpx;
            height: 29rpx;
        }
        >text{
            font-size: 24rpx;
            color: #999;
            margin-left: 15rpx;
        }
    }
    .list{
        display: flex;
        flex-wrap: wrap;
        width: calc(100% + 23rpx);
        margin-right: -23rpx;
    }
}
</style>
<script>
import darenItem from "@/components/index/daren-item/index" 

export default {
    name:"follow",
    components:{
        darenItem
    },
    data(){
        return{
			recommendList: [], // 推荐达人
        }
	},
	onShow() {
		this.getRecommendList();
	},
	methods: {
		getRecommendList() {
			this.$u.api.getRecommendList().then(res => {
				if(res.errCode == 0) {
					this.recommendList = res.data.list;
				}
			})
		},
		changeType(member_id){
			console.log(member_id);
			this.$emit("pChangeType")
			this.$u.api.attentionMember({
				member_id: member_id
			}).then((res)=>{
				console.log(res)
				this.getRecommendList();
			})
		},
		searchValue() {
			uni.navigateTo({
				url: '/pageB/search/index?type=2'
			})
		},
	},
}
</script>