<template>
	<view class="my-card-box">
		<navigation-bar-vue title="我的黑名单" style="width: 100%;" background-color="#ffffff"
			title-color="#000000"></navigation-bar-vue>
		<view class="addr-list-box">
			<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="onReachBottomCus" refresher-enabled
				@refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
				<view class="user-image-box" v-for="(item,index) in dataList">
					<view class="dl-image-box">
						<image v-if="!item.avatar" class="touxiang" src="@/static/images/profile.jpg" mode="aspectFit">
						</image>
						<image v-else class="touxiang" :src="uploadUrl+item.avatar" mode="scaleToFill"></image>
<!--						<image class="sex" src="@/static/mine/sex_girl.png" mode="aspectFit"></image>-->
					</view>
					<view class="name-box">
						<view class="title-box">
							{{item.nickName || ''}}
						</view>
						<view class="bottom-box">
							<view class="fans-box">
								<view class="fans-num">{{item.createTime}}</view>
							</view>
						</view>
					</view>
					<view class="edit-box" @click="remove(item.id)">
						<view class="move-button">移除</view>
					</view>
				</view>
				<view style="text-align: center" v-if="dataList.length==0">
					<image class="" src="@/static/images/nothing.png"></image>
				</view>

			</scroll-view>
		</view>
	</view>
</template>

<script>
	import navigationBarVue from '@/components/navigation/navigationBar.vue';
  import {toast} from '@/utils/common.js'
  import config from '@/config';
  import {blackList,removeBlackList} from '@/api/business/member.js';
	export default {
		components: {
			navigationBarVue
		},
		data() {
			return {
        uploadUrl: '',
				dataList: [{
					nickName: "李林",
					createTime: "2024-02-10 12:22:44",
				}, {
					nickName: "李林",
					createTime: "2024-02-10 12:22:44",
				}],
				queryParams: {
					pageNum: 1,
					pageSize: 10,
          userId:null
				},
				total: 0,
				//下来刷新状态
				isTriggered: false
			}
		},
    onLoad(option){
		  this.queryParams.userId = option.userId
      this.initData()
    },
		methods: {

		  /**出事后数据*/
		  initData(){
        blackList(this.queryParams).then(res=>{
          this.isTriggered = false
          if (res.code == 200) {
            if (this.queryParams.pageNum == 1) {
              this.dataList = res.data.records
            } else {
              this.dataList = this.dataList.concat(res.data.records)
            }
            this.total = res.data.total
          }
        })
      },

			/**
			 * 上滑加载数据
			 */
			onReachBottomCus() {
				//判断 如果页码*页容量大于等于总条数，提示该页数据加载完毕
				if (this.queryParams.pageNum * this.queryParams.pageSize >= this.total) {
					toast("没有更多数据了")
					return
				}
				//页码+1,调用获取数据的方法获取第二页数据
				this.queryParams.pageNum++
        this.initData()
			},
			/**
			 * 下拉刷新数据
			 */
			onRefresherrefresh() {
				this.isTriggered = true
				this.queryParams.pageNum = 1
				this.total = 0
        this.initData()
			},
			remove(id) {
        removeBlackList({id:id}).then(res=>{
          if (res.code ==200){
            this.initData()
          }
        })
      }
		}
	}
</script>

<style lang="scss">
	.my-card-box {
		padding-top: calc(90rpx + var(--status-bar-height));
		background-color: white;
		width: 100%;
		color: #363636;
		font-size: 32rpx;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: self-start;
		justify-content: center;
		position: relative;

		.addr-list-box {
			background-color: #F6F6F6;
			height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 91rpx);
			overflow-y: scroll;
			padding: 0 30rpx;
			width: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: start;

			.user-image-box {
				width: 100%;
				background-color: white;
				margin-top: 20rpx;
				padding: 20rpx;
				border-radius: 20rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				.dl-image-box {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 100rpx;
					position: relative;

					.touxiang {
						border-radius: 50%;
						width: 80rpx;
						height: 80rpx;
					}

					.sex {
						width: 30rpx;
						height: 30rpx;
						position: absolute;
						bottom: 0rpx;
						right: 0rpx;
						border-radius: 50%;
					}
				}

				.name-box {
					display: flex;
					padding-left: 20rpx;
					flex: 1;
					flex-direction: column;
					align-items: self-start;
					justify-content: center;

					.title-box {
						display: flex;
						align-items: center;
						justify-content: center;

						image {
							margin-left: 10rpx;
							width: 50rpx;
							height: 50rpx;
						}
					}

					.bottom-box {
						display: flex;
						align-items: center;
						justify-content: center;

						.fans-box {
							max-width: 200rpx;
							margin-right: 10rpx;
							font-size: 18rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							padding: 5rpx 10rpx;
							color: #929292;

							image {
								height: 20rpx;
								width: 20rpx;
								margin-right: 8rpx;
							}
						}

						.member-box {
							flex: 1;
							font-size: 18rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							background-color: #FC1F3E;
							color: white;
							padding: 5rpx 10rpx;
							border-radius: 20rpx;
						}
					}



					.fans-num {}
				}

				.edit-box {
					color: #929292;
					text-align: right;
					padding-right: 20rpx;
					font-size: 22rpx;
					width: 130rpx;

					.move-button {
						color: #FC405B;
						text-align: center;
						padding: 8rpx 20rpx;
						background-color: white;
						border-radius: 25rpx;
						border: 1rpx solid #FC405B;
					}
				}
			}
		}
	}
</style>
