<template>
	<view class="page">
		<view class="team">
			<uni-data-picker class="picker-input" placeholder="切换团队" popup-title="切换团队" preload :clear-icon="false" :localdata="list" v-model="partnerId" @change="teamChange"></uni-data-picker>
		</view>
		
		<image class="banner" src="../../static/image/index/index1.png" mode="widthFix"></image>
		<ul class="entry">
			<li @click="$util.to('../clients/clients')">
				<image class="icon" src="../../static/image/index/index3.png" mode="widthFix"></image>
				<view class="text">客户</view>
			</li>
			<li @click="$util.to('../plans/plans')">
				<image class="icon" src="../../static/image/index/index4.png" mode="widthFix"></image>
				<view class="text">方案</view>
			</li>
			<li @click="$util.to('../orders/orders')">
				<image class="icon" src="../../static/image/index/index5.png" mode="widthFix"></image>
				<view class="text">订单</view>
			</li>
			<li @click="$util.to('../products/products')">
				<image class="icon" src="../../static/image/index/index6.png" mode="widthFix"></image>
				<view class="text">产品</view>
			</li>
		</ul>
	</view>
</template>

<script>
	import { getTeamsByAccountId } from '@/apis/modules/client.js'
	export default {
		data() {
			return {
				partnerId: uni.getStorageSync('partnerId') || '',
				list: [],
			}
		},
		onShow() {
			this.getInfo()
		},
		methods: {
			// 获取团队
			getInfo() {
				getTeamsByAccountId().then(({ data }) => {
					const result = []
					data.map(e => {
						result.push({
							text: e.partnerClassificationName,
							value: e.partnerId
						})
					})
					this.list = result
				}).catch(e => {})
			},
			// 团队选择回调
			teamChange() {
				uni.setStorageSync('partnerId', this.partnerId)
			}
		}
	}
</script>

<style scoped lang="scss">
.page {
	min-height: 100%;
	padding: 30rpx 22rpx;
	background: url(../../static/image/index/index2.png) 0 0/100% 100% no-repeat;
}
.team {
	width: 200rpx;
	margin-bottom: 30rpx;
}
.banner {
	width: 100%;
}
.entry {
	display: flex;
	justify-content: space-around;
	align-items: center;
	margin-top: 10rpx;
	text-align: center;
	.icon {
		width: 78rpx;
	}
	.text {
		font-size: 28rpx;
		color: #333;
	}
}
</style>
