<template>
	<view>
		<loadlogo v-if="!loadlogo" />
		<view class="card">
			<view class="top-info">
				<view class="title">您可提现(元)</view>
				<view v-if="0" class="rule-box">
					<view class="iconfont icon-gantanhaozhong"></view>
					<view>推广规则</view>
				</view>
			</view>
			<view class="price">{{matchmakerInfo.commission}}</view>
			<view class="footer">
				<view class="common-btn" @click="handlePostClick">生成海报</view>
				<view class="common-btn right" @click="handleWithdrawalClick">立即提现</view>
			</view>
		</view>
	
		<view class="price-info">
			<view class="common-box">
				<view class="title">我的收益</view>
				<view class="value">
					<view class="unit">¥</view>
					<view class="num">{{matchmakerInfo.total_commission}}</view>
				</view>
			</view>
			<view class="common-box">
				<view class="title">我的邀请</view>
				<view class="value">
					<view class="num">{{matchmakerInfo.customer}}</view>
					<view class="unit">人</view>
				</view>
			</view>
		</view>
	
		<view class="h1-title">会员列表</view>
	
		<view class="content" v-if="memberList.length > 0">
			<view class="item" v-for="item in memberList" :key="item.id">
				<user :memberInfo="item" :isShowViews="false" @extension="extension"></user>
			</view>
		</view>
		<view  v-else>			
			<image style="width: 750upx;height: 560upx;" :src="imgfixUrls + 'homemakingImg/wushuju.png'" mode=""></image>
		</view>
		
		<!-- 推荐弹窗 -->
		<PopManager :show="is_showpop" type="bottom" @clickmask="is_showpop = false">
			<view class="pop">
				<view class="btn-box">
					<view class="common" @click="toExtensionPage(1)">
						<view class="img-box">
							<image :src="imgfixUrls + 'dating/bd_praise.svg'" mode=""></image>
						</view>
						<view class="text">未推荐</view>
					</view>
					<view class="common" @click="toExtensionPage(2)">
						<view class="img-box">
							<image :src="imgfixUrls + 'dating/bd_light_praise.svg'" mode=""></image>
						</view>
						<view class="text">已推荐</view>
					</view>
				</view>
				<view class="line"></view>
				<view class="foot" @click="is_showpop = false">取消</view>
			</view>
		</PopManager>
	</view>
</template>

<script>
	import user from '@/components/template/user.vue'
	// import user from './template/user.vue';
	import App from '@/common/js/app.js';
	import Loadlogo from '@/components/template/loadlogo.vue';
	import PopManager from '@/components/template/PopManager';
	export default {
		data() {
			return {
				loadlogo: false,
				matchmakerInfo: {},  //红娘信息
				lng: '',
				lat: '',
				memberList: [],  //会员列表
				member_id: 0,  //会员id
				currentPage: 1,
				is_showpop: false,  //推荐弹窗的显示
				matchmaker_id: ''
			}
		},
		watch: {
			matchmaker_id() {
				this.getMemberList()
			}
		},
		components: {
			user,
			Loadlogo,
			PopManager
		},
		onLoad(e) {
			this.lng = e.lng
			this.lat = e.lat
		},
		onShow() {
			this.getMatchmakerInfo()
		},
		onReachBottom() {
			this.currentPage++;
			this.getMemberList(true);
		},
		methods: {
			// 获取红娘信息
			getMatchmakerInfo() {
				let _this = this
				App._post_form(
					 `&p=dating&do=matchmakerCenter`,
					{},
					res => {
						_this.loadlogo = true
						_this.matchmakerInfo = res.data
						_this.matchmaker_id = res.data.id
					},
					false,
					() => {
					}
				);
			},
			
			// 获取会员列表
			getMemberList(flag) {
				let _this = this,
					apiUrl = `&p=dating&do=homeList&lng=${_this.lng}&lat=${_this.lat}`
				App._post_form(
					apiUrl,
					{
						page: _this.currentPage,
						matchmaker_id: _this.matchmaker_id
					},
					res => {
						if(flag){
							_this.memberList = _this.memberList.concat(res.data);
						}else{
							_this.memberList = res.data || []
						}
						
						// _this.memberList = []
					},
					false,
					() => {
					}
				);
			},
			
			// 点击提现
			handleWithdrawalClick() {
				App.navigationTo({
					url: `pages/subPages2/blindDate/withdraw?is_blindDate=true`
				})
			},
			
			
			// 会员右上角推广按钮点击
			extension(id) {
				this.is_showpop = true
				this.member_id = id
			},
			
			// 去推荐会员页面
			toExtensionPage(type) {
				App.navigationTo({
					url: `pages/subPages2/blindDate/member/recommend?matchmaker_id=${this.matchmakerInfo.id}&is_recommend=${type}&member_id=${this.member_id}&lng=${this.lng}&lat=${this.lat}`
				})
				this.is_showpop = false
			},
			
			// 生成海报
			handlePostClick() {
				App.navigationTo({
					url: `pages/mainPages/poster/poster?id=${this.matchmakerInfo.id}&type=15`
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		width: 610rpx;
		height: 260rpx;
		padding: 40rpx;
		margin: 30rpx auto 0;
		border-radius: 20rpx;
		background: linear-gradient(135deg, #FDAE25 0%, #FF8E8A 100%);
		color: #fff;
		.top-info {
			height: 32rpx;
			width: 100%;
			font-size: 24rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.rule-box {
				display: flex;
				.iconfont {
					margin-right: 10rpx;
					line-height: 32rpx;
				}
			}
		}
		.price {
			height: 70rpx;
			line-height: 70rpx;
			margin-top: 20rpx;
			font-size: 56rpx;
			font-weight: bold;
		}
		.footer {
			width: 100%;
			height: 70rpx;
			margin-top: 70rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.common-btn {
				width: 295rpx;
				height: 70rpx;
				line-height: 70rpx;
				text-align: center;
				border-radius: 20rpx;
				border: 1rpx solid #fff;
				font-size: 28rpx;
				font-weight: bold;
			}
			.right {
				background-color: #fff;
				color: #FDAC2C;
			}
		}
	}

	.price-info {
		width: 690rpx;
		height: 104rpx;
		margin: 50rpx auto;
		display: flex;
		align-items: center;
		font-size: 24rpx;
		color: #333;
		.common-box {
			flex: 1;
			height: 100%;
			display: flex;
			align-items: center;
			flex-direction: column;
			.title {
				height: 34rpx;
				line-height: 32rpx;
				color: #999;
			}
			.value {
				height: 60rpx;
				margin-top: 10rpx;
				display: flex;
				font-weight: bold;
				.unit {
					margin-right: 10rpx;
					line-height: 76rpx;
				}
				.num {
					font-size: 48rpx;
				}
			}
		}
	}

	.h1-title {
		height: 50rpx;
		line-height: 50rpx;
		font-size: 36rpx;
		color: #333;
		font-weight: bold;
		margin-left: 30rpx;
	}

	.content {
		width: 690rpx;
		height: auto;
		margin: 30rpx auto;
		display: flex;
		flex-wrap: wrap;
		.item {
			&:nth-child(2n+1) {
				margin-right: 20rpx;
			}
		}
	}

	.pop {
		width: 750rpx;
		height: 430rpx;
		background-color: #F3F3F5;
		border-radius: 20rpx 20rpx 0 0;
		overflow: hidden;
		.btn-box {
			width: 100%;
			height: 160rpx;
			margin-top: 80rpx;
			font-size: 28rpx;
			color: #333;
			display: flex;
			.common {
				flex: 1;
				height: 100%;
				.img-box {
					width: 100rpx;
					height: 100rpx;
					margin: auto;
					border-radius: 50rpx;
					background-color: #fff;
					display: flex;
					align-items: center;
					justify-content: center;
					image {
						width: 40rpx;
						height: 40rpx;
					}
				}
				.text {
					height: 40rpx;
					line-height: 40rpx;
					margin: 20rpx auto 0;
					text-align: center;
				}
			}
		}
		.line {
			width: 690rpx;
			height: 8rpx;
			border-radius: 4rpx;
			background-color: #EEEEEE;
			margin: 80rpx auto 0;
		}
		.foot {
			width: 100%;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			font-size: 28rpx;
			color: #999;
		}
	}
</style>
