<template>
	<view>
		<!-- 顶部操作条 -->
		<cu-custom :bgColor="'bg-main-color'" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{myOperator.level.name}}运营商</block>
		</cu-custom>
		<view class="margin-top-sm margin-lr-sm padding bg-white name-card shadow-warp">
			<!-- 个人名片 -->
			<horizontal-name-card :avatarWidth="'130rpx'" :avatarHeight="'130rpx'" :avatarPubClass="'round'"
				:vCard="myOperator.myInfo"></horizontal-name-card>
			<!-- 实名及公告图标 -->
			<view class="flex justify-end oper-bar">
				<view class="text-center margin-right-sm" @click="showCertificationForm">
					<view class="cuIcon-profilefill text-yellow"></view>
					<view class="text-xs">实名认证</view>
				</view>
				<view class="text-center">
					<view class="cuIcon-notice"></view>
					<view class="text-xs">公告</view>
				</view>
			</view>
			<!-- 团队人员统计 -->
			<view class="cu-list grid no-border col-4 solid-top margin-top-sm">
				<view class="cu-item">
					<view class="margin-bottom-xs">客户数</view>
					<view class="text-red">{{myOperator.customerNums}}</view>
				</view>
				<view class="cu-item">
					<view class="margin-bottom-xs">本月绑定</view>
					<view class="text-red">{{myOperator.customerBindCurMonth}}</view>
				</view>
				<view class="cu-item solid-left">
					<view class="margin-bottom-xs">团队</view>
					<view class="text-red">{{myOperator.teamNums}}</view>
				</view>
				<view class="cu-item">
					<view class="margin-bottom-xs">本月绑定</view>
					<view class="text-red">{{myOperator.teamBindCurMonth}}</view>
				</view>
			</view>
		</view>
		<!-- 团队订单统计 -->
		<view class="margin-lr-sm margin-top-sm padding bg-white">
			<view class="cu-list grid no-border col-4">
				<view class="cu-item" v-for="(item, index) in myOperator.orderAnalyse">
					<view class="margin-bottom-xs">{{item.title}}</view>
					<view class="text-red" v-if="item.unit === 'yuan'">
						￥{{item.num}}
					</view>
					<view v-else class="text-red">
						{{item.num}}{{item.unit}}
					</view>
				</view>
			</view>
		</view>
		<!-- 操作栏 -->
		<view class="bg-white padding margin-top-sm fixed-bottom-bar">
			<view class="flex flex-wrap justify-between">
				<view class="basis-df margin-tb-sm" v-for="(item, index) in operBtn">
					<button class="cu-btn long-btn shadow bg-main-color light" :data-cur="item.code"
						@click="doSomething">{{item.name}}</button>
				</view>
			</view>
		</view>
		<!-- 屏蔽设置 模态框 -->
		<view class="cu-modal" :class="isShowShieldSet?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">屏蔽设置</view>
					<view class="action" @tap="hideModal">
						<text class="cuIcon-close text-bold text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					<view class="margin-bottom">对所有客户屏蔽有竞争关系区域的服务和商品类目</view>
					<view>
						<text class="margin-right">屏蔽请勾选: </text>
						<checkbox style="transform:scale(0.7)" class="round sm main-color" :value="agreeShield" :checked="agreeShield"
							@click="changeAgreeShield">
						</checkbox>
					</view>
				</view>
				<view class="cu-bar bg-white">
					<view class="action margin-0 flex-sub text-black" @tap="hideModal">取消</view>
					<view class="action margin-0 flex-sub text-main-color solid-left" @tap="hideModal"
						@click="confirmShield">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import horizontalNameCard from '@/components/common-card/horizontal-name-card.vue';

	export default {
		components: {
			horizontalNameCard
		},
		data() {
			return {
				myOperator: {},
				operBtn: [{
					code: 'ShieldSet',
					name: '屏蔽设置'
				}, {
					code: '',
					name: '加价申请'
				}, {
					code: 'showTeamMembers',
					name: '查看团队'
				}, {
					code: '',
					name: '查看客户'
				}, {
					code: '',
					name: '添加团队'
				}, {
					code: '',
					name: '审批团队'
				}],
				agreeShield: false,
				isShowShieldSet: false
			}
		},
		onLoad() {
			this.loadData();
		},
		methods: {
			async loadData() {
				this.myOperator = await this.$api.data('myOperator');
			},
			hideModal(e) {
				this.isShowShieldSet = false
			},
			doSomething(e) {
				const cur = e.currentTarget.dataset.cur;
				switch (cur) {
					case 'ShieldSet':
						this.isShowShieldSet = !this.isShowShieldSet;
						break;
					case 'showTeamMembers':
						uni.navigateTo({
							url: '/pages/my/my-team-member'
						})
						break;
					default:
						break;
				}
			},
			changeAgreeShield() {
				this.agreeShield = !this.agreeShield;
			},
			confirmShield(e) {},
			showCertificationForm() {
				uni.navigateTo({
					url: '/pages/my/Certification'
				})
			}
		}
	}
</script>

<style scoped>
	.cu-list.grid.no-border>.solid-left.cu-item:after {
		border-left: 1rpx solid rgba(0, 0, 0, 0.1);
		border-left-width: 0.5px;
		border-left-style: solid;
		border-left-color: rgba(0, 0, 0, 0.1);
	}

	.name-card {
		position: relative;
	}

	.name-card .oper-bar {
		position: absolute;
		top: 20rpx;
		right: 20rpx;
		font-size: 40rpx;
	}

	.long-btn {
		width: 90%;
		margin-left: 5%;
		margin-right: 5%;
	}
</style>
