<template>
	<view class="content">
		<view class="bindbox">
			<image :src="baseUrl + '/images/bindComUser.png'" mode="aspectFill"></image>
			<view>立即绑定，享受更多权益</view>
		</view>
		<button class="bind-btn" :loading="btnLodaing" :disabled="btnLodaing" @click="handleBind">立即绑定</button>
	</view>
</template>

<script>
	import { bindCompanyFsUser } from '@/api/companyUser.js'
	export default {
		data() {
			return {
				baseUrl:uni.getStorageSync('requestPath'),
				btnLodaing: false,
				companyUserId: '',
			}
		},
		onLoad(option) {
			let q = {}
			if(option.q) {
				q = decodeURIComponent(option.q) // 获取到二维码原始链接内容
			}
			this.companyUserId = q.companyUserId || option.companyUserId
		},
		methods: {
			handleBind() {
				this.btnLodaing = true
				uni.showLoading({
					title: '绑定中...'
				})
				bindCompanyFsUser(this.companyUserId).then(res=>{
					this.btnLodaing = false
					uni.hideLoading()
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
				}).catch(()=>{
					this.btnLodaing = false
					uni.hideLoading()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bindbox {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-top: 20vh;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 32rpx;
		color: #757575;
		image {
			height: 150rpx;
			width: 150rpx;
			margin-bottom: 50rpx;
		}
	}
	.content {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-bottom: calc(var(--window-bottom) + 150rpx);
		
	}
	.bind-btn {
		margin: 20vh auto 20px auto;
		width: 300px;
		height: 44px;
		line-height: 44px;
		text-align: center;
		background: #FF5C03 !important;
		color: #fff !important;
		font-size: 16px;
		font-weight: 500;
		border-radius: 22px;
		display: block;
		&:after {
			border: none;
		}
	}
</style>
