<template>
	<view class="container">
		<!-- tab选项 -->
		<view class="tabTitle">
			<text :class="{'actived': tabType===1}" @click="switchTab(1)">基本信息</text>
			<text :class="{'actived': tabType===2}" @click="switchTab(2)">邀请信息</text>
		</view>
		<!-- tab内容 -->
		<view class="tabContent">
			<!-- 基本信息 -->
			<view v-if="tabType===1">
				<view class="ulBox">
					<view class="liBox">
						<text>姓名：</text>
						<text><input class="uni-input" maxlength="15" placeholder="姓名" /></text>
					</view>
					<view class="liBox">
						<text>手机号：</text>
						<text><input class="uni-input" type="number" maxlength="11" placeholder="手机号" /></text>
					</view>
					<view class="liBox">
						<text>申请身份：</text>
						<text>
							<picker @change="bindPickerChange" :value="applyIdentity" :range="identityArr">
								<view class="uni-input">{{identityArr[applyIdentity]}}</view>
							</picker>
						</text>
					</view>
					<view class="liBox">
						<text>所属组织：</text>
						<text>XXXXXX</text>
					</view>
					<view class="liBox">
						<text>是否跨区邀请：</text>
						<view class="isCrossBox">
							 <view :class="{checked:isCross}">
								<i class="circle" @click="isCross=true"></i>
								<text>是</text>
							</view>
							<view :class="{checked:!isCross}">
								<i class="circle" @click="isCross=false"></i>
								<text>否</text>
							</view>
						</view>
					</view>
				</view>
				<share></share>
				<button type="primary" plain="true" class="sendInvite" @click="shareToggle()">发出邀请</button>
			</view>
			<!-- 邀请信息 -->
			<view class="inviteListsBox" v-if="tabType===2">
				<view class="listUl ulBox" v-for="item in inviteLists" >
					<view class="liBox">
						<text>姓名：</text>
						<text>{{item.name}}</text>
					</view>
					<view class="liBox">
						<text>手机号：</text>
						<text>{{item.mobileNumber}}</text>
					</view>
					<view class="liBox">
						<text>申请身份：</text>
						<text>{{item.partnerLevel == '1'? '事业伙伴' : '工作室'}}</text>
					</view>
					<view class="liBox">
						<text>所属组织：</text>
						<text>{{item.orgName}}</text>
					</view>
					<view class="liBox">
						<text>是否跨区邀请：</text>
						<text>{{item.hasCrossDistrict==1 ? '是' : '否'}}</text>
					</view>
					<view class="liBox">
						<text>邀请状态：</text>
						<text v-if="item.approvalStatus=='0'">审核中</text>
						<text v-else-if="item.approvalStatus=='1'" class="success">邀请成功</text>
						<text v-else class="fail">邀请失败</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 分享信息 -->
		<view>
			<uni-popup ref="share" type="bottom" backgroundColor="#fff">
				<view class="popup-content">
					<view class="shareBox">
						<view class="shareOptionItem" @click="uniShare(1)">
							<view class="imgBox">
								<image src="../../static/app-plus/sharemenu/wechatfriend.png" mode="widthFix"></image>
							</view>
							<text>微信好友</text>
						</view>
						<view class="shareOptionItem" @click="uniShare(2)">
							<view class="imgBox">
								<image src="../../static/app-plus/sharemenu/wechatmoments.png" mode="widthFix"></image>
							</view>
							<text>分享朋友圈</text>
						</view>
					</view>
				</view>
				<view class="popup-footer" @click="closeShare()">
					<view>取消</view>
				</view>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	import api from "@/api/api"
	export default {
		data() {
			return {
				userId:'1',
				tabType:1,
				identityArr:['工作室','事业伙伴'],
				applyIdentity:0,
				isCross:true,
				inviteLists:[]
			};
		},
		methods:{
			switchTab(type){
				this.tabType = type;
				if(this.tabType===2){
					this.queryInviteList()
				}
			},
		    bindPickerChange: function(e) {
				this.applyIdentity = e.detail.value
			},
			shareToggle() {
				this.$refs.share.open()
			},
			closeShare(){
				this.$refs.share.close()
			},
			uniShare(type){
				if(type===1){
					uni.share({
						provider: "weixin",
						scene: "WXSceneSession",
						type: 0,
						href: "https://mdev.zuihuibi.cn/cffp/",
						title: "uni-app分享",
						summary: "我正在使用HBuilderX开发uni-app，赶紧跟我一起来体验！",
						imageUrl: "https://mdev.zuihuibi.cn/cffp/static/cffp_logo.jpg",
						success: function (res) {
							console.log("success:" + JSON.stringify(res));
						},
						fail: function (err) {
							console.log("fail:" + JSON.stringify(err));
						}
					});
				}else if(type===2){
					uni.share({
						provider: "weixin",
						scene: "WXSceneTimeline",
						type: 0,
						href: "https://mdev.zuihuibi.cn/cffp/",
						title: "uni-app分享",
						summary: "我正在使用HBuilderX开发uni-app，赶紧跟我一起来体验！",
						imageUrl: "https://mdev.zuihuibi.cn/cffp/static/cffp_logo.jpg",
						success: function (res) {
							console.log("success:" + JSON.stringify(res));
						},
						fail: function (err) {
							console.log("fail:" + JSON.stringify(err));
						}
					});
				}
			},
			queryInviteList(){
				api.queryInviteList({userId:this.userId}).then(res=>{
					if(res['success']){
						this.inviteLists = res['data']['data']
					}
				})
			},
			
		
		}
	}
</script>

<style lang="scss">
	.container{
		position: relative;
		height: 100vh;
		.tabTitle{
			color: #666666;
			background-color:#fff;
			display: flex;
			align-items: center;
			justify-content: space-around;
			padding: 30rpx 60rpx 0;
			text{
				&.actived{
					color: #333;
					border-bottom: 4rpx solid #20269B;
				}
			}
		}
		.tabContent{
			margin-top: 10rpx;
			.ulBox{
				width: 95%;
				margin: 0 auto 20rpx;
				padding: 0.3125rem 1.25rem;
				color: #333;
				border-radius: 0.3125rem;
				background-color: #fff;
				box-sizing: border-box;
				position: relative;
				.liBox{
					border-bottom: 1px solid #F0F0F0;
					height: 76rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					&:last-child{
						border:none;
					}
					.uni-input{
						text-align: right;
					}
					text{
						&.success{
							color: #78C06E;
						}
						&.fail{
							color: #FF0000;
						}
					}
					.isCrossBox{
						display: flex;
						align-items: center;
						view{
							display: flex;
							align-items: center;
							&:first-child{
								margin-right: 20rpx;
							}
						.circle{
							display: block;
							width: 28rpx;
							height: 28rpx;
							border: 2rpx solid #20269B;
							border-radius: 50%;
							position: relative;
							margin: 4rpx 10rpx 0 10rpx;
						}
						&.checked{
							.circle{
								&::before{
									position: absolute;
									content: '';
									width: 20rpx;
									height: 20rpx;
									border-radius: 50%;
									left: 50%;
									top: 50%;
									background-color: #20269B;
									transform: translate(-50%,-50%);
								}
							}
						}
						
						}
					
					
					}
				
				}
				&.listUl::before{
					display: block;
					content: '';
					position: absolute;
					left: 10rpx;
					top: 20rpx;
					width: 8rpx;
					height: 20rpx;
					background-color: #FA882F;
					border-radius: 8rpx;
				}
			}
			.sendInvite{
				position: absolute;
				left: 50%;
				top: 80%;
				transform: translateX(-45%);
				width: 60%;
				border-radius: 80rpx;
				background-color: #20269B;
				color: #fff;
				font-size: 36rpx;
			}
		}
		.popup-content{
			font-size: 32rpx;
			color: #666;
			padding-bottom: 40rpx;
			.shareBox{
				display: flex;
				justify-content: space-around;
				align-items: center;
				.shareOptionItem{
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					.imgBox{
						width: 100rpx;
					}
				}
				
			}
		}
		.popup-footer{
			color: #666;
			font-size: 36rpx;
			border-top: 2rpx solid #f0f0f0;
			display: flex;
			justify-content: center;
			align-items: center;
			padding-top: 36rpx;
		}
	}
</style>
