<template>
	<view class="">
		<view style="padding: 10px 20px;">
			<u-divider text="互助组信息"></u-divider>
			<view class="info" v-if="info">
				<view>场所：{{info.tradeAreaName}}</view>
				<view>名称：{{info.orgName}}</view>
				<view>组长：{{info.leaderName}}</view>
				<view style="display: flex;">
					<view>
						联系号码：{{info.leaderPhone}}
					</view>
					<u-icon @click.stop="makePhoneCall(info.leaderPhone)" v-if="info.leaderPhone" name="phone-fill"
						size="25" style="margin-left:10px;cursor: pointer;" color="#07c5ff"></u-icon>
				</view>
			</view>
			<view v-else style="display: flex;text-align: center;">
				<view>
					未查询到互助组信息(
				</view>
				<view style="color: blue;" text="" @click="joinGroup">加入互助组</view>)
			</view>
			<button class="btn back" @click="back()">返回</button>
		</view>
		<view style="height: 50px;"></view>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				info: null,

			};
		},
		onLoad() {

		},
		onShow() {
			this.checkGroup()
		},
		methods: {
			joinGroup() {
				uni.navigateTo({
					url:'/pages/personal/group'
				})
			},
			back() {
				uni.navigateBack()
			},
			makePhoneCall(phone) {
				uni.makePhoneCall({
					phoneNumber: phone
				});
			},
			getGroupList() {
				this.http.request({
					url: '/level-one-server/app/TbPeople/getGroupInfo',
					success: res => {
						this.info = 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;
	}

	.info {
		font-size: 18px;
		line-height: 30px;
	}

	.back {
		margin-top: 50px;
	}
</style>