<!--底部Tabber组件-->
<template>
	<view class="main_box">
		<fui-tabbar :tabBar="tabBar" selectedColor="#5bdbbb" :current="tabBerIndex" @click="openView"></fui-tabbar>
		
		<fui-bottom-popup :show="show" @close="closePopup">
			<view class="fui-custom__wrap">
				<view class="title" style="font-size: 36rpx;text-align: center;padding: 36rpx 0;">快捷新增</view>
				<view class="but-style">
					<view class="but-style-top">
						<view class="left" @click="writingFollowUp">
							<image src="@/static/images/index/writing.png" class="drop-image-x"></image>
							<view class="title-x">写作跟进</view>
						</view>
						<view class="right" @click="newTask">
							<image src="@/static/images/index/task.png" class="drop-image-x"></image>
							<view class="title-x">新建任务</view>
						</view>
					</view>
					<view class="but-style-below" @click="addClues">
						<image src="@/static/images/index/addto.png" class="drop-image-x"></image>
						<view class="title-x">添加线索</view>
					</view>
				</view>
			</view>
		</fui-bottom-popup>
	</view>
</template>

<script>
	import fuiTabbar from "@/components/firstui/fui-tabbar/fui-tabbar.vue"
	export default {
		name: "AQTabber",
		components: {
			fuiTabbar
		},
		data() {
			return {
				userType: '1', //用户类型|1=教练,2=销售,3=学员
				tabBerIndex: '0',
				tabBar: [],
				show: false
			};
		},

		created() {
			console.log(123)
			this.init()
		},

		methods: {
			async init() {
				let userType = uni.getStorageSync('userType')
				this.userType = userType
				let tabBerIndex = uni.getStorageSync('tabBerIndex')// tabBerIndex=0|从左数第1个按钮

				if (tabBerIndex) {
					this.tabBerIndex = String(tabBerIndex)
				} else {
					this.tabBerIndex = '0'
				}
				switch (String(this.userType)) {
					case "1": //教练
						this.tabBar = [{
								text: "首页",
								urlPath: '/pages/coach/home/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/index.png",
								selectedIconPath: "/static/images/tabbar/indexs.png"
							},
							{
								text: "课表",
								urlPath: '/pages/coach/course/list', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/timetable.png",
								selectedIconPath: "/static/images/tabbar/timetables.png"
							},
							{
								text: "班级",
								urlPath: '/pages/coach/class/list', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/banji.png",
								selectedIconPath: "/static/images/tabbar/banjis.png"
							},
							{
								text: "我的",
								urlPath: '/pages/coach/my/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/my.png",
								selectedIconPath: "/static/images/tabbar/my.png"
							}
						]
						break;
					case "2": //销售
						this.tabBar = [{
								text: "首页",
								urlPath: '/pages/market/index/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/index.png",
								selectedIconPath: "/static/images/tabbar/indexs.png"
							},
							{
								text: "线索",
								urlPath: '/pages/market/clue/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/clue.png",
								selectedIconPath: "/static/images/tabbar/clues.png"
							},
							{
								text: "",
								urlPath: '/pages/market/clue/add_clues', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/plus.png",
								selectedIconPath: "/static/images/tabbar/plus.png",
								midButton: true,
								width: 70,
								height: 70
							},
							{
								text: "数据",
								urlPath: '/pages/market/data/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/timetable.png",
								selectedIconPath: "/static/images/tabbar/timetables.png"
							},
							{
								text: "我的",
								urlPath: '/pages/market/my/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/my.png",
								selectedIconPath: "/static/images/tabbar/mys.png"
							}
						]
						break;
					case "3": //学员 
						this.tabBar = [{
								text: "首页",
								urlPath: '/pages/student/index/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/index.png",
								selectedIconPath: "/static/images/tabbar/indexs.png",
							},
							{
								text: "课表",
								urlPath: '/pages/student/timetable/index', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/timetable.png",
								selectedIconPath: "/static/images/tabbar/timetables.png",
							},
							{
								text: "我的",
								urlPath: '/pages/student/my/my', //自定义页面跳转路径
								iconPath: "/static/images/tabbar/my.png",
								selectedIconPath: "/static/images/tabbar/mys.png",
							}
						]
						break;
				}
			},
			openView(e) {
				console.log('点击跳转', e)
				if (e.text != '') {
					//跳转tabBar页面
					uni.setStorageSync('tabBerIndex', e.index)
					console.log('qqq', e.urlPath)
					uni.navigateTo({
						url: e.urlPath
					})
				}else{
					this.show = true
				}
			},
			closePopup(type) {
				this.show = false
			},
			//协作跟进
			writingFollowUp(){
				uni.navigateTo({
					url: '/pages/market/clue/writing_followUp'
				})
			},
			//新建任务
			newTask(){
				uni.navigateTo({
					url: '/pages/market/clue/new_task'
				})
			},
			//添加线索
			addClues(){
				uni.navigateTo({
					url: '/pages/market/clue/add_clues'
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.fui-wrap {
		//为防止标签栏遮住页面内容，页面底部需留白高度不低于标签栏高度。非Nvue端和头条小程序如果fixedHeight属性没有设置为true，则页面外层还需加入以下样式（或者在页面最底部加入`fui-safe-area` 组件）兼容异形屏：
		/* #ifndef APP-NVUE */
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		/* #endif */
	}
	.fui-custom__wrap {
		width: 100%;
		height: 600rpx;
	}
	.title{
		font-size: 36rpx;
		text-align: center;
		padding: 36rpx 0;
	}
	.but-style{
		width: 92%;
		height: 70%;
		margin: auto;
	}
	.but-style-top{
		width: 100%;
		display: flex;
		justify-content: space-between;
	}
	.left{
		width: 45%;
		height: 180rpx;
		border-radius: 16rpx;
		background: #3ee9d7;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.right{
		width: 45%;
		height: 180rpx;
		border-radius: 16rpx;
		background: #fad24e;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.but-style-below{
		width: 100%;
		height: 180rpx;
		margin-top: 36rpx;
		border-radius: 16rpx;
		background: #35bdae;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.drop-image-x {
		width: 50rpx;
		height: 50rpx;
	}
	.title-x {
		font-size: 32rpx;
		color: #fff;
		padding-left: 30rpx;
	}
</style>