<template>
	<view class="concerns">
		<view class="concerns-container">
			<view v-for="(info, index) in list" :key="index">
				<view class="daren-item">
					<image class="head" :src="info.friend_tomavatar" @click="viewDetails({ id: info.friend_tomid, type: info.role })"></image>
					<text class="name" @click="viewDetails({ id: info.friend_tomid, type: info.role })">{{ info.friend_tomname || '' }}</text>
					<view class="guanzhu" @click="changeType(info.friend_tomid)" v-if="info.friend_followstate == 1">取消关注</view>
				</view>
			</view>
		</view>
		<u-empty mode="list" v-if="!list.length" color="#000" img-width="200" font-size="30" margin-top="120"></u-empty>
	</view>
</template>
<script>
export default {
	data() {
		return {
			list: []
		}
	},
	onShow() {
		this.attentionMemberList();
	},
	// 下拉刷新
	onPullDownRefresh() {
        this.attentionMemberList();
    },
	methods: {
		attentionMemberList() {
			this.$u.api.attentionMemberList().then(res => {
				uni.stopPullDownRefresh();
				if(res.errCode == 0) {
					this.list = res.data.data;
				} else {
					this.list = [];
				}
			})
		},
		viewDetails({ id, type }) {
			let src = type == 3 ? 'pageB/details/index' : 'pageC/merchant/index';
			this.$u.route(src, {
				id: id
			});
		},
		changeType(id) {
				console.log(id);
				this.$u.api.attentionMember({
					member_id: id
				}).then(res => {
					this.$u.toast(res.message);
					this.attentionMemberList();
				})
			},
	},
};
</script>
<style lang="scss" scoped>
.concerns {
	.concerns-container {
		padding: 30rpx;
		display: flex;
		flex-wrap: wrap;
		&:not(:nth-child(3n)) {
			margin-right: 20rpx;
		}
		.daren-item{
			width: 215rpx;
			height: 282rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			background-color: #fff;
			border-radius: 10rpx;
			overflow: hidden;
			.head{
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
				margin-top: 24rpx;
				background-color: #0f0;
			}
			.name{
				font-size: 26rpx;
				color: #333;
				font-weight: 400;
				margin-top: 23rpx;
			}
			.zhuangtai{
				font-size:22rpx;
				color: #999;
				margin-top: 19rpx;
			}
			.guanzhu{
				width: 130rpx;
				height: 50rpx;
				background-color: #EDEDED;
				font-size: 26rpx;
				line-height: 50rpx;
				color: #fff;
				text-align: center;
				margin-top: 19rpx;
				border-radius: 25rpx;
			}
			.action{
				background: #f3f3f3;
			}
		}
	}
}
</style>