<template>
	<view>
		<uni-section title="邀请城市合伙人" type="line">
			<view class="page">
				<view class="org-picker">
					<uni-data-picker class="picker-input" placeholder="请选择组织" popup-title="请选择组织" preload :localdata="orgs" :map="{text: 'partnerClassificationName', value: 'id'}" v-model="org" @nodeclick="orgClick" @popupclosed="orgClose"></uni-data-picker>
				</view>
				<button type="primary" @click="toCode">生成邀请二维码</button>
			</view>
		</uni-section>
	</view>
</template>

<script>
	import { treeList } from '@/apis/modules/parner.js'
	export default {
		data() {
			return {
				orgs: [],
				org: '',
				orgTemp: '',
				extraIcon: {
					color: '#007eff',
					size: '22',
					type: 'icon-qrcode'
				}
			}
		},
		onShow() {
			this.getOrg()
		},
		methods: {
			// 获取组织
			getOrg() {
				treeList().then(({ treeList }) => {
					this.orgs = treeList
				}).catch(e => {})
			},
			// 组织点击回调
			orgClick(e) {
				this.orgTemp = e.id
			},
			// 组织关闭回调
			orgClose(e) {
				this.org = this.orgTemp
			},
			// 邀请成员
			toCode() {
				this.$util.to(`../qrcode/qrcode?id=${this.org}`)
			}
		}
	}
</script>

<style scoped lang="scss">
.page {
	padding: 0 20px 20px;
	.org-picker {
		margin-bottom: 20px;
	}
}
.slot-box {
	display: flex;
	flex-direction: row;
	align-items: center;
}
.icon {
	width: 25px;
	height: 25px;
	margin-right: 10px;
}
.text {
	font-size: 14px;
}
</style>
