<template>
	<view class="">
		<view style="padding: 10px 20px;">
			<u-divider text="互助组信息"></u-divider>
			<u-radio-group v-model="groupId" placement="column" :size="20" iconPlacement="right"
				style="margin-top: 25px;">
				<view v-for="(item,index) in groupList">
					<u-radio style="font-size: 14px;"
						:label="(index+1)+'.'+item.orgName+'('+(item.leaderName?item.leaderName:'未分配组长')+')'"
						:name="item.id" :customStyle="{marginBottom: '18px'}" :labelSize="19"></u-radio>
					<u-divider></u-divider>
				</view>
			</u-radio-group>
		</view>
		<view style="height: 50px;"></view>
		<view class="mfooter">
			<view class="flex">
				<view class="f">
					<button class="btn" @click="apply()">申请加入</button>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				groupId: undefined,
				groupList: [],
			};
		},
		onLoad() {

		},
		onShow() {
			this.checkGroup()
		},
		methods: {
			getGroupList() {
				this.http.request({
					url: '/level-one-server/app/TbGroup/getList',
					data: {
						pageNo: 1,
						pageSize: 200
					},
					success: res => {
						this.groupList = res.data.data;

					}
				});
			},
			checkGroup() {
				this.http.request({
					url: '/sp-admin/app/AppUser/getAuth',
					success: res => {
						this.groupId = res.data.data.groupId;
						this.getGroupList()
					}
				});
			},
			apply() {
				let groupId=this.groupId;
				if(!groupId){
					uni.showModal({
						content: '请选择互助组',
						showCancel: false
					});
					return;
				}
				let groupName=this.groupList.filter(obj=>obj.id==groupId)[0].orgName;
				let that=this;
				uni.showModal({
					title:'提示',
					content:'是否申请加入【'+groupName+'】',
					success(resp) {
						if(resp.confirm){
							that.http.request({
								url: '/level-one-server/app/TbPeople/joinGroup',
								data:{groupId,groupId,groupName:groupName},
								success: res => {
									uni.showToast({
										title: '提交成功'
									})
								}
							});
						}
						
					}
				})
			}
		},
	}
</script>
<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.my_top {
		position: relative;
		overflow: hidden;

		image {
			width: 100%;
		}
	}

	.list {
		position: relative;
		padding: 0px 20px 10px 20px;
		margin-top: -196px;

		.user {
			background-color: white;
			padding: 20px;
			border-radius: 8px;
			color: $font-c;

			.head {
				float: left;
				width: 55px;
				height: 55px;
			}

			.con {
				float: left;
				padding-left: 15px;
				width: 60%;

				.nickName {
					font-size: 17px;
					font-weight: bold;
				}

				.tag {
					background-color: #6799ad;
					color: white;
					float: left;
					font-size: 13px;
					padding: 2px 6px;
					border-radius: 5px;
					margin-top: 6px;
				}
			}

			.edit {
				float: right;
				font-size: 20px;
				margin-top: 17px;
			}
		}
	}

	.exit {
		margin-top: 20px;
		background-color: white;
		color: #f44336;
	}
</style>