<template>
	<view class="park" :style="{backgroundImage:`url(${recordBackgroundImage})`}">
		<view class="park-navbar">
			<u-navbar title="邀请记录" :border-bottom="false" :background="background"></u-navbar>
		</view>
		<view class="park-hd" :style="{backgroundImage:`url(${tipsBackgroundImage})`}">
		</view>
		<view class="park-bd">
			<view class="tab">
				<view class="item" :class="tabIndex == 0?'item-on':''" @click="tabItem(0)">
					申请已过<text style="margin-left: 15rpx;">{{invite_num}}</text></view>
				<view class="item" :class="tabIndex == 1?'item-on':''" @click="tabItem(1)">
					申请未过<text style="margin-left:15rpx;">{{refuse_num}}</text></view>
			</view>
			<view class="li" v-for="(a,i) in list" :key="i">
				<view class="li-box">
					<view class="l">
						<image v-if="a.avatar_url" :src="a.avatar_url"></image>
						<image v-else :src="$picUrl+'/static/news/avater.png'"></image>
					</view>
					<view class="m">
						<view class="n">{{a.username}}</view>
						<view class="t">{{a.desensitization_mobile}}
							<image @click="copy(a.mobile)" :src="$picUrl+'/static/shangjia/record_copy.png'"></image>
						</view>
					</view>
				</view>
				<view class="li-hui">
					{{a.user_type==20?'分销商':a.user_type==30?'服务商':a.user_type==10?'游客':'其他'}}
				</view>
				<view class="borderline"></view>
			</view>
			<view v-if="total == 0" style="margin: 250rpx 0">
				<u-empty text="暂无信息" mode="list"></u-empty>
			</view>
		</view>
		<addShuiyin />
	</view>
</template>

<script>
	import * as newFunApi from '@/api/newFun'
	export default {
		data() {
			return {
				list: [],
				total: 0,
				tabIndex: 0,
				refuse_num: 0,
				invite_num: 0,
				recordBackgroundImage: 'https://www.amiami.com.cn/static/shangjia/record_bg.png?t=1',
				tipsBackgroundImage: 'https://www.amiami.com.cn/static/shangjia/record_tips.png?t=1',
				background: {
					background: 'none'
				},
			};
		},
		onLoad() {
			this.getList();
		},
		methods: {
			copy(str) {
				uni.setClipboardData({
					data: str, //	这里是个坑接受字符串类型 value转化为字符串
					success: function() {
						//调用方法成功
						uni.showToast({
							title: '复制成功',
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			tabItem(i) {
				this.tabIndex = i
				this.getList();
			},
			async getList() {
				uni.showLoading({
					title: "加载中"
				})
				const {
					status,
					data
				} = await newFunApi.inviteWholesalerList({
					status: this.tabIndex == 0 ? 20 : 30
				});
				if (status == 200) {
					uni.hideLoading();
					this.list = data.list;
					this.total = data.total;
					this.invite_num = data.invite_num;
					this.refuse_num = data.refuse_num;
				}
			},
		}
	}
</script>
<style>
	page {
		background: #fff;
		width: 100%;
	}
</style>
<style lang="scss" scoped>
	.park {
		padding: 0 0 60rpx;
		overflow: hidden;
		width: 100%;
		background-size: 100% auto;
		min-height: 100vh;
		background-size: cover;

		&-hd {
			width: 440rpx;
			height: 196rpx;
			margin: 40rpx auto;
			background-repeat: no-repeat;
			background-size: cover;
		}

		&-bd {
			padding: 0 32rpx;
			border-radius: 10rpx;
			overflow: hidden;
			margin: 40rpx auto 0;

			.tab {
				display: flex;
				justify-content: space-between;
				overflow: hidden;

				.item {
					display: flex;
					justify-content: center;
					padding: 0 24rpx;
					min-width: 176rpx;
					height: 54rpx;
					background: linear-gradient(90deg, #FFDD99 0%, #B87D07 100%);
					border-radius: 32rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #FFFFFF;
					line-height: 54rpx;
					font-style: normal;
					text-transform: none;

					text {
						margin-left: 10rpx;
					}

					&-on {
						border-color: #9A372D;
						color: #9A372D;
					}
				}
			}

			.li {
				padding: 24rpx 24rpx 40rpx 24rpx;
				overflow: hidden;
				background: #FFFFFF;
				border-radius: 16rpx;
				margin-top: 32rpx;
				position: relative;

				.li-hui {
					position: absolute;
					padding: 0 16rpx;
					height: 48rpx;
					background: #FFFFFF;
					border-radius: 8rpx;
					border: 2rpx solid #FFAD33;
					top: 24rpx;
					right: 24rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #FFAD33;
					line-height: 46rpx;
					font-style: normal;
					text-transform: none;
				}

				.li-box {
					overflow: hidden;
					display: flex;
					align-items: flex-start;
				}

				.borderline {
					margin-top: 24rpx;
					width: 100%;
					height: 1rpx;
					background: #F2F2F2;
				}

				.l {
					width: 80rpx;
					height: 80rpx;
					margin-right: 16rpx;

					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}

				.m {
					flex: 1;
					max-width: 400rpx;
					margin-right: 20rpx;

					.n {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: #222;
					}

					.t {
						margin-top: 10rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #A7A7A7;
						display: flex;
						align-items: center;

						image {
							width: 32rpx;
							height: 32rpx;
							margin-left: 24rpx;
						}
					}
				}

				.r {
					font-size: 28rpx;
					color: #FF4C4B;

					text {
						font-size: 36rpx;
					}
				}
			}
		}
	}
</style>
