<template>
	<view class="content">
		<view class="content1">
			<span>邀请</span>
			<span>黑名单</span>
		</view>
		<view class="content2 ">
			<view class="row" v-for="(item,index) in cardList" :key="index">
				<view class="flex">
					<view class="left">
						<view class="top flex-row-center">
							<image :src="item.cardManagementInfo.headSculpture" mode="widthFix" class="img"></image>
						</view>
					</view>
					<view class="right">
						<view class="row1 flex">
							<text>{{item.cardManagementInfo.name}}</text>
							<text class="line"></text>
							<text>{{item.cardManagementInfo.post}}</text>
						</view>
						<view class="row2">
							{{item.cardManagementInfo.companyName}}
						</view>
						<view class="row3" @click="toMap">
							<uni-icons type="redo" size="20"></uni-icons>
							<text>{{item.cardManagementInfo.detailedAddress}}</text>
						</view>
						<view class="row3">
							<uni-icons type="redo" size="20"></uni-icons>
							<text>{{item.cardManagementInfo.phone}}</text>
						</view>
					</view>
				</view>
				<view class="" v-if="item.status==0">
					<span @click='cardExchangeInfoEdit(1,item)'> 拉黑</span>
					<span @click='cardExchangeInfoEdit(2,item)'>拒绝</span>
					<span @click='cardExchangeInfoEdit(3,item)'>接受</span>
					<span @click='cardExchangeInfoEdit(4,item)'>移除</span>
				</view>
				<view class="" v-else>
					<span v-if="item.status==1">已接受</span>
					<span v-if="item.status==3">已拒绝</span>
					<span v-if="item.status==5">已过期</span>
					<span v-if="item.status==7">已拉黑</span>
				</view>
				<view class="flex flex-between">
					<span>来至 {{item.circleName}}</span>
					<span> {{parseTime(item.gmtCreate)}}</span>
				</view>
			</view>
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:{},
				status:1,
				cardList:[],
			};
		},
		onLoad() {
			this.userInfo = uni.getStorageSync("userInfo")
			this.getList()
		},
		methods:{
			getList(){
				uni.showLoading({
					title: '数据加载中'
				})
				this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
					receiveId:this.userInfo.id,
					status:this.status
				}, failres => {
					console.log('res+++++', failres.errmsg)
					this.$refs.uToast.show({
						type: 'error',
						message: failres.errmsg,
					})
					uni.hideLoading()
				}).then(res => {
					uni.hideLoading()
					this.cardList = res.data.items
				})
			},
			cardExchangeInfoEdit(type,val){
				uni.showLoading({
					title: '数据加载中'
				})
				this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'update', {
					cardExchangeInfo:JSON.stringify(val),
					updateFlag:type
				}, failres => {
					console.log('res+++++', failres.errmsg)
					this.$refs.uToast.show({
						type: 'error',
						message: failres.errmsg,
					})
					uni.hideLoading()
				}).then(res => {
					uni.hideLoading()
					this.$refs.uToast.show({
						type: 'success',
						message: "操作成功！",
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content2 {
		border: 1px solid #ccc;
		border-radius: 30rpx;
		padding: 40rpx;
		box-sizing: border-box;

		.left {
			width: 30%;

			.top {
				
				margin-bottom: 20rpx;
			}
			.img {
				width: 80%;
			}

			.bottom {
			}
		}

		.right {
			.row1 {
				.line {
					width: 1px;
					height: 20px;
					margin: 0 20rpx;
					background: black;
				}
			}
		}
	}
</style>
